forked from mschmidt712/kubernetes-ci-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
steps.yml
75 lines (51 loc) · 3.38 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
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 6000 --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 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; docker rm 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. For "repository url" enter https://github.com/kenzanlabs/kubernetes-ci-cd.git. Save and run the job.
com: minikube service jenkins
# - name: Part 3
# intro: part 3 intro here
# - name: Part 4
# intro: part 4 intro here
# - name: Part 5
# intro: part 5 intro here