forked from mschmidt712/kubernetes-ci-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
part3.yml
68 lines (46 loc) · 3.88 KB
/
part3.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
parts:
- 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: Start the etcd operator and service on the cluster. You may notice errors showing up as it is waiting to start up the cluster. This is normal until it starts.
com: scripts/etcd.sh
- cap: Now that we have an etcd service, we need an etcd client. The following command will set up a directory within etcd for storing key-value pairs, and then run the etcd client.
com: kubectl create -f manifests/etcd-job.yml
- cap: Check the status of the job in step 2 to make sure it deployed.
com: kubectl describe jobs/etcd-job
- cap: The crossword application is a multi-tier application whose services depend on each other. We will create three services in Kubernetes ahead of time, so that the deployments are aware of them.
com: kubectl apply -f manifests/all-services.yml
- cap: Now we're going to walk through an initial build of the monitor-scale service.
com: docker build -t 127.0.0.1:30400/monitor-scale:`git rev-parse --short HEAD` -f applications/monitor-scale/Dockerfile applications/monitor-scale
- cap: Set up a proxy so we can push the monitor-scale Docker image we just built 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 monitor-scale image to the registry.
com: docker push 127.0.0.1:30400/monitor-scale:`git rev-parse --short HEAD`
- cap: The proxy’s work is done, so go ahead and stop it.
com: docker stop socat-registry
- cap: Open the registry UI and verify that the monitor-scale image is in our local registry.
com: minikube service registry-ui
- cap: Create the monitor-scale deployment and service.
com: sed 's#127.0.0.1:30400/monitor-scale:latest#127.0.0.1:30400/monitor-scale:'`git rev-parse --short HEAD`'#' applications/monitor-scale/k8s/deployment.yaml | kubectl apply -f -
- cap: Wait for the monitor-scale deployment to finish.
com: kubectl rollout status deployment/monitor-scale
- cap: View pods to see the monitor-scale pod running.
com: kubectl get pods
- cap: View services to see the monitor-scale service.
com: kubectl get services
- cap: View ingress rules to see the monitor-scale ingress rule.
com: kubectl get ingress
- cap: View deployments to see the monitor-scale deployment.
com: kubectl get deployments
- cap: We will run a script to bootstrap the puzzle and mongo services, creating Docker images and storing them in the local registry. The puzzle.sh script runs through the same build, proxy, push, and deploy steps we just ran through manually for both services.
com: scripts/puzzle.sh
- cap: Check to see if the puzzle and mongo services have been deployed.
com: kubectl rollout status deployment/puzzle
- cap: Bootstrap the kr8sswordz frontend web application. This script follows the same build proxy, push, and deploy steps that the other services followed.
com: scripts/kr8sswordz-pages.sh
- cap: Check to see if the frontend has been deployed.
com: kubectl rollout status deployment/kr8sswordz
- cap: Check out all the pods that are running.
com: kubectl get pods
- cap: Start the web application in your default browser. You may have to refresh your browser so that the puzzle appears properly.
com: minikube service kr8sswordz