Managing Kubernetes
Hey everybody! In this post, I’d like to talk about Container-centric infrastructure with Kubernetes. This is Part 5 of a series of posts on using installing and using Kubernetes.
If you missed Part 4 where I give you Install Kubernetes on your Computer (Minikube), make sure to check that out.
In this post I’ll show you two ways to manage your Kubernetes applications:
kubectl
- Kubernetes Web UI Dashboard
The kubectl
command
When Kubernetes starts a pod it’s isolated in its own network. So how do we interact with the application?
One way is through a proxy, which you can start in a separate terminal window. Start a new Terminal window and execute the kubectl proxy
command.
kubectl proxy
By default the proxy uses port 8001, but you can specify a different port using the --port
option.
kubectl proxy --port=8080
This starts the proxy using port 8080. Now you can connect to the cluster through port 8080 on your computer.
I’ve written a script to get the pod name and use it to access the application through the cluster’s REST interface. The script is called test-k8sdemo.sh
and takes the port as an argument.
./test-k8sdemo.sh 8080
And there you see the output.
Now that we have an app up and running, let’s talk about how to manage it. You can use the kubectl command to get information about pods, deployments, and so on.
For example, you can show a listing of the deployments:
kubectl get deployments
Or of the pods:
kubectl get pods
You can even get detailed information about the pods:
kubectl describe pods
This produces a lot of output, but it’s valuable (if somewhat verbose) information.
Kubernetes Web UI Dashboard
Now I love the command line as much as anybody, but did you know that Kubernetes has a Web-based UI dashboard?
By default the Dashboard is not deployed. From the documentation, you can copy the command to create the deployment through the kubectl command:
kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
Paste the above command into the console to deploy it.
Make sure the proxy is running (I showed you how to do this in Part 4). Start the proxy in a separate Terminal window:
kubectl proxy --port=8001
Once the Dashboard is deployed you can access it from http://localhost:8001/ui.
You can see the same basic information as from the various kubectl commands, but in a UI. Here’s an example of what I see using Chrome:
Conclusion
Well, that’s it for this series. I hope you enjoyed it, and make sure to check out the video below that walks you through everything I covered in this blog series (it’s true what they say: a video is worth a thousand pictures!).
Want to know more?
If you want to learn more about Kubernetes, check out this post at IBM developerWorks: What is Kubernetes?
Be sure to check out the other posts in this series:
- Part 1: Why Containers?
- Part 2: Kubernetes Overview
- Part 3: Install Kubernetes on your Computer (Minikube)
- Part 4: Work with Kubernetes on your Computer (Minikube)
Check out this video at IBM developerWorks TV, where I show you everything I covered in Parts 1-5 of this series:
Thanks for reading!
–jsp
You must be logged in to post a comment.