-
Notifications
You must be signed in to change notification settings - Fork 5
/
shippable.jobs.yml
99 lines (93 loc) · 3.59 KB
/
shippable.jobs.yml
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
jobs:
# jobs for the sample node app pipeline from CI thru TEST environment
################################
# runCI job that builds and pushes artifact to S3
- name: deploy-kubernetes-runsh-kubectl_runCI
type: runCI
steps:
- OUT: deploy_kube_runsh_img
flags:
- deploy_kube_runsh_kubectl
# TEST deployment to Kube cluster on AWS
- name: deploy_kube_runsh_test
type: runSh
steps:
- IN: deploy_kube_runsh_repo
switch: off
- IN: deploy_kube_runsh_cli_kubectl
- IN: deploy_kube_runsh_img
- IN: deploy_kube_runsh_params_test
- TASK:
# set environment variables
- script: IMAGE_TAG=$(shipctl get_resource_version_name deploy_kube_runsh_img)
- script: IMAGE_URL=$(shipctl get_resource_version_key deploy_kube_runsh_img sourceName)
# - script: |
# set -a
# source $DEPLOY_KUBE_RUNSH_PARAMS_TEST_STATE
# IMAGE_URL=$DEPLOY_KUBE_RUNSH_IMG_SOURCENAME
# IMAGE_TAG=$DEPLOY_KUBE_RUNSH_IMG_VERSIONNAME
# set +a
- script: echo "deploying to Kubernetes cluster..."
# update kube yaml file(s)
- script: |
pushd $DEPLOY_KUBE_RUNSH_REPO_STATE
shippable_replace kube-deploy.yaml
cat kube-deploy.yaml
# deploy to cluster and verify success
- script: |
kubectl version
kubectl apply -f kube-deploy.yaml
kubectl rollout status deployments sample-node-ayeaye --namespace test
popd
# save image state
- script: |
shipctl put_resource_state deploy_kube_runsh_test_state IMAGE_TAG $IMAGE_TAG
shipctl put_resource_state deploy_kube_runsh_test_state IMAGE_URL $IMAGE_URL
shipctl put_resource_state deploy_kube_runsh_prod_state KUBE_NAMESPACE test
# - script: >
# echo -e "IMAGE_TAG=$IMAGE_TAG\n"
# "IMAGE_URL=$IMAGE_URL"
# > $DEPLOY_KUBE_RUNSH_TEST_STATE/latest_test_deploy.env
- OUT: deploy_kube_runsh_test_state
overwrite: true
flags:
- deploy_kube_runsh_kubectl
# PROD deployment to Kube cluster on AWS
- name: deploy_kube_runsh_prod
type: runSh
steps:
- IN: deploy_kube_runsh_test
switch: off
- IN: deploy_kube_runsh_test_state
switch: off
- IN: deploy_kube_runsh_repo
switch: off
- IN: deploy_kube_runsh_cli_kubectl
- IN: deploy_kube_runsh_params_prod
- TASK:
# set environment variables
# - script: |
# set -a
# source $DEPLOY_KUBE_RUNSH_TEST_STATE/latest_test_deploy.env
# source $DEPLOY_KUBE_RUNSH_PARAMS_PROD_STATE
# set +a
- script: echo "deploying to Kubernetes cluster..."
# update kube yaml file(s) with current values
- script: |
pushd $DEPLOY_KUBE_RUNSH_REPO_STATE
shippable_replace kube-deploy.yaml
cat kube-deploy.yaml
# deploy to cluster and verify success
- script: |
kubectl version
kubectl apply -f kube-deploy.yaml
kubectl rollout status deployments sample-node-ayeaye --namespace prod
popd
# save image state
- script: |
shipctl put_resource_state deploy_kube_runsh_prod_state IMAGE_TAG $IMAGE_TAG
shipctl put_resource_state deploy_kube_runsh_prod_state KUBE_NAMESPACE prod
# - script: echo -e "IMAGE_TAG=$IMAGE_TAG" > $DEPLOY_KUBE_RUNSH_PROD_STATE/latest_prod_deploy.env
- OUT: deploy_kube_runsh_prod_state
flags:
- deploy_kube_runsh_kubectl