forked from mschmidt712/kubernetes-ci-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
steps.yml
198 lines (134 loc) · 8.86 KB
/
steps.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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
parts:
- name: Part 1
intro: In this part we will setup a local cluster with minikube, deploy a public image from dockerhub, customize that image, and then finally deploy it inside our local cluster.
steps:
- cap: Start up the cluster with minikibe
com: minikube start --memory 8000 --cpus 2 --kubernetes-version v1.6.0
- cap: Enable addons
com: minikube addons enable heapster; minikube addons enable ingress
- cap: Wait 20 seconds and view minikube dashboard
com: sleep 20; minikube service kubernetes-dashboard --namespace kube-system
- cap: Deploy the public nginx image from DockerHub
com: kubectl run nginx --image nginx --port 80
- cap: Create a service for deployment
com: kubectl expose deployment nginx --type NodePort --port 80
- cap: Launch browser to test service
com: minikube service nginx
- cap: Install registry
com: kubectl apply -f manifests/registry.yml
- cap: Wait for registry to deploy
com: kubectl rollout status deployments/registry
- cap: View registry UI
com: minikube service registry-ui
- cap: Edit the contents of applications/hello-kenzan/index.html. This will open the file with the nano editor. When finished press ctrl + x to exit and confirm save.
com: nano applications/hello-kenzan/index.html
- cap: We will now build the image with a special name that is pointing at our cluster registry.
com: docker build -t 127.0.0.1:30400/hello-kenzan:latest -f applications/hello-kenzan/Dockerfile applications/hello-kenzan
- cap: Before we can push our image we need to set up a temporary proxy. This is a container that listens on 127.0.0.1:30400 and forwads to our cluster. By default the docker client can only push to non https via localhost.
com: docker stop socat-registry; docker rm socat-registry; docker run -d -e "REGIP=`minikube ip`" --name socat-registry -p 30400:5000 chadmoon/socat:latest bash -c "socat TCP4-LISTEN:5000,fork,reuseaddr TCP4:`minikube ip`:30400"
- cap: We can now push our image.
com: docker push 127.0.0.1:30400/hello-kenzan:latest
- cap: Stop the registry proxy.
com: docker stop socat-registry;
- cap: Now that our image is on the cluster we can deploy the manifests
com: kubectl apply -f applications/hello-kenzan/k8s/deployment.yaml
- cap: View the app
com: minikube service hello-kenzan
- name: Part 2
intro: In this part we will Setup Jenkins, and setup an automated jon to build, push and deploy our custom appliction.
steps:
- cap: Install Jenkins
com: kubectl apply -f manifests/jenkins.yml; kubectl rollout status deployment/jenkins
- cap: Get Jenkins admin password
com: kubectl exec -it `kubectl get pods --selector=app=jenkins --output=jsonpath={.items..metadata.name}` cat /root/.jenkins/secrets/initialAdminPassword
- cap: Enter the admin password from above and choose "suggested plugins". Create a new job with type pipeline. Scroll down and under "pipeline script" choose "Pipeline script from SCM". Under SCM choose GIT. Fork repo and put "repository url" as your fork, such as https://github.com/kenzanlabs/kubernetes-ci-cd.git. Save and run the job.
com: minikube service jenkins
- cap: View updated application
com: minikube service hello-kenzan
- cap: Push a change to your fork. Run job again. View changes
com: minikube service hello-kenzan
- name: Part 3
intro: This part will have us setup the various applications that will present the crossword puzzle. We will run a sample etcd cluster as a cache, a pages application containing the front-end, a crossword server using mongodb, and a monitoring and scaling server application.
steps:
- cap: Bootstrap etcd operator on the cluster
com: scripts/etcd.sh
- cap: Run job to create etcd directory
com: kubectl create -f manifests/etcd-job.yml
- cap: Check job status
com: kubectl describe jobs/etcd-job
- cap: Now we're going to walk through an initial build of the monitoring and scaling service for our crosswords application.
com: docker build -t 127.0.0.1:30400/monitor-scale:`git rev-parse --short HEAD` -f applications/monitor/Dockerfile applications/monitor
- cap: Setup the proxy in order to push the monitoring docker image to our cluster's registry
com: docker stop socat-registry; docker rm socat-registry; docker run -d -e "REGIP=`minikube ip`" --name socat-registry -p 30400:5000 chadmoon/socat:latest bash -c "socat TCP4-LISTEN:5000,fork,reuseaddr TCP4:`minikube ip`:30400"
- cap: Push the image
com: docker push 127.0.0.1:30400/monitor-scale:`git rev-parse --short HEAD`
- cap: Stop the registry proxy
com: docker stop socat-registry
- cap: Verify that the image is in our local registry using the registry-ui
com: minikube service registry-ui
- cap: Create the deployment and service for the monitoring and scaling server and wait for it to be deployed
com: sed 's#127.0.0.1:30400/services:latest#127.0.0.1:30400/services:'`git rev-parse --short HEAD`'#' applications/monitor/k8s/monitor-scale.yaml | kubectl apply -f -
- cap: Wait for the deployment to run
com: kubectl rollout status deployment/monitor-scale
- cap: See the montior-scale-* pod running using kubectl.
com: kubectl get pods
- cap: See the montior-scale-* service is setup using kubectl.
com: kubectl get services
- cap: See the montior-scale-* ingress is configured using kubectl.
com: kubectl get ingress
- cap: See the monitor-scale deployment is setup using kubectl
com: kubectl get deployments
- cap: Delete the monitor-scale pod and watch as k8s brings it back up. Note that everything wrapped in tick marks is used to parse the unique name of the pod from the get pods display.
com: kubectl delete pod `kubectl get pods --selector=app=monitor-scale --output=jsonpath={.items[1]..metadata.name}`
- cap: If you act quickly you might see one pod terminating while a new uniquely identified pod is created.
com: kubectl get pods
- cap: Run this command to make sure the re-deployment of the pod is complete
com: kubectl rollout status deployment/monitor-scale
- cap: Bootstrap the crossword/mongodb services, creating a docker image and storing it in the local registry
com: scripts/server.sh
- cap: Check to see if services has been deployed
com: kubectl rollout status deployment/services
- cap: Bootstrap the frontend web application
com: scripts/pages.sh
- cap: Check to see if the front end has been deployed
com: kubectl rollout status deployment/kr8sswordz
- cap: See all the pods running using kubectl.
com: kubectl get pods
- cap: Start the web application in your default browser
com: minikube service kr8sswordz
- name: Part 4
intro: Kubescale
steps:
- cap: Bootstrap etcd operator on the cluster
com: scripts/etcd.sh
- cap: Run job to create etcd directory
com: kubectl create -f manifests/etcd-job.yml
- cap: Check job status
com: kubectl describe jobs/etcd-job
- cap: build kubescale image
com: docker build -t 127.0.0.1:30400/kubescale:latest -f applications/kubescale/Dockerfile applications/kubescale
- cap: build scaling image
com: docker build -t 127.0.0.1:30400/set:latest -f applications/kubescale/set/Dockerfile applications/kubescale/set
- cap: Start the registry proxy.
com: docker stop socat-registry; docker rm socat-registry; docker run -d -e "REGIP=`minikube ip`" --name socat-registry -p 30400:5000 chadmoon/socat:latest bash -c "socat TCP4-LISTEN:5000,fork,reuseaddr TCP4:`minikube ip`:30400"
- cap: Push the kubescale image
com: docker push 127.0.0.1:30400/kubescale:latest
- cap: Push the scaling image
com: docker push 127.0.0.1:30400/set:latest
- cap: Stop the registry proxy
com: docker stop socat-registry
- cap: Deploy kubescale
com: kubectl apply -f applications/kubescale/k8s/kubescale.yml; kubectl rollout status deployment/kubescale
- cap: Deploy scaling set
com: kubectl apply -f applications/kubescale/k8s/set.yml; kubectl rollout status deployment/set
- cap: View kubescale application
com: minikube service kubescale
# - name: Part 5
# intro: Spinnaker
# steps:
# - cap: Initialize Helm
# com: helm init; sleep 10; kubectl --namespace kube-system rollout status deployment/tiller-deploy
# - cap: Install Chart
# com: helm install --name spinnaker applications/spinnaker-helm/spinnaker-chart
# - cap: Launch Deck
# com: minikube service deck