Introduction
Nowadays, Continues Integration and Continues Delivery (CI/CD) is becoming more popular. DevOps is a set of practices that works to automate and integrate the processes between software development and IT teams, so they can build, test, and release software faster and more reliably. The term DevOps was formed by combining the words “development” and “operations”.
Kubernetes (Aks or k8s)
Kubernetes is a system for automating deployment, scaling, and management of containerized applications.
In this article, we will see how to set up Kubernetes in local machine with the help of Docker for our Desktop application.
Step 1
Install Docker for Windows in your local machine from this
docker-for-windows. If already installed, get the latest version of Docker.
Step 2
Once Docker is installed, you can verify by running sample commands like "docker info" in command prompt. In the system bottom tray of right corner, you can see a notification such as "Docker is running".
Step 3
Next, Configuring kubernetes (k8s) with this Docker application. There are two options to configure k8s,
- One is while installing docker itself there will be options prompt to apply k8s.
- Another option is configuring after docker installation.
To do that, Open the docker info tray like Step 2 and click Settings. You can find Kubernetes options available in the Docker application. Select those three options and hit apply.
Step 4
Wait for some time, It will take a few minutes to configure k8s in the local machine. Once installed you can input a command like "kubectl version and kubectl cluster-info" in command prompt to verify kubectl. Kubectl (Kubernetes control) - is a syntax for k8s. Once the configuration is done, we have to setup k8s Dashboard for UI view and user flexibility.
Step 5
To do that, Open command prompt and hit below command to make configuration for Kubernetes dashboard UI.
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-rc7/aio/deploy/recommended.yaml
Step 6
Once we've successfully applied the settings, we have to set up the proxy to available the k8s service. To do this, execute "kubectl proxy". If the proxy is successfully enabled, then you can visit http://localhost:8001/#!/overview?namespace=default.
While starting the proxy, if you are facing an issue like 'error: listen tcp 127.0.0.1:8001', we have another way to starting up. Execute kubectl proxy --port=8090 command to point another port address.
Step 7
Now you can navigate to http://localhost:8090/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/ . You can see the k8s dashboard is successfully running in the local machine. To enter into the k8s dashboard we have to generate Token or using Config file.
Step 8
SInce our login is token-based, we have to create a service account to access the current cluster. Please follow below commands one by one to get token. Once generated the token, copy-paste it into the k8s login screen input and hit sign in.
- # Create the service account in the current namespace
- # (we assume default)
- kubectl create serviceaccount my-dashboard-sa
- # Give that service account root on the cluster
- kubectl create clusterrolebinding my-dashboard-sa \
- --clusterrole=cluster-admin \
- --serviceaccount=default:my-dashboard-sa
- # Find the secret that was created to hold the token for the SA
- kubectl get secrets
- # Show the contents of the secret to extract the token
- kubectl describe secret my-dashboard-sa-token-xxxxx
Reference - https://blog.heptio.com/on-securing-the-kubernetes-dashboard-16b09b1b7aca
Now you can see the k8s dashboard like below.
Step 9
You can verify virtual machines that are running in your machine by pressing the Windows key and typing Hyper-V Manager.
That's it. You have made a configuration for k8s in our local machine. In the next article, we will see how to setup Jenkins in our local machine and implement CI/CD.
I hope this was helpful for you. Enjoy ;)