Commit a4cc6a02 authored by David Mendez's avatar David Mendez
Browse files

Use global variables in deployment

parent e1a130d6
...@@ -94,12 +94,14 @@ deploy-dev-hx: ...@@ -94,12 +94,14 @@ deploy-dev-hx:
- dev - dev
stage: deploy stage: deploy
script: script:
- echo $KUBE_URL_HX - set -x
- echo "$KUBE_CA_PEM_HX" > "$(pwd)/kube.ca.pem" - echo "$KUBE_CA_PEM_HX" > "$(pwd)/kube.ca.pem"
- kubectl config set-cluster ${KUBE_CLUS_NAME_HX} --server="${KUBE_URL_HX}" --certificate-authority="$(pwd)/kube.ca.pem" - kubectl config set-cluster ${KUBE_CLUS_NAME_HX} --server="${KUBE_URL_HX}" --certificate-authority="$(pwd)/kube.ca.pem"
- kubectl config set-credentials ${KUBE_USER_HX} --token="${KUBE_TOKEN_HX}" - kubectl config set-credentials ${KUBE_USER_HX} --token="${KUBE_TOKEN_HX}"
- kubectl config set-context ${KUBE_NAMESPACE_DEV} --cluster=${KUBE_CLUS_NAME_HX} --user=${KUBE_USER_HX} - kubectl config set-context ${CHEMBL_NS_STAGING} --cluster=${KUBE_CLUS_NAME_HX} --user=${KUBE_USER_HX}
- kubectl config use-context ${KUBE_NAMESPACE_DEV} - kubectl config use-context ${CHEMBL_NS_STAGING}
- echo ${CHEMBL_NS_STAGING} ${KUBE_URL_HX} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX}
- kubectl get pods -n ${CHEMBL_NS_STAGING}
- kubectl create secret generic ${ENV_SECRET_NAME_STAGING} --from-file=.env=${ENV_STAGING_FILE_PATH} -o yaml -n ${CHEMBL_NS_STAGING} --dry-run=client | kubectl apply -f - - kubectl create secret generic ${ENV_SECRET_NAME_STAGING} --from-file=.env=${ENV_STAGING_FILE_PATH} -o yaml -n ${CHEMBL_NS_STAGING} --dry-run=client | kubectl apply -f -
- cat ${CONFIG_STAGING_FILE_PATH} - cat ${CONFIG_STAGING_FILE_PATH}
- echo ${KUBE_NAMESPACE_DEV} ${KUBE_URL_HH} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX} - echo ${KUBE_NAMESPACE_DEV} ${KUBE_URL_HH} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX}
...@@ -138,46 +140,38 @@ prepare_config_prod: ...@@ -138,46 +140,38 @@ prepare_config_prod:
- ${INGRESS_PROD_HH_FILE_PATH} - ${INGRESS_PROD_HH_FILE_PATH}
# deploy-dev-hh: deploy-prod-hx:
# image: image:
# name: lachlanevenson/k8s-kubectl:latest name: lachlanevenson/k8s-kubectl:latest
# entrypoint: ["/bin/sh", "-c"] entrypoint: ["/bin/sh", "-c"]
# stage: deploy stage: deploy
# script: only:
# - echo $KUBE_URL_HH - master
# - echo "$KUBE_CA_PEM_HH" > "$(pwd)/kube.ca.pem" script:
# - kubectl config set-cluster ${KUBE_CLUS_NAME_HH} --server="${KUBE_URL_HH}" --certificate-authority="$(pwd)/kube.ca.pem" - echo $KUBE_URL_HX
# - kubectl config set-credentials ${KUBE_USER_HH} --token="${KUBE_TOKEN_HH}" - echo "$KUBE_CA_PEM_HX" > "$(pwd)/kube.ca.pem"
# - kubectl config set-context ${KUBE_NAMESPACE_DEV} --cluster=${KUBE_CLUS_NAME_HH} --user=${KUBE_USER_HH} - kubectl config set-cluster ${KUBE_CLUS_NAME_HX} --server="${KUBE_URL_HX}" --certificate-authority="$(pwd)/kube.ca.pem"
# - kubectl config use-context ${KUBE_NAMESPACE_DEV} - kubectl config set-credentials ${KUBE_USER_HX} --token="${KUBE_TOKEN_HX}"
# - echo ${KUBE_NAMESPACE_DEV} ${KUBE_URL_HH} ${KUBE_CLUS_NAME_HH} ${KUBE_USER_HH} - kubectl config set-context ${KUBE_NAMESPACE_PROD} --cluster=${KUBE_CLUS_NAME_HX} --user=${KUBE_USER_HX}
# - kubectl get pods -n ${KUBE_NAMESPACE_DEV} - kubectl config use-context ${KUBE_NAMESPACE_PROD}
# - sed -i "s~<VERSION>~${CI_COMMIT_SHORT_SHA}~" k8s-deployment.yml
# - sed -i "s~<DOCKER_IMAGE>~${DOCKER_IMAGE}~" k8s-deployment.yml
# - kubectl apply -n ${KUBE_NAMESPACE_DEV} -f k8s-deployment.yml
# only:
# - dev
# deploy-prod-hx: - kubectl create secret generic ${RUN_CONFIG_SECRET_NAME_PROD_HX} --from-file=.env=${ENV_PROD_HX_FILE_PATH} -o yaml -n ${CHEMBL_NS_} --dry-run=client | kubectl apply -f -
# image:
# name: lachlanevenson/k8s-kubectl:latest
# entrypoint: ["/bin/sh", "-c"] - cat ${CONFIG_STAGING_FILE_PATH}
# stage: deploy - echo ${KUBE_NAMESPACE_DEV} ${KUBE_URL_HH} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX}
# script: - kubectl get pods -n ${KUBE_NAMESPACE_DEV}
# - echo $KUBE_URL_HX - sed -i "s~<VERSION>~${CI_COMMIT_SHORT_SHA}~" k8s-deployment.yml
# - echo "$KUBE_CA_PEM_HX" > "$(pwd)/kube.ca.pem" - sed -i "s~<DOCKER_IMAGE>~${DOCKER_IMAGE}~" k8s-deployment.yml
# - kubectl config set-cluster ${KUBE_CLUS_NAME_HX} --server="${KUBE_URL_HX}" --certificate-authority="$(pwd)/kube.ca.pem" - sed -i "s~<HTTP_PROXY>~${HTTP_PROXY_HX}~g" k8s-deployment.yaml
# - kubectl config set-credentials ${KUBE_USER_HX} --token="${KUBE_TOKEN_HX}" - sed -i "s~<HTTPS_PROXY>~${HTTPS_PROXY_HX}~g" k8s-deployment.yaml
# - kubectl config set-context ${KUBE_NAMESPACE_PROD} --cluster=${KUBE_CLUS_NAME_HX} --user=${KUBE_USER_HX} - sed -i "s~<NO_PROXY>~${NO_PROXY_HX_DEFAULT}~g" k8s-deployment.yaml
# - kubectl config use-context ${KUBE_NAMESPACE_PROD} - sed -i "s~<ENV_SECRET_NAME>~${RUN_CONFIG_SECRET_NAME_STAGING}~g" k8s-deployment.yaml
# - echo ${KUBE_NAMESPACE_DEV} ${KUBE_URL_HX} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX} - kubectl apply -n ${KUBE_NAMESPACE_DEV} -f k8s-deployment.yml
# - kubectl get pods -n ${KUBE_NAMESPACE_PROD} - cat ${INGRESS_STAGING_FILE_PATH}
# - sed -i "s~<VERSION>~${CI_COMMIT_SHORT_SHA}~" k8s-deployment.yml - kubectl apply -n ${CHEMBL_NS_STAGING} -f ${INGRESS_STAGING_FILE_PATH}
# - sed -i "s~<DOCKER_IMAGE>~${DOCKER_IMAGE}~" k8s-deployment.yml
# - kubectl apply -n ${KUBE_NAMESPACE_PROD} -f k8s-deployment.yml
# when: manual
# only:
# - master
# deploy-prod-hh: # deploy-prod-hh:
# image: # image:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment