Commands

Minikube

Command
Description

minikube start

Starts a single node cluster with latest supported stable version of Kubernetes, with default isolation driver detected

minikube start --driver=<driver> --kubernetes-version=v<sem-ver>

Starts a single node cluster with given version of Kubernetes and specific driver for isolation

minikube delete

Completely removes Minikube and the Minikube VM. This command should be attempted only when the Minikube cluster is to be decommissioned. All work will be lost after the completion of this command

minikube status

Display the status of the Minikube cluster

minikube stop

Stops all applications running in Minikube, safely stops the cluster and the VirtualBox VM, preserving our work until we decide to start the Minikube cluster once again, while preserving the Minikube VM.

minikube profile list

Allows us to view the status of all our clusters in a table formatted output. Default profile is minikube

minikube profile <profile-name>

Sets profile to a specific given profile

minikube node list

Allows users to list the nodes of a cluster, add new control plane or worker nodes, delete existing cluster nodes, start or stop individual nodes of a cluster

minikube ip

To display the cluster control plane node's IP address, or another node's IP with the --node|-n option

Examples

    minikube start --kubernetes-version=v1.27.10 --driver=podman --profile minipod

    minikube start --nodes=2 --kubernetes-version=v1.28.1 --driver=docker --profile doubledocker

    minikube start --driver=virtualbox --nodes=3 --disk-size=10g --cpus=2 --memory=6g --kubernetes-version=v1.27.12 --cni=calico --container-runtime=cri-o -p multivbox

    minikube start --driver=docker --cpus=6 --memory=8g --kubernetes-version="1.27.12" -p largedock

    minikube start --driver=virtualbox -n 3 --container-runtime=containerd  --cni=calico -p minibox

Command Reference

K8 Objects short forms

Object Name
Short Form

Deployment

deploy

Replica Set

rs

Pods

po

DaemonSet

ds

Certificate Signing Request

csr

K8 kubectl Commands

Query Commands

Command
Description

kubectl version --client

To get installed version of kubectl client.

kubectl config view

To get the configuration details of kubectl.

kubectl cluster-info

To display kuberneted cluster info.

kubectl get <resource1, resource2 ....>

To get details about resources such as nodes, namespaces, pods etc. Multiple resources can be specified by using , separator.

kubectl get <resource1, resource2 ....> -l label=value

Same as above command but with filter of label.

kubectl describe type name

Print a detailed description of the selected resources, including related resources such as events or controllers.

kubectl get namespaces

To list all the Namespaces

Networking Commmands

Command
Description

kubectl proxy

kubectl authenticates with the API server on the control plane node and makes services available on the default proxy port 8001. Run this command in background.

CUD Commands

  • Create, Update, Delete commands.

Command
Description

kubectl create token default

Creates a default token that can be used to authenticate

kubectl create clusterrole api-access-root --verb=get --non-resource-url=/*

kubectl create clusterrolebinding api-access-root --clusterrole api-access-root --serviceaccount=default:default

kubectl create namespace new-namespace-name

To create a new namespace

kubectl create -f <file>.yaml

To load a manifest into the cluster to run the desired Pod and its associated container image.

kubectl run <pod-name> --image=<image-name> --port=<port-no>

Run the Pod defined above without the definition manifest.

kubectl run nginx-pod --image=nginx:1.22.1 --port=80 --dry-run=client -o yaml > nginx-pod.yaml

An imperative command with additional key flags such as dry-run and the yaml output, can generate the definition template instead of running the Pod, while the template is then stored in the nginx-pod.yaml file. It can also genereate json by replacing -o flag value with json

kubectl apply -f nginx-pod.yaml

Apply a configuration to a resource as per the given file name. This command is preferred over create command.

kubectl replace --force -f file-name.yaml

Replace the existing configuration deployed with new one as per the given file.

kubectl delete -f filename.yaml

Delete the kubernetes objects as per the given configuration file.

kubectl delete <type> <resource-name>...

Delete the kubernetes pods as per the resource names from the default namespace.

Deployment Commands

Command
Description

kubectl rollout history deploy <deployment name>

Provides history for a given deployment.

kubectl rollout history deploy <deployment name> --revision=<n>

Provides history for a given deployment.

kubectl scale rs frontend --replicas=n

Scale the replication set to n for an replica set with name frontend.

kubectl scale deploy <name> --replicas=n

Scale the replication set to n for an deployment with given name.

kubectl set image deployment <deployment-name> <image-name>=<revision>

Sets the image in a deployment to a particular image revision.

kubectl rollout undo deployment <deployment-name> --to-revision=<n>

Undo's the rollout to previous specified revision.

Command Reference

Last updated