Skip to content

Instantly share code, notes, and snippets.

@omerxx
Created May 10, 2019 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omerxx/99ba877d75084aaca5473da5bdcd3609 to your computer and use it in GitHub Desktop.
Save omerxx/99ba877d75084aaca5473da5bdcd3609 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Setting a defaults
ECR_REG=${ECR_REG:-000.dkr.ecr.cn-northwest-1.amazonaws.com.cn}
CHINA=${CHINA:-false}
# Changing registries to Chinese accessible mirrors
#
set_china_environment() {
REGISTRY="000.dkr.ecr.cn-northwest-1.amazonaws.com.cn"
QUAY="quay.azk8s.cn"
GCR="gcr.azk8s.cn"
K8SGCR="registry.aliyuncs.com/google_containers"
DOCKERHUB="dockerhub.azk8s.cn"
}
# Switching China options on with an environment variable
#
running_from_china() {
if [[ ${CHINA} == "true" ]]; then
return 0
else
return 1
fi
}
# Using HELM to install and set registries dynamically
#
helm_install_my_application() {
helm install --upgrade \
--set global.repository="${REGISTRY}" \
--set prometheus-operator.prometheus.prometheusSpec.image.repository="${QUAY}/prometheus/prometheus" \
my_application .
# Main function
#
run() {
running_from_china && set_china_environment
helm_install_my_application
}
run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment