Skip to content
Snippets Groups Projects
gitlab-ci.yaml 4.11 KiB
Newer Older
# This file is included as part of the main repository .gitlab-ci.yml file
David Hoese's avatar
David Hoese committed

  environment:
    name: gcp
  extends: .helm_based_job
  before_script:
    - export KUBECONFIG="/root/.kube/config"
    - gcloud --verbosity=debug auth activate-service-account "${GEOSPHERE_DEPLOY_GCP_SA_EMAIL}" --key-file="${GEOSPHERE_DEPLOY_GCP_SA_KEY}"
    # If this produces a warning about not having permission make sure the SA
    # has the project "Viewer" role. If it still produces a warning then try
    # enabling this Cloud Resource Manager API. See admin/GCP_README.md
    # for more information.
    - gcloud --verbosity=debug config set project "${GEOSPHERE_DEPLOY_GCP_PROJECT_NAME}"
    - gcloud --verbosity=debug container clusters get-credentials "${GEOSPHERE_DEPLOY_GCP_CLUSTER_NAME}" --zone "${GEOSPHERE_DEPLOY_GCP_ZONE_NAME}";
    - helm registry login -u ${CI_REGISTRY_USER} -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
    - helm repo add stable https://kubernetes-charts.storage.googleapis.com
    - helm repo update
David Hoese's avatar
David Hoese committed
    - if: $CI_COMMIT_TAG !~ /^gcp-r[0-9]+_[0-9]+/
      when: never
    - when: on_success

test gcp connection:
  extends: .gcloud_base
  stage: test
  # don't need any artifacts for this to run
  dependencies: []
  script:
    - gcloud compute instances list
    - if [ "${GEOSPHERE_DEPLOY_GCP_CLUSTER_NAME}" != "" ]; then
        gcloud container clusters get-credentials "${GEOSPHERE_DEPLOY_GCP_CLUSTER_NAME}" --zone "${GEOSPHERE_DEPLOY_GCP_ZONE_NAME}";
        kubectl get all;
      fi

David Hoese's avatar
David Hoese committed
gcp deploy grb:
  extends: .gcloud_base
  stage: deploy GRB
    - ns=$(./helpers/get_namespace.sh)
    - cd geosphere-grb/chart
    - source cspp-geo-grb/cibuild.env
    # copy private ssh key to the chart for inclusion in the secret
    - cp $GRB_PROXY_SSH_KEY cspp-geo-grb/secrets/grb_ssh_proxy_rsa
    - echo "Deploying version $docker_tag to cluster namespace $ns"
    - helm upgrade -v 2 --install --namespace $ns -f ../../ci_gcp/values-grb-g16.yaml cspp-geo-grb cspp-geo-grb/
  dependencies:
    - get_chart_grb

David Hoese's avatar
David Hoese committed
gcp create geotiff storage:
  extends: .gcloud_base
  stage: create storage
  script:
    - ns=$(./helpers/get_namespace.sh)
    - ./helpers/create_pvc.sh "$ns" "ci_${ns}/geotiff-pvc.yaml" "cspp-geo-geo2grid" "$KUBECONFIG"
  # this job doesn't actually need any artifacts from previous jobs
  dependencies: []
  rules:
David Hoese's avatar
David Hoese committed
    - if: $CI_COMMIT_TAG !~ /^gcp-r[0-9]+_[0-9]+/
      when: never
    # this will always be true for tags
    - changes:
        - ci_gcp/geotiff-pvc.yaml
David Hoese's avatar
David Hoese committed
gcp create shapefile storage:
  extends: .gcloud_base
  stage: create storage
  script:
    - ns=$(./helpers/get_namespace.sh)
    - ./helpers/create_pvc.sh "$ns" "ci_${ns}/shapefiles-pvc.yaml" "geosphere-tile-gen-shapefiles" "$KUBECONFIG"
  # this job doesn't actually need any artifacts from previous jobs
  dependencies: []
  rules:
David Hoese's avatar
David Hoese committed
    - if: $CI_COMMIT_TAG !~ /^gcp-r[0-9]+_[0-9]+/
      when: never
    # this will always be true for tags
    - changes:
        - ci_gcp/shapefiles-pvc.yaml
David Hoese's avatar
David Hoese committed
gcp deploy rabbit:
  environment:
    name: geosphere
    url: http://geosphere.ssec.wisc.edu
  stage: deploy rabbit
  script:
    - ./helpers/deploy_rabbitmq.sh ci_geosphere
  # this job doesn't actually need any artifacts from previous jobs
  dependencies: []
  rules:
David Hoese's avatar
David Hoese committed
    - if: $CI_COMMIT_TAG !~ /^gcp-r[0-9]+_[0-9]+/
      when: never
    # no need to build if another project triggered us
    - if: $CI_PIPELINE_SOURCE == "pipeline"
      when: never
    - changes:
        - ci_geosphere/values-geosphere-rabbit.yaml
    - if: $DEPLOY_RABBIT

David Hoese's avatar
David Hoese committed
gcp deploy client:
  stage: deploy Client
  script:
    - ns=$(./helpers/get_namespace.sh)
    - cd geosphere-client/chart
    - source geosphere-client/cibuild.env
    - echo "Deploying version $docker_tag to cluster namespace $ns"
    - helm upgrade -v 2 --kubeconfig $HOME/.kube/config --install --namespace $ns -f ../../ci_gcp/values-client.yaml geosphere-client geosphere-client/
  dependencies:
    - get_chart_client_test
  rules:
David Hoese's avatar
David Hoese committed
    - if: $CI_COMMIT_TAG !~ /^gcp-r[0-9]+_[0-9]+/
      when: never
    - when: on_success