Skip to content

Commit 6dc8fda

Browse files
Fixing the commit issue and history of commit which is exposed
1 parent c01371e commit 6dc8fda

File tree

3 files changed

+194
-13
lines changed

3 files changed

+194
-13
lines changed

.gitlab-ci.yml

Lines changed: 126 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
include:
22
- project: 'pluralsight/experience/gitlab-helpers'
3-
file: '/salt-deploy/helper.yml'
3+
file: '/slack-notification/helper.yml'
4+
- project: 'pluralsight/experience/gitlab-helpers'
5+
file: '/helm-deploy/helper.yml'
46

57
image: openjdk:8
68

@@ -16,6 +18,18 @@ variables:
1618
ARTIFACTORY_PATH: ${ARTIFACTORY_ID}/${ARTIFACTORY_ARTIFACT_VERSION}
1719
ARTIFACTORY_ARTIFACT_URL: ${ARTIFACTORY_REPOSITORY_URL}/${ARTIFACTORY_REPOSITORY}/${ARTIFACTORY_PATH}
1820
BUILD_VERSION: 1.0.${CI_PIPELINE_IID}
21+
HELM_K8S_CLUSTER_URL: https://6C29C0073BB19BEF220B9437E6962AF2.gr7.us-west-2.eks.amazonaws.com
22+
K8S_CLUSTER_NAME: app-eks.eplur-staging.us-west-2
23+
ENV: ${CI_JOB_STAGE}
24+
SERVICE_NAME: "hydra-notifications"
25+
SLACK_ICON_EMOJI: ":gitlab:"
26+
SLACK_CHANNEL: '#data-platform-alerts'
27+
SNYK_ORG_ID: "d8094638-7a37-413f-b1b4-ad840fb9e239"
28+
SLACK_MESSAGE: |
29+
*[[SERVICE_NAME]]* deployed to *[[ENV]]*.
30+
Version: *[[BUILD_VERSION]]*
31+
[[PIPELINE_LINK]]
32+
SLACK_USERNAME: 'GITLAB'
1933

2034
before_script:
2135
- apt-get update -yqq
@@ -25,35 +39,64 @@ before_script:
2539
- gpg --recv-keys --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/scalasbt-release.gpg --keyserver hkp://keyserver.ubuntu.com:80 2EE0EA64E40A89B84B2DF73499E82A75642AC823
2640
- chmod 644 /etc/apt/trusted.gpg.d/scalasbt-release.gpg
2741
- apt-get update -yqq
28-
- apt-get install -yqq sbt
42+
- apt-get install -yqq sbt curl
43+
- curl --compressed https://static.snyk.io/cli/latest/snyk-linux -o snyk
44+
- chmod +x ./snyk
45+
- mv ./snyk /usr/local/bin/
46+
2947

3048
stages:
3149
- build
3250
- package
51+
- code-analysis
3352
- publish
53+
- deploy-dev
54+
- notify
55+
- notify_dev
56+
- deploy-staging
57+
- notify_staging
58+
3459

3560
build:
3661
stage: build
62+
retry: 2
3763
script:
3864
- sbt clean compile test
65+
3966
package:
4067
stage: package
68+
retry: 2
4169
script:
4270
- sbt universal:packageBin
4371
- CURYEAR=$(date +%Y)
4472
- CURMONTH=$(date +%-m)
4573
- echo -n "${CURYEAR}.${CURMONTH}.${BUILD_VERSION}" > VERSION
46-
- pwd
47-
- ls -lh
4874
- unzip server/target/universal/*.zip
4975
- mv hydra-notifications-server-* hydra-notifications-server
5076
- tar czf ${ARTIFACT_NAME}-${BUILD_VERSION}.tgz --exclude=*.tmp --exclude=*.tgz --exclude=*.tgz.md5 .
5177
- echo "##teamcity[publishArtifacts '${ARTIFACT_NAME}.tgz']"
52-
5378
artifacts:
5479
paths:
5580
- hydra-notifications-server
5681

82+
snyk-code-analysis:
83+
stage: code-analysis
84+
allow_failure: true
85+
script:
86+
- |
87+
snyk_ver=$(snyk --version)
88+
echo "--> Installed SNYK Version:${snyk_ver}"
89+
echo "----- Configuring SNYK Api Token and Org -----"
90+
snyk config set api=${SNYK_API_TOKEN}
91+
snyk config set org=${SNYK_ORG_ID}
92+
echo "--> Iniciating SNYK Code Analysis"
93+
snyk code test --report --project-id="cdafcbb5-24d1-4afc-bcda-96055113fc57" --commit-id="${CI_COMMIT_SHA}"
94+
artifacts:
95+
when: always
96+
paths:
97+
- ./snyk-code-analysis.json
98+
99+
57100
publish:
58101
stage: publish
59102
image: harbor.vnerd.com/proxy/library/docker:cli
@@ -62,18 +105,93 @@ publish:
62105
- docker
63106
needs:
64107
- package
108+
- snyk-code-analysis
65109
before_script:
66110
- echo "$DOCKER_REGISTRY_USERNAME:$DOCKER_REGISTRY_PASSWORD"
67111
- echo -n "$DOCKER_REGISTRY_PASSWORD" | docker login -u "$DOCKER_REGISTRY_USERNAME" --password-stdin "$DOCKER_REGISTRY_URL"
68112
script:
69-
- pwd
70-
- ls -lh
71113
- docker build -t ${IMAGE_NAME} -f Dockerfile .
72114
- docker tag ${IMAGE_NAME} ${DOCKER_REGISTRY_IMAGE}:${BUILD_VERSION}
73115
- docker push ${DOCKER_REGISTRY_IMAGE}:${BUILD_VERSION}
74-
75116
variables:
76117
DOCKER_HOST: tcp://localhost:2376
77118
DOCKER_TLS_CERTDIR: "/certs"
78119
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client"
79120
DOCKER_TLS_VERIFY: 1
121+
122+
.notify-all:
123+
image: harbor.vnerd.com/library/ps-helm:latest
124+
tags:
125+
- ps
126+
- docker
127+
script:
128+
- ps-notify slack "$SLACK_MESSAGE" "$SLACK_CHANNEL" --slack-username $SLACK_USERNAME --slack-icon-emoji $SLACK_ICON_EMOJI
129+
variables:
130+
NODE_ENV: $ENV
131+
132+
deploy-dev:
133+
stage: deploy-dev
134+
extends: .helmDeploy
135+
environment:
136+
name: dev
137+
variables:
138+
HELM_CHART_NAME: ps-service
139+
HELM_DEPLOY_TOKEN: ${HELM_DEPLOY_TOKEN}
140+
K8S_CLUSTER_NAME: app-eks.eplur-staging.us-west-2
141+
HELM_K8S_CLUSTER_URL: https://6C29C0073BB19BEF220B9437E6962AF2.gr7.us-west-2.eks.amazonaws.com
142+
BOUNDED_CONTEXT: adapt-dvs-dev
143+
HELM_TARGET_NAMESPACE: ${BOUNDED_CONTEXT}
144+
APPLICATION_ROLE: dev-hydra-notifications
145+
HELM_VALUES_FILE: helm/eks-dev-values.yml
146+
HELM_SET_VALUES: "NODE_ENV=production, INGEST_URL=https://dev-hydra.eplur-staging.vnerd.com, PUBLIC_URL=https://dvs-dev.eplur-staging.vnerd.com/dvs-data-explorer, REACT_APP_INGEST_URL=https://dev-hydra.eplur-staging.vnerd.com, REACT_APP_STREAMS_URL=https://hydra-streams-dev.eplur-staging.vnerd.com, STREAMS_URL=https://hydra-streams-dev.eplur-staging.vnerd.com"
147+
before_script:
148+
- export BUILD_VERSION="$(date +%Y).$(date +%m).$(date +%d).${CI_COMMIT_SHORT_SHA}"
149+
- kubectl config set-cluster app-${CI_ENVIRONMENT_NAME%/*} --server=${HELM_K8S_CLUSTER_URL} --embed-certs --certificate-authority="$HELM_K8S_CLUSTER_CACERT"
150+
- kubectl config set-credentials deploy --token=`echo ${HELM_DEPLOY_TOKEN} | base64 -d`
151+
- kubectl config set-context deploy --cluster=app-${CI_ENVIRONMENT_NAME%/*} --namespace=${HELM_TARGET_NAMESPACE} --user=deploy
152+
- kubectl config use-context deploy
153+
154+
slack:dev:
155+
stage: notify_dev
156+
extends: .notify-all
157+
when: on_success
158+
needs: ['deploy-dev']
159+
before_script:
160+
- echo "Sending notification to slack"
161+
variables:
162+
ENV: "DEV Cluster"
163+
SERVICE_NAME: "dev-hydra-notifications"
164+
165+
deploy-staging:
166+
stage: deploy-staging
167+
extends: .helmDeploy
168+
when: manual
169+
environment:
170+
name: staging
171+
variables:
172+
HELM_CHART_NAME: ps-service
173+
HELM_DEPLOY_TOKEN: ${HELM_DEPLOY_TOKEN}
174+
K8S_CLUSTER_NAME: app-eks.eplur-staging.us-west-2
175+
HELM_K8S_CLUSTER_URL: https://6C29C0073BB19BEF220B9437E6962AF2.gr7.us-west-2.eks.amazonaws.com
176+
BOUNDED_CONTEXT: adapt-dvs
177+
HELM_TARGET_NAMESPACE: ${BOUNDED_CONTEXT}
178+
APPLICATION_ROLE: is-hydra-notifications
179+
HELM_VALUES_FILE: helm/eks-staging-values.yml
180+
HELM_SET_VALUES: "NODE_ENV=production, INGEST_URL=https://hydra-publish.eplur-staging.vnerd.com, PUBLIC_URL=https://dvs.eplur-staging.vnerd.com/dvs-data-explorer, REACT_APP_INGEST_URL=https://hydra-publish.eplur-staging.vnerd.com, REACT_APP_STREAMS_URL=https://hydra-streams.eplur-staging.vnerd.com, STREAMS_URL=https://hydra-streams.eplur-staging.vnerd.com"
181+
before_script:
182+
- export BUILD_VERSION="$(date +%Y).$(date +%m).$(date +%d).${CI_COMMIT_SHORT_SHA}"
183+
- kubectl config set-cluster app-${CI_ENVIRONMENT_NAME%/*} --server=${HELM_K8S_CLUSTER_URL} --embed-certs --certificate-authority="$HELM_K8S_CLUSTER_CACERT"
184+
- kubectl config set-credentials deploy --token=`echo ${HELM_DEPLOY_TOKEN} | base64 -d`
185+
- kubectl config set-context deploy --cluster=app-${CI_ENVIRONMENT_NAME%/*} --namespace=${HELM_TARGET_NAMESPACE} --user=deploy
186+
- kubectl config use-context deploy
187+
188+
slack:staging:
189+
stage: notify_staging
190+
extends: .notify-all
191+
when: on_success
192+
needs: ['deploy-staging']
193+
before_script:
194+
- echo "Sending notification to slack"
195+
variables:
196+
ENV: "STAGING Cluster"
197+
SERVICE_NAME: "is-hydra-notifications"

helm/eks-dev-values.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
image:
2+
repository: harbor.vnerd.com/library/hydra-notifications
3+
pullPolicy: Always
4+
tag: latest
5+
6+
serviceAccount:
7+
create: true
8+
annotations:
9+
eks.amazonaws.com/role-arn: arn:aws:iam::523344010929:role/is-aws-msk-is-hydra-streams-us-west-2
10+
11+
deployment:
12+
apiVersion: "apps/v1"
13+
updateStrategy:
14+
rollingUpdate:
15+
maxUnavailable: 0
16+
type: RollingUpdate
17+
18+
replicas: 1
19+
20+
service:
21+
type: ClusterIP
22+
port: 8080
23+
annotations: {}
24+
labels: {}
25+
26+
ingress:
27+
enabled: true
28+
ingressClassName: internal
29+
annotations: {}
30+
labels: {}
31+
hosts:
32+
- hydra-notifications-dev.eplur-staging.vnerd.com
33+
- hydra-notifications-dev-stage.vnerd.com
34+
tls:
35+
- hosts:
36+
- hydra-notifications-dev-stage.vnerd.com
37+
path: /
38+
pathType: Prefix
39+
40+
hpa:
41+
enabled: true
42+
minReplicas: 1
43+
maxReplicas: 1
44+
targetMemoryUtilizationPercentage: 80
45+
46+
resources:
47+
limits:
48+
memory: 512Mi
49+
requests:
50+
cpu: 250m
51+
memory: 50Mi
52+
53+
tolerations: []
54+
55+
nodeSelector: {}
56+
57+
config:
58+
LOG_DIR: /var/log/hydra-notifications
59+
LOG_LEVEL: ERROR
60+
PORT_NUMBER: 8080
61+
SLACK_TOKEN:
62+
OPSGENIE_TOKEN:
63+
STREAMS_URL: https://hydra-streams-dev.eplur-staging.vnerd.com

helm/eks-staging-values.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ service:
2020

2121
ingress:
2222
enabled: true
23-
ingressClassName: alb
23+
ingressClassName: internal
2424
labels: {}
2525
hosts:
2626
- hydra-notifications.eplur-staging.vnerd.com
2727
- hydra-notifications-stage.vnerd.com
2828
path: /
29+
pathType: Prefix
2930

3031

3132
hpa:
@@ -50,7 +51,6 @@ config:
5051
LOG_DIR: /var/log/hydra-notifications
5152
LOG_LEVEL: ERROR
5253
PORT_NUMBER: 8080
53-
SLACK_TOKEN: xoxp-2345022201-286493579810-550147647603-73094781a9bc0e8dc2ecaad62c19ea0b
54-
OPSGENIE_TOKEN: e171c410-5cc6-4786-b962-90b923715996
55-
STREAMS_URL: https://hydra-streams.eplur-staging.vnerd.com
56-
54+
SLACK_TOKEN:
55+
OPSGENIE_TOKEN:
56+
STREAMS_URL: https://hydra-streams.eplur-staging.vnerd.com

0 commit comments

Comments
 (0)