This readme is dynamically generated when node readme.js
-
clone this repo
-
Ensure you are starting with a clean slate:
minikube delete; minikube rm -rf ~/.minikube; rm -rf ~/.kube
-
run
npm install
Begin the desired section npm run part1
npm run part2
npm run part3
Start up the cluster with minikibe
minikube start --memory 8000 --cpus 2 --kubernetes-version v1.6.0
Enable addons
minikube addons enable heapster; minikube addons enable ingress
Wait 20 seconds and view minikube dashboard
sleep 20; minikube service kubernetes-dashboard --namespace kube-system
Deploy the public nginx image from DockerHub
kubectl run nginx --image nginx --port 80
Create a service for deployment
kubectl expose deployment nginx --type NodePort --port 80
Launch browser to test service
minikube service nginx
Install registry
kubectl apply -f manifests/registry.yml
Wait for registry to deploy
kubectl rollout status deployments/registry
View registry UI
minikube service registry-ui
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.
nano applications/hello-kenzan/index.html
We will now build the image with a special name that is pointing at our cluster registry.
docker build -t 127.0.0.1:30400/hello-kenzan:latest -f applications/hello-kenzan/Dockerfile applications/hello-kenzan
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.
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"
We can now push our image.
docker push 127.0.0.1:30400/hello-kenzan:latest
Stop the registry proxy.
docker stop socat-registry;
Now that our image is on the cluster we can deploy the manifests
kubectl apply -f applications/hello-kenzan/k8s/deployment.yaml
View the app
minikube service hello-kenzan
## Part 2
Install Jenkins
kubectl apply -f manifests/jenkins.yml; kubectl rollout status deployment/jenkins
Open the Jenkins service running in our cluster. You will retrieve the admin password in the next step.
minikube service jenkins
Get Jenkins admin password. 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.
kubectl exec -it
kubectl get pods --selector=app=jenkins --output=jsonpath={.items..metadata.name} cat /root/.jenkins/secrets/initialAdminPassword
View updated application
minikube service hello-kenzan
Push a change to your fork. Run job again. View changes
minikube service hello-kenzan
## Part 3
Bootstrap etcd operator on the cluster
scripts/etcd.sh
Run job to create etcd directory
kubectl create -f manifests/etcd-job.yml
Check job status
kubectl describe jobs/etcd-job
The crossword application is a multi-tier application and its services depend on each other. For our first step we will create the 3 services ahead of time so that the deployments are already aware of them later.
kubectl apply -f manifests/all-services.yml
Now we're going to walk through an initial build of the monitoring and scaling service for our crosswords application.
docker build -t 127.0.0.1:30400/monitor-scale:
git rev-parse --short HEAD -f applications/monitor/Dockerfile applications/monitor
Setup the proxy in order to push the monitoring docker image to our cluster's registry
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"
Push the image
docker push 127.0.0.1:30400/monitor-scale:
git rev-parse --short HEAD``
Stop the registry proxy
docker stop socat-registry
Verify that the image is in our local registry using the registry-ui
minikube service registry-ui
Create the deployment and service for the monitoring and scaling server and wait for it to be deployed
sed 's#127.0.0.1:30400/monitor-scale:latest#127.0.0.1:30400/monitor-scale:'
git rev-parse --short HEAD'#' applications/monitor/k8s/monitor-scale.yaml | kubectl apply -f -
Wait for the deployment to run
kubectl rollout status deployment/monitor-scale
See the montior-scale-* pod running using kubectl.
kubectl get pods
See the montior-scale-* service is setup using kubectl.
kubectl get services
See the montior-scale-* ingress is configured using kubectl.
kubectl get ingress
See the monitor-scale deployment is setup using kubectl
kubectl get deployments
Now we will bootstrap the crossword/mongodb services, creating a docker image and storing it in the local registry. This script runs the same steps as before for a different service application.
scripts/server.sh
Check to see if services has been deployed
kubectl rollout status deployment/services
Bootstrap the frontend web application. This script follows the same steps as before but
scripts/pages.sh
Check to see if the front end has been deployed
kubectl rollout status deployment/kr8sswordz
See all the pods running using kubectl.
kubectl get pods
Start the web application in your default browser
minikube service kr8sswordz