Well, once you add the nodes to kubernetes and configure kubectl here are five things you could do,
1. Validate the setup
kubectl get nodes kubectl get cs kubectl get pods -n kube-system
2. Setup kubernetes dashboard
The following command will setup dashboard and make it available on port 31000 on all your kubernetes nodes ( hosts on to which you have setup kubernetes) .
kubectl apply -f https://gist.githubusercontent.com/initcron/32ff89394c881414ea7ef7f4d3a1d499/raw/4863613585d05f9360321c7141cc32b8aa305605/kube-dashboard.yaml
Warning: Make sure you understand the repercussions of running kubernetes dashboard and exposing it on a port. Do this only if your kubernetes cluster is private. I have created the above setup with NodePort configurations, just to make it easy to access it for beginners. If you expose it in a public cloud environment, without authentication, you are giving everyone admin access to manage your cluster. Be aware of this.
Following is how the dashboard looks like,
3. Setup a visualizer
I personally love this tool. If you are getting started with kubernetes, and want to understand how your cluster look like, which nodes are running what, how to the pod gets deployed, this is a fantastic tool. Continue using and observe as you deploy new services, scale up etc. and this tool will show you the changes being made live.
git clone https://github.com/schoolofdevops/kube-ops-view kubectl apply -f kube-ops-view/deploy/
This is how it may look with 2 nodes,
4. Deploy your first docker image
Lets assume you have built an image and published it to a registry e.g. dockerhub. I am going to assume this image https://hub.docker.com/r/schoolofdevops/vote/tags/ (https://hub.docker.com/r/schoolofdevops/vote/tags/)
If I now want to deployment this image, I would run the following command,
kubectl run vote --image=schoolofdevops/vote
kubectl get pods
The above command creates a
- deployment object
- deployment creates the replicaset
- replicaset launches a pod
- pod is what runs your container in kubernetes
5. Publish the application and access it
Creating a deployment is just half the job. You also need to be able to access it. This is where you publish it.
kubectl expose deployment vote --type=NodePort --port 80 kubectl get svc
Note the **nodeport **in the output. Do not use the IP that you see in the output. Use the actual node’s ( host on which you have setup kubernetes). Go to the browser and access it using http://NODE_IP:PORT (http://NODE_IP:PORT)
You may see output such as
There you go ! Thats your quick start to kubernetes !
Now, if you are interested in learning kubernetes further, here are a couple of resources that we created for you,
- Ultimate Kubernetes Bootcamp (https://schoolofdevops.github.io/ultimate-kubernetes-bootcamp/) tutorials
- Just Enough Kubernetes (https://www.schoolofdevops.net/p/just-enough-kubernetes), a free course
All the best !
Subscribe to The Devops Blog
Get the latest posts delivered right to your inbox