kubernetes-ci-cd/part1.yml

54 строки
3.5 KiB
YAML
Исходник Ответственный История

Этот файл содержит неоднозначные символы Юникода!

Этот файл содержит неоднозначные символы Юникода, которые могут быть перепутаны с другими в текущей локали. Если это намеренно, можете спокойно проигнорировать это предупреждение. Используйте кнопку Экранировать, чтобы подсветить эти символы.

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.6.0
- cap: Enable the Minikube add-ons Heapster and Ingress.
com: minikube addons enable heapster; minikube addons enable ingress
- cap: Wait 20 seconds, and then view the Minikube Dashboard, a web UI for managing deployments.
com: sleep 20; 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 its not available locally.
com: kubectl run nginx --image nginx --port 80
- cap: Create a service for 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: Set up the cluster registry by applying a .yml manifest file.
com: kubectl apply -f manifests/registry.yml
- 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: Lets 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 lets 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: Weve 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, well set up a container that listens on 127.0.0.1:30400 and forwards to our cluster.
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: With our proxy container up and running, we can now push our image to the local repository.
com: docker push 127.0.0.1:30400/hello-kenzan:latest
- cap: The proxys 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/deployment.yaml
- cap: Launch a web browser and view the service.
com: minikube service hello-kenzan