How to set up Kubernetes terminal 🌟🌟🌟

How to set up Kubernetes terminal 🌟🌟🌟

Kubernetes comes pre-packaged with an outstanding CLI. For basic operations, it works wonderfully. Alas, when one needs to do something quickly, complexity increases... 🛥🛥🛥

Kubernetes comes pre-packaged with an outstanding CLI. For basic operations, it works wonderfully. Alas, when one needs to do something quickly, complexity increases.

The Kubernetes community has built all sorts of web based tooling for monitoring your cluster — kube ops view, grafana etc. However, having a fully kitted terminal will rapidly speed up the time it takes to get to the root of an issue. It forms a fundamental part of your Swiss army knife.

The following is a very short list of open source tools that I’ve applied to my OSX terminal. When used together, they allow me to skip around my kubernetes cluster, quickly troubleshoot issues, and monitor behaviour. I’ve cut out lots of small little utilities and stuck to the tools that I find myself using every day.

Before any tools…

Before you go after these tools, I’d strongly recommend installing zsh. It is an outstanding, open source wrapper around the standard OSX terminal. It is more feature rich and intuitive and the plugins you can install are fantastic. Some of these tools listed make the assumption you have ZSH installed.

k9s

oh yes

I’m starting strong. K9s is the momma bear of CLI tools for kubernetes cluster. You can SSH straight into pods with a single key press, view logs, delete resources and more. It provides outstanding access for the most common operations you’ll be performing. This is a staple for any engineer using kubernetes.

kubectx

But one thing that K9s doesn’t support is switching between various contexts in your kubernetes config. It is very rare that we’ll only have one single cluster. Switching between these is as simple as

kubectl config use-context my-context

But with this, there are some prerequisites:

  • You need to know the name of the cluster before you run.
  • There is another, similar set-context command that could trip you up.

kubectx presents a simpler alternative to this. If you run kubectx on its own, it will list out all of the contexts in your .kube/config file. You can then provide the name of the context you’re interested in:

kubectx my-context

No need to remember all the contexts, no need to manually check files and no possibility of getting the wrong command. Nice and simple. Combined with k9s, this offers a lot of navigability from your CLI with minimal key presses.

kubens

Once you’re flitting around contexts, you may want to dig into a specific namespace. Once again, it’s very common to have more than a few namespaces in your cluster. Well, ahmetb (the gentleman who brought you kubectx) also put together kubens. It’s the same as kubectx, only for namespaces.

kubens kube-system

Now all of your commands run against the kube-system namespace, by default. You can also run kubens without anything else to see a list of your namespaces.

kube-ps1

So, you can switch between contexts and namespaces. But how do you know which one you’re currently aimed at? It’s a pain to keep checking. At the moment, to find out you’d need to run:

kubens
kubectx
kubectl <my-command>

To remove this, ps1 is a zsh plugin that will automatically show you your current context and namespace:

I’m pointing at my minikube context and the default namespace

Now you can see which namespace and context you’re pointing out without running a single command. It’s also highly configurable too — you can turn off namespace or context, if you’re only interested in one of them, or you can use kubeoff to disable the whole thing entirely.

popeye

Now, onto something a little different. popeye will run automatic scans of the resources in your repository and highlight clear, obvious problems. This is a very new tool and one that I have found very useful. If you’re looking for some spring cleaning to do in your cluster, starting with popeye will give you some clear indications of what needs to be fixed.

This was the first few lines of a very long, detailed report.

Stern

Ever used kubectl logs? Noticed you can only follow logs from one pod at one time? Well, worry no more! Stern is a tool that allows you to pull the logs from multiple pods, based on a very flexible query.

What is Kubernetes | Kubernetes Introduction | Intellipaat

What is Kubernetes | Kubernetes Introduction | Intellipaat

🔥Intellipaat Kubernetes course: https://intellipaat.com/kubernetes-training/ In this kubernetes introduction video, you will learn what is kubernetes, it's f...

In this kubernetes introduction video, you will learn what is kubernetes, it's features & architecture of kubernetes. You will also see how to install kubernetes with hands on demo.

Why should you watch this Kubernetes tutorial?

Kubernetes is an open source platform that manages containerized applications which ultimately helps business to handle the containers to a compute cluster and make sure it runs smoothly as per the requirement. We are offering the top DevOps tutorial that can be watched by anybody to learn DevOps. Our Kubernetes tutorial has been created with extensive inputs from the industry so that you can learn DevOps easily.

Why DevOps is important?

DevOps implementation is going through the roof with most of the largest software organizations around the world invested heavily in its implementation. The core values of devops is effectively based on the Agile Manifesto but with one slight change which moves the focus from creating a working software to one that is more interested in the end-to-end software service mechanism and delivery.

What is Kubernetes | Kubernetes Tutorial For Beginners

What is Kubernetes | Kubernetes Tutorial For Beginners

This video on "What is Kubernetes | Kubernetes Tutorial For Beginners" will give you an introduction to one of the most popular Devops tool in the market - Kubernetes, and its importance in today's IT processes. This tutorial is ideal for beginners who want to get started with Kubernetes & DevOps

What Is Kubernetes | Kubernetes Introduction | Kubernetes Tutorial For Beginners

The following topics are covered in this training session:

  1. Need for Kubernetes
  2. What is Kubernetes and What it's not
  3. How does Kubernetes work?
  4. Use-Case: Kubernetes @ Pokemon Go
  5. Hands-on: Deployment with Kubernetes

Building and Managing Kubernetes with Kubernetes

Building and Managing Kubernetes with Kubernetes

Building and Managing Kubernetes with Kubernetes: Kubernetes as a declarative and portable system can be used to do many things in different ways.

Kubernetes as a declarative and portable system can be used to do many things in different ways.

At eBay we built a fleet management system based on k8s. Everything(server, subnet, OS, package and state) is declarative and can be modeled as CRDs in k8s, or referred to as a commit id in git from the objects. By running various controllers on top of these CRD objects, we use k8s to manage k8s, and the entire eBay data center. - Our system provisions hosts the same way k8s creates and manages pods. - We build k8s clusters with Salt. each host has a set of states defined in its salt CRD object. controllers pull states from git based on commit ids to apply. - We build both schedulers and deployment transactions to manage the k8s clusters for both config deployments and upgrades. This declarative, highly scalable, auto healing, and cloud native system is what we think can unify eBay’s fleet.

Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow us on Facebook | Twitter

Further reading about Kubernetes

An illustrated guide to Kubernetes Networking

Google Kubernetes Engine By Example

An Introduction to the Kubernetes DNS Service

Deploying a Laravel app in Kubernetes on Google Cloud

How to build a Microservice Architecture with Spring Boot and Kubernetes?