Kubernetesis one of the most famous container orchestration platforms. An open-source platform, Kubernetes automates a wide range of management, deployment, and scaling tasks for containerized applications. A Kubernetes cluster is a set of control panes and worker machines called nodes, which form a cluster every time you deploy Kubernetes. If you want to command your Kubernetes cluster to perform tasks, you can use the command line kubectl. It uses Kubernetes API to communicate with a Kubernetes cluster’s control pane. With it, you can perform almost any action on your Kubernetes cluster without needing to make direct API calls. Programmers with Kubernetes knowledge are in great demand, as many companies and organizations embrace Kubernetes to develop applications efficiently. Ready to make the most out of Kubernetes commands with kubectl? We’ve put together this kubectl cheat sheet filled with insights about managing Kubernetes clusters, kubectl logs, kubectl list pods, and much more. With this kubectl and Kubernetes commands cheat sheet, you’ll be equipped to tackle any application project. Here is a link to the kubectl cheat sheet that you can download and access offline whenever and wherever needed. Please follow this link if you're interested in a Kubernetes Benchmarking Study.

| Kubernetes | Docker swarm |
|---|---|
| Setup is very complicated, but once installed, cluster is robust For Kubernetes, GUI is the Kubernetes Dashboard Highly scalable and scales fast Kubernetes can do auto-scaling Manual intervention needed for load balancing traffic between different containers and pods Kubernetes can deploy rolling updates and does automatic rollbacks Kubernetes can share storage volumes only with the other containers in the same pod Kubernetes has In-built tools for logging and monitoring Kubernetes can do auto-scaling Kubernetes can deploy rolling updates and does automatic rollbacks Kubernetes can share storage volumes only with the other containers in the same pod Has In-built tools for logging and monitoring | Docker Swarm's Installation is very simple, but the cluster is not robust There is no GUI Highly scalable and scales 5x faster than Kubernetes Cannot do auto-scaling Docker swarm does auto load balancing of traffic between containers in the cluster Can deploy rolling updates, but not automatic rollback Can share storage volumes with any other container Uses 3rd party tools like ELK stack should be used for logging and monitoring Docker swarm does auto load balancing of traffic between containers in the cluster Can deploy rolling updates, but not automatic rollback Can share storage volumes with any the other containers |


BASH
To set upan autocomplete in bash within the current shell, you must install the bash-completion package using the following command.
source <(kubectl completion bash)
For adding the autocomplete permanently to your bash shell, run the following command.
echo "source <(kubectl completion bash)" >> ~/.bashrc
You can use a short name for Kubectl, as shown below.
alias k=kubectl
complete -F __start_kubectl k
ZSH
To set upan autocomplete in zsh within the current shell, you need to run the following command.
source <(kubectl completion zsh)
You can also run the following command to make it permanent.
echo "[[ $commands[kubectl] ]] && source <(kubectl completion zsh)" >> ~/.zshrc
Kubectl Context and Configuration
The next set of commands will cover display, context, and user information.
Display merged kubeconfig settings with this command:
kubectl config view
Use several kubeconfig files simultaneously and view the merged config with this command:
KUBECONFIG=~/.kube/config:~/.kube/kubconfig2
kubectl config viewâ
kubectl config view -o jsonpath='{.users[?(@.name == "e2e")].user.password}'
Get the password of the e2e user with this command:
Run this command to display the first user:
kubectl config view -o jsonpath='{.users[].name}'
Display the entire list of the users with this command:
kubectl config view -o jsonpath='{.users[*].name}'
Display the list of context:
kubectl config get-contexts
Display the current context:
kubectl config current-context
Set the default context to the my-cluster-name:
kubectl config use-context my-cluster-name
Add a new user to your kubeconf supporting basic authentication:
kubectl config set-credentials kubeuser/foo.kubernetes.com --username=kubeuser --password=kubepassword
Save the namespace permanently for all subsequent kubectl commands in that context:
kubectl config set-context --current --namespace=ggckad-s2
Set a context with a specific username and namespace:
kubectl config set-context gce --user=cluster-admin --namespace=foo \
&& kubectl config use-context gceâ
kubectl config unset users.foo
Delete the user named foo:
Set or show context/namespace with a short alias:
alias kx='f() { [ "$1" ] && kubectl config use-context $1 || kubectl config current-context ; } ; f'
alias kn='f() { [ "$1" ] && kubectl config set-context --current --namespace $1 || kubectl config view --minify | grep namespace | cut -d" " -f6 ; } ; f'
The “apply” helps manage the applications through files that define Kubernetes resources. You can easily create and update resources within the cluster by running kubectl apply. It is one of the commonly practiced ways for managing applications on production. Kubectl Apply
Objects in Kubernetes are persistent entities that represent the state of your cluster.
Specifically, they can describe:
A Kubernetes object is a "record of intent." After you create the object, the Kubernetes system will constantly work to ensure that the object exists. By creating an object, you'retelling the Kubernetes system about how your cluster's workload will look (desired state).
If you want to work with Kubernetes objects (create, modify, or delete), you need to use the Kubernetes API. The kubectl command-line interface (CLI) makes it easier for you to make the necessary Kubernetes API calls. Interested in using the Kubernetes API directly? Try out one of the client libraries.
You can define the Kubernetes manifest file in YAML or JSON. This manifest file comes with the extension as .yaml, .yml, and .json, etc.
The following are the commands that allow you to work around the manifest file. “Apply” is used to push the required changes based on your configuration files.
Create resources:
kubectl apply -f ./my-manifest.yaml
Create from multiple files:
kubectl apply -f ./my1.yaml -f ./my2.yaml
Create resources in all manifest files in dir:
kubectl apply -f ./dir
** the “create” command will help in generating the new resources from files or standard input devices.
Create resources from url:
kubectl apply -f https://git.io/vPieo
Start a single instance of Nginx using the following command:
kubectl create deployment nginx --image=nginx
Create a job that will print "Hello World:"
kubectl create job hello --image=busybox:1.28 -- echo "Hello World"
Create a CronJob that will print "Hello World" every minute:
kubectl create cronjob hello --image=busybox:1.28 --schedule="*/1 * * * *" -- echo "Hello World"â
kubectl explain pods
Retrieve the documentation for pod manifests:
Create multiple YAML objects from stdin:
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: busybox-sleep
spec:
containers:
- name: busybox
image: busybox:1.28
args:
- sleep
- "1000000"
---
apiVersion: v1
kind: Pod
metadata:
name: busybox-sleep-less
spec:
containers:
- name: busybox
image: busybox:1.28
args:
- sleep
- "1000"
EOF
Create a secret
with several keys:
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
name: mysecret
type: Opaque
data:
password: $(echo -n "s33msi4" | base64 -w0)
username: $(echo -n "jane" | base64 -w0)
EOF
In Kubernetes, we can define aresource as an endpoint present in the Kubernetes API. It is responsible for storing the collection of specific sorts of API objects. For example, the resource named built-in pods is a collection of pod objects.
We can use acustom resource to extend the Kubernetes API. It is not necessary that a custom resource should always be available in the default installation of Kubernetes. Moreover, custom resources have made it possible for us to create various core Kubernetes functions, which make Kubernetes more modular in nature.
Dynamic registration makes it possible for custom resources to appear or disappear in a running cluster. Also, cluster admins have the right to update custom resources without concerning the cluster itself. Like the built-in resources, users can also create and access the objects of custom resourceswhen they are installed.
These commands will help you fetch cluster data from various sources:
kubectl describe nodes my-node
kubectl describe pods my-pod
kubectl get services --sort-by=.metadata.name
List pods sorted by restart count:
kubectl get pods --sort-by='.status.containerStatuses[0].restartCount'
List PersistentVolumes sorted by capacity:
kubectl get pv --sort-by=.spec.capacity.storage
Obtain theversion label of all pods with label app=cassandra:
kubectl get pods --selector=app=cassandra -o \
jsonpath='{.items[*].metadata.labels.version}'
Get the value of a key with dots, e.g. 'ca.crt:'
kubectl get configmap myconfig \
-o jsonpath='{.data.ca\.crt}'
For this command, use a selector for excluding the results that have a label # named 'node-role.kubernetes.io/master.'View all worker nodes:
kubectl get node --selector='!node-role.kubernetes.io/master'
Get all running pods in the namespace:
kubectl get pods --field-selector=status.phase=Running
Get the ExternalIPs of all nodes:
kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="ExternalIP")].address}'
This command is useful for transformations that are too complex for jsonpath, and can be found here. List pod names of Pods that belong to Particular RC "jq:"
sel=${$(kubectl get rc my-rc --output=json | jq -j '.spec.selector | to_entries | .[] | "\(.key)=\(.value),"')%?}
echo $(kubectl get pods --selector=$sel --output=jsonpath={.items..metadata.name})â
kubectl get pods --show-labels
Show all pod labels:
Checkwhich nodes are ready:
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}' \
&& kubectl get nodes -o jsonpath="$JSONPATH" | grep "Ready=True"â
kubectl get secret my-secret -o go-template='{{range $k,$v := .data}}{{"### "}}{{$k}}{{"\n"}}{{$v|base64decode}}{{"\n\n"}}{{end}}'
List all secrets currently in use by a pod:Get theoutput decoded secrets without external tools:
kubectl get pods -o json | jq '.items[].spec.containers[].env[]?.valueFrom.secretKeyRef.name' | grep -v null | sort | uniq
This command is helpful when cleaning up stopped containers, while avoiding removal of initContainers.List all containerIDs of initContainer of all pods:
kubectl get pods --all-namespaces -o jsonpath='{range .items[*].status.initContainerStatuses[*]}{.containerID}{"\n"}{end}' | cut -d/ -f3â
kubectl get events --sort-by=.metadata.creationTimestamp
List events sorted by timestamp:
Compare current and future cluster states:
kubectl diff -f ./my-manifest.yaml
Create a period-delimited tree of all keys returned for nodes:
This command is helpful when locating a key within a complex nested JSON structure.
kubectl get nodes -o json | jq -c 'paths|join(".")'
Create a period-delimited tree of all keys returned for pods, etc.:
kubectl get pods -o json | jq -c 'paths|join(".")'
Create an ENV for all pods:
This command assumes you have a default container for the pods, default namespace and that the `env` command is supported. It is helpful when running any supported command across all pods, not just `env.`
for pod in $(kubectl get po --output=jsonpath={.items..metadata.name}); do echo $pod && kubectl exec -it $pod -- env; done
kubectl set image deployment/frontend www=image:v2
kubectl rollout history deployment/frontend
kubectl rollout undo deployment/frontend
kubectl rollout undo deployment/frontend --to-revision=2
kubectl rollout status -w deployment/frontend
kubectl rollout restart deployment/frontend
This command may cause a service outage.
kubectl replace --force -f ./pod.json
kubectl expose rc nginx --port=80 --target-port=8000
kubectl get pod mypod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f -
kubectl label pods my-pod new-label=awesome
kubectl annotate pods my-pod icon-url=http://goo.gl/XXBTWq
kubectl autoscale deployment foo --min=2 --max=10
These commands will patch resources as required.
kubectl patch node k8s-node-1 -p '{"spec":{"unschedulable":true}}'
Keep in mind that the spec.containers[*].name is required because it's a merge key
kubectl patch pod valid-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve-hostname","image":"new image"}]}}'
kubectl patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"new image"}]'
kubectl patch deployment valid-deployment --type json -p='[{"op": "remove", "path": "/spec/template/spec/containers/0/livenessProbe"}]'
kubectl patch sa default --type='json' -p='[{"op": "add", "path": "/secrets/1", "value": {"name": "whatever" } }]'
These commands will edit resources as required.
kubectl edit svc/docker-registry
KUBE_EDITOR="nano" kubectl edit svc/docker-registry
These commands will scale resources as required.
kubectl scale --replicas=3 rs/foo
kubectl scale --replicas=3 -f foo.yaml
kubectl scale --current-replicas=2 --replicas=3 deployment/mysql
kubectl scale --replicas=5 rc/foo rc/bar rc/baz
The following commands are used to delete the resources as required.
kubectl delete -f ./pod.json
kubectl delete pod unwanted -now
kubectl delete pod, service baz foo
kubectl delete pods, services -l name=myLabel
kubectl -n my-ns delete pod, svc --all
kubectl get pods -n mynamespace --no-headers=true | awk '/pattern1|pattern2/{print $1}' | xargs kubectl delete -n mynamespace pod
This next set of commands will show youhow to interact with running pods:
kubectl logs my-pod
kubectl logs -l name=myLabel
kubectl logs my-pod --previous
kubectl logs my-pod -c my-container
kubectl logs -l name=myLabel -c my-container
kubectl logs my-pod -c my-container --previous
kubectl logs -f my-pod
kubectl logs -f my-pod -c my-container
kubectl logs -f -l name=myLabel --all-containers
kubectl run -i --tty busybox --image=busybox:1.28 -- sh
kubectl run nginx --image=nginx -n mynamespace
kubectl run nginx --image=nginx
--dry-run=client -o yaml > pod.yaml
Attach pod to Running Container:
kubectl attach my-pod -i
kubectl port-forward my-pod 5000:6000
kubectl exec my-pod -- ls /
kubectl exec --stdin --tty my-pod -- /bin/sh
kubectl exec my-pod -c my-container -- ls /
kubectl top pod POD_NAME --containers
kubectl top pod POD_NAME --sort-by=cpu
These commands help you copy files and directories:
kubectl cp /tmp/foo_dir my-pod:/tmp/bar_dir
kubectl cp /tmp/foo my-pod:/tmp/bar -c my-container
kubectl cp /tmp/foo my-namespace/my-pod:/tmp/bar
kubectl cp my-namespace/my-pod:/tmp/foo /tmp/bar
This next set of commands helps you interact (dump, listen, view, run) with deployments and services.
kubectl logs deploy/my-deployment
kubectl logs deploy/my-deployment -c my-container
kubectl port-forward svc/my-service 5000
kubectl port-forward svc/my-service 5000:my-service-port
kubectl port-forward deploy/my-deployment 5000:6000
kubectl exec deploy/my-deployment -- ls
Learn how to interact with nodes and clusters with this next set of commands.
kubectl cordon my-node
kubectl drain my-node
kubectl uncordon my-node
kubectl top node my-node
kubectl cluster-info
kubectl cluster-info dump
kubectl cluster-info dump --output-directory=/path/to/cluster-state
kubectl taint nodes foo dedicated=special-user:NoSchedule
These commands help you manage clusters, from listing API resources to displaying pertinent information:
kubectl cluster-info
kubectl version
kubectl config view
kubectl api-resources
kubectl api-versions
kubectl get all --all-namespaces
A DaemonSet makes sure that nodes run pod copies. Nodes and pods are added to clusters. Similarly, pods undergo garbage collection once nodes are removed.When you delete a DaemonSet, all the pods created by it also get deleted.
Some typical DaemonSet uses for every node:
For simple cases, one DaemonSet could cover all nodes and each daemon type. A more complex setup might use multiple DaemonSets for a single type of daemon, but with different flags, memory, and CPU requests for various hardware types.
Shortcode = ds
kubectl get daemonsetâ
kubectl edit daemonset <daemonset_name>
kubectl delete daemonset <daemonset_name>
kubectl create daemonset <daemonset_name>
kubectl rollout daemonset
kubectl describe ds <daemonset_name> -n <namespace_name>
A deployment runs multiple application replicas and automatically replaces any failed or unresponsive instances.Deployments are managed by the Kubernetes Deployment Controller. Moreover, deployments make sure that user requests are served through one or more instances of your application.
Shortcode = deploy
kubectl get deployment
kubectl describe deployment <deployment_name>
kubectl edit deployment <deployment_name>
kubectl create deployment <deployment_name>
kubectl delete deployment <deployment_name>
kubectl rollout status deployment <deployment_name>
A Kubernetes event is an object in the framework automatically generated in response to changes with other resources—like nodes, pods, or containers.
State changes lie at the center of this. For example, phases across a pod’s lifecycle—like a transition from pending to running, or statuses like successful or failed—may trigger a Kubernetes event. The same goes for reallocations and scheduling.
Shortcode = ev
kubectl get events
kubectl get events --field-selector type=Warning
kubectl get events --field-selector involvedObject.kind!=Pod
kubectl get events --field-selector involvedObject.kind=Node, involvedObject.name=<node_name>
kubectl get events --field-selector type!=Normal
The Main Components of Kubernetes Explained.
Managing modern, distributed applications is challenging. Keeping systems reliable, scalable, and fault-tolerant requires sophisticated orchestration tools.
This is where Kubernetes comes in.
Kubernetes (K8s) streamlines the deployment, scaling, and management of containerized applications, making it a cornerstone of modern DevOps.
At its core, Kubernetes is built on a handful of key components, each with a distinct role.
By understanding them, you'll have a strong foundational understanding — Let's dive in!
Node: Machines (physical or virtual) that run containerized applications. Nodes host the workload, which is composed of Pods.
Pod: The smallest deployable unit in K8s, containing one or more containers that share storage, networking, and resources.
Control plane: The "brain" of the cluster that manages system state and oversees Nodes and Pods.
It consists of:
• API server: handles cluster management requests
• Scheduler: assigns Pods to Nodes
• Controller manager: maintains the desired state
• etcd: stores cluster configuration and state as a distributed key-value store
𝗦𝗲𝗿𝘃𝗶𝗰𝗲: Provides stable endpoints (IP/DNS) to enable communication between Pods or expose applications to external users.
𝗜𝗻𝗴𝗿𝗲𝘀𝘀: Manages external HTTP/HTTPS traffic, routing it to the appropriate services within the cluster.
𝗡𝗮𝗺𝗲𝘀𝗽𝗮𝗰𝗲: A virtual cluster within a Kubernetes cluster, allowing for resource isolation and multi-tenancy.
𝗣𝗲𝗿𝘀𝗶𝘀𝘁𝗲𝗻𝘁 𝘃𝗼𝗹𝘂𝗺𝗲: Decouples storage from Pods, enabling data persistence across container restarts or deletions.
The components above work together to form a powerful system for automating application orchestration. Kubernetes has become the go-to platform for ensuring reliability and scalability in modern software systems. That said it's not the answer for every application. There's a steep learning curve and complexity involved. Sometimes simpler/lightweight options like Docker Swarm or PaaS solutions are a better fit.

System component logs record events happening in a cluster, which can be useful for debugging.To see the desired details of those events, you can configure log verbosity.
There can be two types of logs, namely fine-grained and coarse-grained. Coarse-grained logs represent errors within a component. On the other hand, fine-grained logs represent step-by-step traces of events.
kubectl logs <pod_name>
kubectl logs --since=1h <pod_name>
kubectl logs --tail=20 <pod_name>
kubectl logs -f <service_name> [-c <$container>]
kubectl logs -f <pod_name>
kubectl logs -c <container_name> <pod_name>
kubectl logs <pod_name> pod.log
kubectl logs --previous <pod_name>
In Kubernetes, namespaces provide a mechanism for isolating groups of resources within a single cluster. Resource names must be uniquewithina namespace but notacrossnamespaces. Namespace-based scoping is applicable only for namespaced objects (e.g., Deployments, Services, etc.) and not for cluster-wide objects (e.g., StorageClass, Nodes, PersistentVolumes, etc.).
Shortcode = ns
kubectl create namespace <namespace_name>
kubectl get namespace <namespace_name>
kubectl describe namespace <namespace_name>
kubectl delete namespace <namespace_name>
kubectl edit namespace <namespace_name>
kubectl top namespace <namespace_name>
A replication controller is a key Kubernetes feature, responsible for:
Shortcode = rc
kubectl get rc
kubectl get rc --namespace="<namespace_name>"
RepliceSets ensure you have a stable set of replica pods operating. You might use one to confirm that identical pods are available.
Shortcode = rs
kubectl get replicasets
kubectl describe replicasets <replicaset_name>
kubectl scale --replicas=[x]
A secret is an object containing a small amount of sensitive data such as a password, token, or key. This information is either stored in a Pod specification or in a container image.Ifyou use a Secret, you don't need to include confidential data in your application code.
kubectl create secret
kubectl get secrets
kubectl describe secrets
kubectl delete secret <secret_name>
Services are anabstract way to expose an application running on a set of Pods as a network service.
If you want to use any unfamiliar servicediscovery mechanism, there is no need to make changes to your application when developed using Kubernetes. This is because Kubernetes assigns each pod with a unique IP address and a single DNS can manage all the load across multiple pods.
Shortcode = svc
kubectl get services
kubectl describe services
kubectl expose deployment [deployment_name]
kubectl edit services
A service account provides an identity for processes that run in a pod. Here is a useful introduction to Service Accounts.
Shortcode = sa
kubectl get serviceaccounts
kubectl describe serviceaccounts
kubectl replace serviceaccount
kubectl delete serviceaccount <service_account_name>
StatefulSets represent a set of pods with unique, persistent identities and stable hostnames that GKE maintains regardless of where they are scheduled.The persistent disk storage associated with the StatefulSet is responsible for storing state information and other resilient data for the given StatefulSet pod.
Shortcode = sts
kubectl get statefulset
kubectl delete statefulset/[stateful_set_name] --cascade=false
If you want to enter the Kubernetes world with high proficiency in managing containers, this kubectl cheat sheet will help you achieve your goals. Don’t forget to download our kubectl cheat sheet so you can have easy access to the commands whenever you’d like. Good luck with your job interview.
1. How Do I Get Pod Details in Kubernetes?
List all kubectl pods in the namespace
kubectl get pods
2. How Do You Use the kubectl Commands?
Here’s the basic syntax for kubectl:
kubectl [command] [TYPE] [NAME] [flags]
The commandportion describes what operation you want to perform, such as create, describe, get, apply, and delete.
Typedescribes the kind of resource kubectl is targeting, such as pods, services, daemonsets, deployments, replicasets, statefulsets, Kubernetes jobs, and cron jobs, etc
Nameis a case sensitive field that specifies the name of the resource in question. Flagshelp denote special options or requests made to a certain resource.
3. Can I Command in kubectl?
Yes, you can command in kubectl. You can query the API authorization layer using kubectl’s auth can-i subcommand. This command determines whether the user using kubectl currently can perform the given action or not using the SelfSubjectAccessReview API.
4. How Do I Get Pod Status With kubectl?
You can run the following command to get pod status:
kubectl get pods -n kube-system some-appdeployment -o jsonpath="Name: {.metadata.name} Status: {.status.phase}"
You can execute shell commands using one of the following methods:
Open a bash command shell in kubectl exec, where you can execute commands:
kubectl exec -it pod-name -- /bin/bash
kubectl exec -it suitecrm-0 -- /bin/bash
kubectl exec -it pod-name -- /bin/bash -c "command(s)"
kubectl exec -it suitecrm-0 -- /bin/bash -c "ls /"
Cluster state metrics
| DESCRIPTION | NAME IN KUBE-STATE-METRICS | COMMAND | |
|---|---|---|---|
| Running pods | kube_pod_status_phase | kubectl get pods | |
| Number of pods desired for a Deployment | kube_deployment_spec_replicas | kubectl get deployment <DEPLOYMENT> | |
| Number of pods desired for a DaemonSet | kube_daemonset_status_desired_number_scheduled | kubectl get daemonset <DAEMONSET> | |
| Number of pods currently running in a Deployment | kube_deployment_status_replicas | kubectl get deployment <DEPLOYMENT> | |
| Number of pods currently running in a DaemonSet | kube_daemonset_status_current_number_scheduled | kubectl get daemonset <DAEMONSET> | |
| Number of pods currently available in a Deployment | kube_deployment_status_replicas_available | kubectl get deployment <DEPLOYMENT> | |
| Number of pods currently available in a DaemonSet | kube_daemonset_status_number_available | kubectl get daemonset <DAEMONSET> | |
| Number of pods currently not available in a Deployment | kube_deployment_status_replicas_unavailable | kubectl get deployment <DEPLOYMENT> | |
| Number of pods currently not available in a DaemonSet | kube_daemonset_status_number_unavailable | kubectl get daemonset <DAEMONSET> |
| DESCRIPTION | NAME IN KUBE-STATE-METRICS | COMMAND | |
|---|---|---|---|
| Current health status of a node (kubelet) | kube_node_status_condition | kubectl describe node <NODE_NAME> | |
| Total memory requests (bytes) per node | kube_pod_container_resource_requests_memory_bytes | kubectl describe node <NODE_NAME> | |
| Total memory in use on a node | N/A | kubectl describe node <NODE_NAME> | |
| Total CPU requests (cores) per node | kube_pod_container_resource_requests_cpu_cores | kubectl describe node <NODE_NAME> | |
| Total CPU in use on a node | N/A | kubectl describe node <NODE_NAME> |
| DESCRIPTION | NAME IN KUBE-STATE-METRICS | COMMAND | |
|---|---|---|---|
| Number of successful job | kube_job_status_succeeded | kubectl get jobs --all-namespaces | grep “succeedeed” | |
| Number of failed jobs | kube_job_status_failed | kubectl get jobs --all-namespaces | grep “failed” | |
| Number of active jobs | kube_job_status_active | kubectl get jobs --all-namespaces | |
| Number of CronJobs | kube_cronjob_info | kubectl get cronjobs --all-namespaces |
| DESCRIPTION | NAME IN KUBE-STATE-METRICS | COMMAND | |
|---|---|---|---|
| Service types per cluster | kube_service_info | kubectl get services --all-namespaces | |
| Number of pods running by service | kubectl get pods --selector=<SERVICE_SELECTOR> -o=name | kubectl get jobs --all-namespaces |
| DESCRIPTION | NAME IN KUBE-STATE-METRICS | COMMAND | |
|---|---|---|---|
| Containers running on a pod | kube_pod_container_info | kubectl describe pod <POD_NAME> | |
| Containers restarted on a pod | kube_pod_container_status_restarts_total | kubectl describe pod <POD_NAME> | |
| Containers terminated on a pod | kube_pod_container_status_terminated | kubectl describe pod <POD_NAME> |
| DESCRIPTION | NAME IN KUBE-STATE-METRICS | COMMAND | |
|---|---|---|---|
| Network in per node | container_network_receive_bytes_total | kubectl get --raw /api/v1/nodes/<NODE_NAME>/proxy/metrics/cadvisor | |
| Network out per node | container_network_transmit_bytes_total | kubectl get --raw /api/v1/nodes/<NODE_NAME>/proxy/metrics/cadvisor | |
| Disk writes per node | container_fs_writes_bytes_total | kubectl get --raw /api/v1/nodes/<NODE_NAME>/proxy/metrics/cadvisor | |
| Disk reads per node | container_fs_reads_bytes_total | kubectl get --raw /api/v1/nodes/<NODE_NAME>/proxy/metrics/cadvisor | |
| Network errors per node | container_network_receive_errors_total, container_network_transmit_errors_total | kubectl get --raw /api/v1/nodes/<NODE_NAME>/proxy/metrics/cadvisor |
| DESCRIPTION | NAME IN KUBE-STATE-METRICS | COMMAND |
|---|---|---|
| List events | kubectl get events |
See how a fictional public relations firm uses Kubernetes capabilities to deploy a containerized app on IBM Cloud. With IBM Watson® Tone Analyzer Service, the firm gets feedback on its press releases.
Learn how to scaffold a web app, run it locally in a container, then deploy it to an IBM Cloud Kubernetes cluster. Also learn how to bind a custom domain, monitor the health of the environment and scale.
Learn how to create a cluster and configure the log analysis and monitoring services. Then, deploy an app to the cluster, view and analyze logs with Kibana and view health and metrics with Grafana.
Learn how to set up a CI/CD pipeline for containerized apps running in Kubernetes. This use case covers the setup of source control, build, test and deploy and integrating security scanners, analytics and more.
Each pattern serves a specific purpose, and should be carefully chosen and applied for the best results.
See the Pen Kubernetes cluster by Fabien Laurent Patrice Egot (@equant_org) on CodePen.