forked from mschmidt712/kubernetes-ci-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
part1.yml
62 lines (42 loc) · 4.05 KB
/
part1.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
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 Kubernetes cluster with Minikube, giving it some extra resources.
com: minikube start --memory 8000 --cpus 2 --kubernetes-version v1.11.0
- cap: Enable the Minikube add-ons Heapster and Ingress.
com: minikube addons enable heapster; minikube addons enable ingress
- cap: View the Minikube Dashboard, a web UI for managing deployments.
com: minikube service kubernetes-dashboard --namespace kube-system
- cap: Deploy the public nginx image from DockerHub into a pod. Nginx is an open source web server that will automatically download from Docker Hub if it’s not available locally.
com: kubectl run nginx --image nginx --port 80
- cap: Create a K8s Service for the deployment. This will expose the nginx pod so you can access it with a web browser.
com: kubectl expose deployment nginx --type NodePort --port 80
- cap: Launch a web browser to test the service. The nginx welcome page displays, which means the service is up and running.
com: minikube service nginx
- cap: Delete the nginx deployment and service you created.
com: kubectl delete service nginx; kubectl delete deployment nginx
- cap: Set up the cluster registry by applying a .yaml manifest file.
com: kubectl apply -f manifests/registry.yaml
- cap: Wait for the registry to finish deploying. Note that this may take several minutes.
com: kubectl rollout status deployments/registry
- cap: View the registry user interface in a web browser.
com: minikube service registry-ui
- cap: Let’s make a change to an HTML file in the cloned project. Open the /applications/hello-kenzan/index.html file in your favorite text editor (for example, you can use nano by running the command 'nano applications/hello-kenzan/index.html' in a separate terminal). Change some text inside one of the <p> tags. For example, change “Hello from Kenzan!” to “Hello from Me!”. Save the file.
com: echo ''
- cap: Now let’s build an image, giving it a special name that points to our local cluster registry.
com: docker build -t 127.0.0.1:30400/hello-kenzan:latest -f applications/hello-kenzan/Dockerfile applications/hello-kenzan
- cap: We’ve built the image, but before we can push it to the registry, we need to set up a temporary proxy. By default the Docker client can only push to HTTP (not HTTPS) via localhost. To work around this, we’ll set up a Docker container that listens on 127.0.0.1:30400 and forwards to our cluster. First, build the image for our proxy container.
com: docker build -t socat-registry -f applications/socat/Dockerfile applications/socat
- cap: Now run the proxy container from the newly created image. (Note that you may see some errors; this is normal as the commands are first making sure there are no previous instances running.)
com: docker stop socat-registry; docker rm socat-registry; docker run -d -e "REG_IP=`minikube ip`" -e "REG_PORT=30400" --name socat-registry -p 30400:5000 socat-registry
- cap: With our proxy container up and running, we can now push our hello-kenzan image to the local repository.
com: docker push 127.0.0.1:30400/hello-kenzan:latest
- cap: The proxy’s work is done, so you can go ahead and stop it.
com: docker stop socat-registry;
- cap: With the image in our cluster registry, the last thing to do is apply the manifest to create and deploy the hello-kenzan pod based on the image.
com: kubectl apply -f applications/hello-kenzan/k8s/manual-deployment.yaml
- cap: Launch a web browser and view the service.
com: minikube service hello-kenzan
- cap: Delete the hello-kenzan deployment and service you created.
com: kubectl delete service hello-kenzan; kubectl delete deployment hello-kenzan