Deploy Kubernetes Pod using CircleCI
- Creating a Docker image
- Pushing it to the Docker Hub (Registry).
- Running a Kubernetes deployment script which calls the Docker image.
- CircleCI 2.1
- Kuberentes cluster with 1.13+ version.
- Dockerfile for the webservice.
- DockerHub registry - To push and store the docker images.
- Workstation.
- Github account
-
Create Kuberentes single node cluster by removing taints. Initializa with Public IP of the node.
- kubeadm init --pod-network-cidr=192.168.0.0/16 --apiserver-cert-extra-sans=
- Ref doc: https://medium.com/htc-research-engineering-blog/install-a-kubernetes-cluster-with-kubeadm-on-ubuntu-step-by-stepff-c118514bc5e0
-
Remove taints to deploy the pods on master node itself. Use the below command.
- kubectl taint nodes --all node-role.kubernetes.io/master-
-
Apply Calico CNI for setting up K8S communication and policy.
-
Creat a service account, role, Token and role binding to access services, objects of a particular namespace in K8S environment.
-
Create application Dockerfile, deployment script and config.yaml for circleci. Pushed them in a Git Repository.
-
Link the CircleCI account with Github Repository.
-
Add the Github Repository as a Project in CircleCI, start following it. Add the required environment variables such as KUBERNETES_SERVER, KUBERNETES_TOKEN, DOCKER_USERNAME, KUBERNETES_CLUSTER_CERTIFICATE etc in the project.
-
Commit all the script files in Github Repository.
-
Commit should trigger the CircleCI Project job and it should be successful.
-
Webservice pod and its service should be up and running.
-
Identify the service NodePort.
-
curl Public IP:NodePort
-
Query response should contain Name and Joke by Chuck Norris.