diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8fcb0eb541b88d2b7882f04616f6a6dfa401d101..e700a2f53992a8568157d05bb66c971da954ee06 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -44,3 +44,29 @@ deploy-int: strategy: depend rules: - if: '$CI_COMMIT_BRANCH == "develop"' + +deployment: + image: + name: alpine + stage: deploy + tags: + - caascad + variables: + KUSTOMIZE_VER: "4.5.7" + ENVIRONMENT: "int" + before_script: + - apk --no-cache add git + - wget -O - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${KUSTOMIZE_VER}/kustomize_v${KUSTOMIZE_VER}_linux_amd64.tar.gz | tar xz -C /usr/local/bin + script: + - git config --global user.name "$CI_COMMIT_SHORT_SHA" + - git config --global user.email "$CI_COMMIT_SHORT_SHA" + - git clone --branch master https://${GIT_ACCESS_USER}:${GIT_ACCESS_TOKEN}@${GIT_SERVER_HOST} /tmp/submission-app + - cd ./src/k8s + - kustomize edit set image submission-server=$K8S_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA + - kustomize build . > /tmp/submission-app/deployment-$ENVIRONMENT.yml + - cd /tmp/submission-app + - git add ./deployment-$ENVIRONMENT.yml + - git commit -m "$ENVIRONMENT $CI_COMMIT_SHORT_SHA" + - git push origin master + rules: + - if: $CI_COMMIT_BRANCH == 'develop' diff --git a/src/k8s/deployment.yml b/src/k8s/deployment.yml new file mode 100644 index 0000000000000000000000000000000000000000..9b090729597906ca8499abafa8fc4494d767f98a --- /dev/null +++ b/src/k8s/deployment.yml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: submission-code-server-deployment + labels: + app: submission-code-server + name: submission-code-server +spec: + revisionHistoryLimit: 1 + selector: + matchLabels: + app: submission-code-server + template: + metadata: + labels: + app: submission-code-server # Bind by service selector>app: + spec: + containers: + - name: submission-app + image: submission-server + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: SPRING_DATASOURCE_URL + valueFrom: + secretKeyRef: + name: submission-secrets + key: SPRING_DATASOURCE_URL + - name: SPRING_DATASOURCE_PASSWORD + valueFrom: + secretKeyRef: + name: submission-secrets + key: SPRING_DATASOURCE_PASSWORD + - name: SUBMISSION_JWTPUBLICKEYS_TOUSANTICOVIDKID + valueFrom: + secretKeyRef: + name: submission-secrets + key: SUBMISSION_JWTPUBLICKEYS_TOUSANTICOVIDKID + - name: SPRING_DATASOURCE_USERNAME + value: pocinit + - name: SPRING_FLYWAY_ENABLED + value: "true" + - name: SPRING_FLYWAY_BASELINE_ON_MIGRATE + value: "true" + - name: SPRING_FLYWAY_BASELINE_VERSION + value: "0" + nodeSelector: + cce.cloud.com/cce-nodepool: "caascad-inttac-ju-pod-tac-dashing-boa" diff --git a/src/k8s/kustomization.yml b/src/k8s/kustomization.yml new file mode 100644 index 0000000000000000000000000000000000000000..68074df3dd84991446edf8a85855fcc6e596cd0f --- /dev/null +++ b/src/k8s/kustomization.yml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - deployment.yml + - service.yml diff --git a/src/k8s/service.yml b/src/k8s/service.yml new file mode 100644 index 0000000000000000000000000000000000000000..8b9b13b25aa2120500380d91f4aaaedf909cd278 --- /dev/null +++ b/src/k8s/service.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: submission-code-server-service # Service name +spec: + type: NodePort # Sets the service type + selector: + app: submission-code-server # Defines app that will be targeted + ports: + - port: 80 + targetPort: 8080