mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-07 20:39:04 +03:00
Improve deploy scripts
This commit is contained in:
parent
0c9ceb51e6
commit
2f1ddc0d0f
@ -9,6 +9,7 @@ spec:
|
||||
restartPolicy: Never
|
||||
containers:
|
||||
- name: migrator
|
||||
imagePullPolicy: Always
|
||||
image: ${ZED_IMAGE_ID}
|
||||
args:
|
||||
- migrate
|
||||
|
@ -7,11 +7,16 @@ if [[ $# < 2 ]]; then
|
||||
echo "Usage: $0 <production|staging|preview> <tag-name>"
|
||||
exit 1
|
||||
fi
|
||||
export ZED_KUBE_NAMESPACE=$1
|
||||
COLLAB_VERSION=$2
|
||||
environment=$1
|
||||
version=$2
|
||||
|
||||
export_vars_for_environment ${environment}
|
||||
image_id=$(image_id_for_version ${version})
|
||||
|
||||
export ZED_KUBE_NAMESPACE=${environment}
|
||||
export ZED_IMAGE_ID=${image_id}
|
||||
|
||||
export_vars_for_environment $ZED_KUBE_NAMESPACE
|
||||
export ZED_IMAGE_ID=$(image_id_for_version $COLLAB_VERSION)
|
||||
target_zed_kube_cluster
|
||||
|
||||
envsubst < crates/collab/k8s/manifest.template.yml | kubectl apply -f -
|
||||
|
||||
echo "deployed collab v${version} to ${environment}"
|
@ -7,14 +7,20 @@ if [[ $# < 2 ]]; then
|
||||
echo "Usage: $0 <production|staging|preview> <tag-name>"
|
||||
exit 1
|
||||
fi
|
||||
export ZED_KUBE_NAMESPACE=$1
|
||||
COLLAB_VERSION=$2
|
||||
environment=$1
|
||||
version=$2
|
||||
|
||||
export_vars_for_environment ${environment}
|
||||
image_id=$(image_id_for_version ${version})
|
||||
|
||||
export ZED_KUBE_NAMESPACE=${environment}
|
||||
export ZED_IMAGE_ID=${image_id}
|
||||
export ZED_MIGRATE_JOB_NAME=zed-migrate-${version}
|
||||
|
||||
export_vars_for_environment $ZED_KUBE_NAMESPACE
|
||||
export ZED_IMAGE_ID=$(image_id_for_version ${COLLAB_VERSION})
|
||||
export ZED_MIGRATE_JOB_NAME=zed-migrate-${COLLAB_VERSION}
|
||||
target_zed_kube_cluster
|
||||
|
||||
envsubst < crates/collab/k8s/migrate.template.yml | kubectl apply -f -
|
||||
pod=$(kubectl --namespace=${ZED_KUBE_NAMESPACE} get pods --selector=job-name=${ZED_MIGRATE_JOB_NAME} --output=jsonpath='{.items[*].metadata.name}')
|
||||
echo "pod:" $pod
|
||||
|
||||
pod=$(kubectl --namespace=${environment} get pods --selector=job-name=${ZED_MIGRATE_JOB_NAME} --output=jsonpath='{.items[0].metadata.name}')
|
||||
|
||||
echo "Job pod:" $pod
|
||||
kubectl --namespace=${environment} logs -f ${pod}
|
@ -1,14 +1,8 @@
|
||||
# Prerequisites:
|
||||
#
|
||||
# - Log in to the DigitalOcean API, either interactively, by running
|
||||
# `doctl auth init`, or by setting the `DIGITALOCEAN_ACCESS_TOKEN`
|
||||
# environment variable.
|
||||
|
||||
function export_vars_for_environment {
|
||||
local environment=$1
|
||||
local env_file="crates/collab/k8s/environments/${environment}.sh"
|
||||
if [[ ! -f $env_file ]]; then
|
||||
echo "Invalid environment name '${environment}'"
|
||||
echo "Invalid environment name '${environment}'" >&2
|
||||
exit 1
|
||||
fi
|
||||
export $(cat $env_file)
|
||||
@ -16,15 +10,18 @@ function export_vars_for_environment {
|
||||
|
||||
function image_id_for_version {
|
||||
local version=$1
|
||||
|
||||
# Check that version is valid
|
||||
if [[ ! ${version} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "Invalid version number '${version}'"
|
||||
echo "Invalid version number '${version}'" >&2
|
||||
exit 1
|
||||
fi
|
||||
TAG_NAMES=$(doctl registry repository list-tags collab --no-header --format Tag)
|
||||
if ! $(echo "${TAG_NAMES}" | grep -Fqx v${version}); then
|
||||
echo "No such image tag: 'zed/collab:v${version}'"
|
||||
echo "Found tags"
|
||||
echo "${TAG_NAMES}"
|
||||
|
||||
# Check that image exists for version
|
||||
tag_names=$(doctl registry repository list-tags collab --no-header --format Tag)
|
||||
if ! $(echo "${tag_names}" | grep -Fqx v${version}); then
|
||||
echo "No docker image tagged for version '${version}'" >&2
|
||||
echo "Found images with these tags:" ${tag_names} >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -7,11 +7,29 @@ if [[ $# < 1 ]]; then
|
||||
echo "Usage: $0 <production|staging|preview>"
|
||||
exit 1
|
||||
fi
|
||||
ZED_KUBE_NAMESPACE=$1
|
||||
environment=$1
|
||||
|
||||
export_vars_for_environment $ZED_KUBE_NAMESPACE
|
||||
export_vars_for_environment ${environment}
|
||||
target_zed_kube_cluster
|
||||
|
||||
IMAGE_ID=$(kubectl --namespace=${ZED_KUBE_NAMESPACE} get deployment collab -o 'jsonpath={.spec.template.spec.containers[0].image}')
|
||||
deployed_image_id=$(
|
||||
kubectl \
|
||||
--namespace=${environment} \
|
||||
get deployment collab \
|
||||
-o 'jsonpath={.spec.template.spec.containers[0].image}' \
|
||||
| cut -d: -f2
|
||||
)
|
||||
|
||||
echo "Deployed image on ${ZED_KUBE_NAMESPACE}:" $(version_for_image_id $IMAGE_ID)
|
||||
job_image_ids=$(
|
||||
kubectl \
|
||||
--namespace=${environment} \
|
||||
get jobs \
|
||||
-o 'jsonpath={range .items[0:5]}{.spec.template.spec.containers[0].image}{"\n"}{end}'
|
||||
)
|
||||
|
||||
echo "Deployed image version:"
|
||||
echo "$deployed_image_id"
|
||||
echo
|
||||
echo "Migration job image versions:"
|
||||
echo "$job_image_ids"
|
||||
echo
|
||||
|
Loading…
Reference in New Issue
Block a user