Skip to content

Commit d33e93b

Browse files
authored
Merge pull request #1032 from snyk/test/sysdig-deploy
Test/sysdig deploy
2 parents c34f987 + d5bd90b commit d33e93b

File tree

6 files changed

+151
-55
lines changed

6 files changed

+151
-55
lines changed

.circleci/config.yml

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ jobs:
154154
name: Notify Slack on failure
155155
when: on_fail
156156
working_directory: ~/kubernetes-monitor
157-
deploy_dev:
157+
deploy_to_dev:
158158
docker:
159159
- auth:
160160
password: $DOCKERHUB_PASSWORD
@@ -178,7 +178,7 @@ jobs:
178178
name: Notify Slack on failure
179179
when: on_fail
180180
working_directory: ~/kubernetes-monitor
181-
deploy_prod:
181+
deploy_to_prod:
182182
docker:
183183
- auth:
184184
password: $DOCKERHUB_PASSWORD
@@ -201,6 +201,47 @@ jobs:
201201
name: Notify Slack on failure
202202
when: on_fail
203203
working_directory: ~/kubernetes-monitor
204+
deploy_to_sysdig_integration_cluster:
205+
docker:
206+
- auth:
207+
password: $DOCKERHUB_PASSWORD
208+
username: $DOCKERHUB_USER
209+
image: cimg/base:stable
210+
steps:
211+
- checkout
212+
- run:
213+
command: |
214+
LATEST_KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
215+
curl -LO "https://dl.k8s.io/release/${LATEST_KUBECTL_VERSION}/bin/linux/amd64/kubectl"
216+
curl -LO "https://dl.k8s.io/${LATEST_KUBECTL_VERSION}/bin/linux/amd64/kubectl.sha256"
217+
echo "$(<kubectl.sha256) kubectl" | sha256sum --check
218+
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
219+
# Ensure the kubectl command is runnable
220+
kubectl version --client
221+
# Prepare kubeconfig to point to the cluster
222+
mkdir ~/.kube || true
223+
printf "%s" "${SYSDIG_KUBECONFIG}" | base64 -d > ~/.kube/config
224+
name: Install and prepare kubectl
225+
- run:
226+
command: |
227+
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
228+
chmod 700 get_helm.sh
229+
./get_helm.sh
230+
# Ensure the Helm command is runnable
231+
helm version
232+
name: Install Helm
233+
- run:
234+
command: |
235+
LATEST_TAG_WITH_V=`git describe --abbrev=0 --tags ${CIRCLE_SHA1}`
236+
LATEST_TAG=${LATEST_TAG_WITH_V:1}-approved
237+
./scripts/slack/notify_deploy.py $LATEST_TAG sysdig-integration-cluster
238+
helm upgrade --install snyk-monitor ./snyk-monitor --namespace snyk-monitor --set image.tag=${LATEST_TAG} --set clusterName="Sysdig cluster" --set sysdig.enabled=true
239+
name: Deploy to shared Sysdig cluster
240+
- run:
241+
command: ./scripts/slack/notify_failure.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
242+
name: Notify Slack on failure
243+
when: on_fail
244+
working_directory: ~/kubernetes-monitor
204245
eks_integration_tests:
205246
machine:
206247
docker_layer_caching: true
@@ -1026,7 +1067,7 @@ workflows:
10261067
branches:
10271068
only:
10281069
- master
1029-
- deploy_prod:
1070+
- deploy_to_prod:
10301071
filters:
10311072
branches:
10321073
only:
@@ -1126,7 +1167,14 @@ workflows:
11261167
- integration_tests
11271168
- integration_tests_helm
11281169
- integration_tests_proxy
1129-
- deploy_dev:
1170+
- deploy_to_dev:
1171+
filters:
1172+
branches:
1173+
only:
1174+
- staging
1175+
requires:
1176+
- tag_and_push
1177+
- deploy_to_sysdig_integration_cluster:
11301178
filters:
11311179
branches:
11321180
only:

.circleci/config/@config.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ workflows:
9797
- integration_tests_helm
9898
- integration_tests_proxy
9999
<<: *staging_branch_only_filter
100-
- deploy_dev:
100+
- deploy_to_dev:
101+
requires:
102+
- tag_and_push
103+
<<: *staging_branch_only_filter
104+
- deploy_to_sysdig_integration_cluster:
101105
requires:
102106
- tag_and_push
103107
<<: *staging_branch_only_filter
@@ -106,7 +110,7 @@ workflows:
106110
jobs:
107111
- publish:
108112
<<: *master_branch_only_filter
109-
- deploy_prod:
113+
- deploy_to_prod:
110114
requires:
111115
- publish
112116
<<: *master_branch_only_filter

.circleci/config/jobs/@jobs.yml

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -380,31 +380,6 @@ tag_and_push:
380380
command: ./scripts/slack/notify_failure.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
381381
when: on_fail
382382

383-
deploy_dev:
384-
docker:
385-
- image: cimg/node:16.13
386-
auth:
387-
username: $DOCKERHUB_USER
388-
password: $DOCKERHUB_PASSWORD
389-
working_directory: ~/kubernetes-monitor
390-
steps:
391-
- checkout
392-
- install_python_requests
393-
- run:
394-
name: Deploy to dev
395-
command: |
396-
LATEST_TAG_WITH_V=`git describe --abbrev=0 --tags ${CIRCLE_SHA1}` &&
397-
LATEST_TAG=${LATEST_TAG_WITH_V:1}-approved &&
398-
./scripts/slack/notify_deploy.py $LATEST_TAG dev &&
399-
curl -s --fail --show-error -i -H "Accept: application/json" -H "Content-Type: application/json" \
400-
-X POST -d "{\"docker_sha\":\"${LATEST_TAG}\", \
401-
\"commit_hash\":\"${CIRCLE_SHA1}\"}" \
402-
https://my.dev.snyk.io/${DEV_DEPLOY_TOKEN}
403-
- run:
404-
name: Notify Slack on failure
405-
command: ./scripts/slack/notify_failure.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
406-
when: on_fail
407-
408383
######################## MERGE TO MASTER ########################
409384
publish:
410385
docker:
@@ -469,27 +444,3 @@ publish:
469444
name: Notify Slack on failure
470445
command: ./scripts/slack/notify_failure.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
471446
when: on_fail
472-
473-
deploy_prod:
474-
docker:
475-
- image: cimg/node:16.13
476-
auth:
477-
username: $DOCKERHUB_USER
478-
password: $DOCKERHUB_PASSWORD
479-
working_directory: ~/kubernetes-monitor
480-
steps:
481-
- checkout
482-
- install_python_requests
483-
- run:
484-
name: Deploy to prod
485-
command: |
486-
LATEST_TAG_WITH_V=`git describe --abbrev=0 --tags ${CIRCLE_SHA1}` &&
487-
LATEST_TAG=${LATEST_TAG_WITH_V:1} &&
488-
./scripts/slack/notify_deploy.py $LATEST_TAG prod &&
489-
curl -s --fail --show-error -i -H "Accept: application/json" -H "Content-Type: application/json" \
490-
-X POST -d "{}" \
491-
https://my.prod.snyk.io/${PROD_DEPLOY_TOKEN}
492-
- run:
493-
name: Notify Slack on failure
494-
command: ./scripts/slack/notify_failure.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
495-
when: on_fail
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
docker:
2+
- image: cimg/node:16.13
3+
auth:
4+
username: $DOCKERHUB_USER
5+
password: $DOCKERHUB_PASSWORD
6+
working_directory: ~/kubernetes-monitor
7+
steps:
8+
- checkout
9+
- install_python_requests
10+
11+
- run:
12+
name: Deploy to dev
13+
command: |
14+
LATEST_TAG_WITH_V=`git describe --abbrev=0 --tags ${CIRCLE_SHA1}` &&
15+
LATEST_TAG=${LATEST_TAG_WITH_V:1}-approved &&
16+
./scripts/slack/notify_deploy.py $LATEST_TAG dev &&
17+
curl -s --fail --show-error -i -H "Accept: application/json" -H "Content-Type: application/json" \
18+
-X POST -d "{\"docker_sha\":\"${LATEST_TAG}\", \
19+
\"commit_hash\":\"${CIRCLE_SHA1}\"}" \
20+
https://my.dev.snyk.io/${DEV_DEPLOY_TOKEN}
21+
22+
- run:
23+
name: Notify Slack on failure
24+
command: ./scripts/slack/notify_failure.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
25+
when: on_fail
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
docker:
2+
- image: cimg/node:16.13
3+
auth:
4+
username: $DOCKERHUB_USER
5+
password: $DOCKERHUB_PASSWORD
6+
working_directory: ~/kubernetes-monitor
7+
steps:
8+
- checkout
9+
- install_python_requests
10+
11+
- run:
12+
name: Deploy to prod
13+
command: |
14+
LATEST_TAG_WITH_V=`git describe --abbrev=0 --tags ${CIRCLE_SHA1}` &&
15+
LATEST_TAG=${LATEST_TAG_WITH_V:1} &&
16+
./scripts/slack/notify_deploy.py $LATEST_TAG prod &&
17+
curl -s --fail --show-error -i -H "Accept: application/json" -H "Content-Type: application/json" \
18+
-X POST -d "{}" \
19+
https://my.prod.snyk.io/${PROD_DEPLOY_TOKEN}
20+
21+
- run:
22+
name: Notify Slack on failure
23+
command: ./scripts/slack/notify_failure.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
24+
when: on_fail
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
docker:
2+
- image: cimg/base:stable
3+
auth:
4+
username: $DOCKERHUB_USER
5+
password: $DOCKERHUB_PASSWORD
6+
working_directory: ~/kubernetes-monitor
7+
steps:
8+
- checkout
9+
10+
- run:
11+
name: Install and prepare kubectl
12+
command: |
13+
LATEST_KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
14+
curl -LO "https://dl.k8s.io/release/${LATEST_KUBECTL_VERSION}/bin/linux/amd64/kubectl"
15+
curl -LO "https://dl.k8s.io/${LATEST_KUBECTL_VERSION}/bin/linux/amd64/kubectl.sha256"
16+
echo "$(<kubectl.sha256) kubectl" | sha256sum --check
17+
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
18+
# Ensure the kubectl command is runnable
19+
kubectl version --client
20+
# Prepare kubeconfig to point to the cluster
21+
mkdir ~/.kube || true
22+
printf "%s" "${SYSDIG_KUBECONFIG}" | base64 -d > ~/.kube/config
23+
24+
- run:
25+
name: Install Helm
26+
command: |
27+
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
28+
chmod 700 get_helm.sh
29+
./get_helm.sh
30+
# Ensure the Helm command is runnable
31+
helm version
32+
33+
- run:
34+
name: Deploy to shared Sysdig cluster
35+
command: |
36+
LATEST_TAG_WITH_V=`git describe --abbrev=0 --tags ${CIRCLE_SHA1}`
37+
LATEST_TAG=${LATEST_TAG_WITH_V:1}-approved
38+
./scripts/slack/notify_deploy.py $LATEST_TAG sysdig-integration-cluster
39+
helm upgrade --install snyk-monitor ./snyk-monitor --namespace snyk-monitor --set image.tag=${LATEST_TAG} --set clusterName="Sysdig cluster" --set sysdig.enabled=true
40+
41+
- run:
42+
name: Notify Slack on failure
43+
when: on_fail
44+
command: ./scripts/slack/notify_failure.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"

0 commit comments

Comments
 (0)