diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f5b1fbd2fe47fb9e8f98e390b296bf6e959275b0..325816ef23c4dcbf7ab16474f6f27a877ba83544 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -120,10 +120,12 @@ deploy-image: when: 'always' variables: ENVIRONMENT_NAME: 'staging' + STATIC_IP: 'staging-todoapp-ip' - if: $CI_COMMIT_REF_NAME !~ /main/ when: 'always' variables: ENVIRONMENT_NAME: 'production' + STATIC_IP: 'todoapp-ip' tags: - docker image: google/cloud-sdk:${GOOGLE_CLOUD_SDK_IMAGE_VERSION} @@ -137,7 +139,8 @@ deploy-image: - DEPLOYMENT_MANIFEST=$(sed -e "s,{{image}},${IMAGE},g" ./deployment.yaml.tmpl) - echo "${DEPLOYMENT_MANIFEST}" | kubectl apply --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}" --filename - - kubectl apply -f service.yaml --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}" - - kubectl apply -f ingress.yaml --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}" + - INGRESS_MANIFEST=$(sed -e "s,{{static-ip-name}},${STATIC_IP},g" ./ingress.yaml.tmpl) + - echo "${INGRESS_MANIFEST}" | kubectl apply --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}" --filename - diff --git a/k8s-manifests/ingress.yaml b/k8s-manifests/ingress.yaml.tmpl similarity index 86% rename from k8s-manifests/ingress.yaml rename to k8s-manifests/ingress.yaml.tmpl index 675762207cbe8609b5b265db97b48d3ce8e356fb..7635067ab99bf8b02bce80d803d08e0d511c327f 100644 --- a/k8s-manifests/ingress.yaml +++ b/k8s-manifests/ingress.yaml.tmpl @@ -5,7 +5,7 @@ metadata: annotations: kubernetes.io/ingress.class: "gce" # an external load-balancer kubernetes.io/ingress.allow-http: "false" # disabling HTTP - kubernetes.io/ingress.global-static-ip-name: todoapp-ip # staging-todoapp-ip for staging + kubernetes.io/ingress.global-static-ip-name: {{static-ip-name}} # staging-todoapp-ip for staging networking.gke.io/managed-certificates: todoapp-managed-cert # defined in the infrastructure repository spec: # rules: