osdu-gcp-gke.yml 6.3 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# Copyright 2021 Google LLC
# Copyright 2017-2019, Schlumberger
# Copyright 2021 EPAM
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Global Protected Variables:
#
# OSDU_GCP
# OSDU_GCP_DEPLOY_FILE
# OSDU_GCP_SERVICE_ACCOUNT
# OSDU_GCP_INTEGRATION_TESTER
# OSDU_GCP_NO_DATA_ACCESS_TESTER

include:
  - local: "cloud-providers/osdu-gcp-global.yml"

.osdu-gcp-variables:
  variables:
    # services' urls
    OSDU_GCP_AUTHORIZE_API: http://entitlements-sql/api/entitlements/v2/
    # should be changed to gke local url after parition is migrated in community gke
    OSDU_GCP_PARTITION_API: https://os-partition-attcrcktoa-uc.a.run.app/api/partition/v1/
    # common helm variables
    OSDU_GCP_HELM_PACKAGE_CHARTS: "devops/gcp/deploy devops/gcp/configmap"
    OSDU_GCP_HELM_DEPLOYMENT_DIR: "devops/gcp/deploy"
    OSDU_GCP_HELM_CONFIG_DIR: "devops/gcp/configmap"
    OSDU_GCP_HELM_NAMESPACE: default
    # common variables
    OSDU_GCP_PROJECT: nice-etching-277309
    OSDU_GCP_CLUSTER: asm-primary
    OSDU_GCP_ZONE: us-central1-c
    OSDU_GCP_PORT: 8080
    REDIS_GROUP_HOST: 10.234.198.27
    REDIS_STORAGE_HOST: 10.16.59.203
    OSDU_GCP_LOCAL_IMAGE_TAG_SHA: $CI_REGISTRY_IMAGE/osdu-gcp:$CI_COMMIT_SHORT_SHA
    # common variables for tests
    DOMAIN: osdu-gcp.go3-nrg.projects.epam.com
    GOOGLE_AUDIENCE: 689762842995-pv217jo3k8j803kk6gqf52qb5amos3a9.apps.googleusercontent.com
    INTEGRATION_TEST_AUDIENCE: 689762842995-pv217jo3k8j803kk6gqf52qb5amos3a9.apps.googleusercontent.com
    LEGAL_TAG: osdu-demo-legaltag
    OTHER_RELEVANT_DATA_COUNTRIES: US
    DEFAULT_DATA_PARTITION_ID_TENANT1: osdu
    GCLOUD_PROJECT: nice-etching-277309
    OSDU_GCP_TESTING_DIR: testing
    OSDU_GCP_TEST_SUBDIR: testing/$OSDU_GCP_SERVICE-test-$OSDU_GCP_VENDOR
    # variables for legal tests
    MY_TENANT_PROJECT: osdu
    MY_TENANT: osdu
    SKIP_HTTP_TESTS: "true"
    HOST_URL: https://community.osdu-gcp.go3-nrg.projects.epam.com/api/legal/v1/

.common: &common
  - gcloud auth activate-service-account --key-file $OSDU_GCP_DEPLOY_FILE
  - gcloud config set project $OSDU_GCP_PROJECT
  - gcloud container clusters get-credentials $OSDU_GCP_CLUSTER --zone $OSDU_GCP_ZONE --project $OSDU_GCP_PROJECT
  - curl https://get.helm.sh/helm-v3.5.4-linux-amd64.tar.gz -s -o helm.tgz; tar -zxf helm.tgz; mv linux-amd64/helm /usr/local/bin/

osdu-gcp-containerize-gitlab:
  stage: containerize
  needs: ["compile-and-unit-test"]
  tags: ["osdu-medium"]
  extends: .osdu-gcp-variables
  image: docker:19.03
  cache: {}
  script:
    - export EXTRA_DOCKER_TAG=""; if [ "$CI_COMMIT_TAG" != "" ] ; then EXTRA_DOCKER_TAG="-t $CI_REGISTRY_IMAGE/osdu-gcp:$CI_COMMIT_TAG" ; elif [ "$CI_COMMIT_REF_NAME" = "master" ] ; then EXTRA_DOCKER_TAG="-t $CI_REGISTRY_IMAGE/osdu-gcp:latest" ; fi
    - docker build -t $OSDU_GCP_LOCAL_IMAGE_TAG_SHA $EXTRA_DOCKER_TAG --file provider/$OSDU_GCP_SERVICE-$OSDU_GCP_VENDOR/cloudbuild/Dockerfile.cloudbuild --build-arg PROVIDER_NAME=$OSDU_GCP_VENDOR --build-arg PORT=$OSDU_GCP_PORT .
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker push $CI_REGISTRY_IMAGE/osdu-gcp
  only:
    variables:
      - $OSDU_GCP == 'true'

osdu-gcp-deploy-configmap:
  extends: .osdu-gcp-variables
  image: gcr.io/google.com/cloudsdktool/cloud-sdk
  stage: deploy
  needs: ["compile-and-unit-test"]
  script:
    - *common
    - >
      helm upgrade $OSDU_GCP_HELM_CONFIG_SERVICE $OSDU_GCP_HELM_CONFIG_DIR
      --install
      --create-namespace
      --namespace=$OSDU_GCP_HELM_NAMESPACE
      --wait
      $OSDU_GCP_HELM_CONFIG_SERVICE_VARS
  only:
    variables:
      - $OSDU_GCP == 'true'

osdu-gcp-deploy-deployment:
  extends: .osdu-gcp-variables
  image: gcr.io/google.com/cloudsdktool/cloud-sdk
  stage: deploy
  needs: ["osdu-gcp-containerize-gitlab"]
  script:
    - *common
    - >
      helm upgrade $OSDU_GCP_HELM_DEPLOYMENT_SERVICE $OSDU_GCP_HELM_DEPLOYMENT_DIR
      --install
      --create-namespace
      --namespace=$OSDU_GCP_HELM_NAMESPACE
      --wait
      $OSDU_GCP_HELM_DEPLOYMENT_SERVICE_VARS
    - echo ----- Verify Deployment -----
    - kubectl rollout status deployment.v1.apps/$OSDU_GCP_SERVICE -n $OSDU_GCP_HELM_NAMESPACE --timeout=900s
    - POD=$(kubectl get pod --sort-by=.metadata.creationTimestamp -n $OSDU_GCP_HELM_NAMESPACE | grep $OSDU_GCP_SERVICE | tail -1 | awk '{print $1}')
    - STATUS=$(kubectl wait -n $OSDU_GCP_HELM_NAMESPACE --for=condition=Ready pod/$POD --timeout=300s)
    - echo $STATUS
    - if [[ "$STATUS" != *"met"* ]]; then echo "POD didn't start correctly" ; exit 1 ; fi
  only:
    variables:
      - $OSDU_GCP == 'true'

osdu-gcp-test:
  image: maven:3.3.9-jdk-8
  extends:
    - .osdu-gcp-variables
    - .maven
  stage: integration
  needs: ["osdu-gcp-deploy-deployment"]
  variables:
    INTEGRATION_TESTER: $OSDU_GCP_INTEGRATION_TESTER
    NO_DATA_ACCESS_TESTER: $OSDU_GCP_NO_DATA_ACCESS_TESTER
    SEARCH_INTEGRATION_TESTER: $OSDU_GCP_INTEGRATION_TESTER
    DE_OPS_TESTER: $OSDU_GCP_R3_OPS_TESTER
    DE_ADMIN_TESTER: $OSDU_GCP_R3_ADMIN_TESTER
    DE_EDITOR_TESTER: $OSDU_GCP_R3_EDITOR_TESTER
    DE_NO_ACCESS_TESTER: $OSDU_GCP_R3_NO_ACCESS_TESTER
  script:
    - export GCP_DEPLOY_FILE=$(echo $OSDU_GCP_DEPLOY_FILE)
    - >
      mvn
      --batch-mode
      --settings=$CI_PROJECT_DIR/.mvn/community-maven.settings.xml
      -f $OSDU_GCP_TESTING_DIR/pom.xml
      verify
      --projects $OSDU_GCP_SERVICE-test-core,$OSDU_GCP_SERVICE-test-gcp
      2>&1 | tee test-results.log
  only:
    variables:
      - $OSDU_GCP == 'true' && $OSDU_GCP_INT_TEST_TYPE != 'python'
  artifacts:
    when: always
    paths:
      - test-results.log
      - $OSDU_GCP_TEST_SUBDIR/target/*/TEST-*.xml
    expire_in: 1 week
    reports:
      junit:
        - $OSDU_GCP_TEST_SUBDIR/target/*/TEST-*.xml