Skip to content

Instantly share code, notes, and snippets.

@nitish24p
Created Jul 25, 2021
Embed
What would you like to do?

Kubernetes Commands and Resources

Components

Any kubernetes cluster has 3 main components

  1. Control Plane
  2. Proxy network

Commands

To start minikube cluster

minikube start

To get pods

kubectl get pods

To Deploy to a pod / create a deployment

kubectl create deployment kubernetes-bootcamp --image=<Image_name>

To Delete a deployment

kubectl delete deployment <Deployment-Id>

Get Pod Name

export POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')

Get Pod data

kubectl get pod -o wide

Get Pod Information

kubectl describe pods
kubectl describe pod <POD-ID>

Execute A commond inside container

kubectl exec -ti $POD_NAME -- /bin/bash

Expose a deployment as a service

kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080

Add a label

kubectl label pods $POD_NAME version=v1

Add a service / Remove service

kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080
kubectl delete service -l app=kubernetes-bootcamp

Scale an app

kubectl scale deployments/<Deployment_name> --replicas=8

kubectl scale deployments/kubernetes-bootcamp --replicas=4

Kubectl proxy

The proxy basically is a local server which allows you to interact with the server via curl requests

Pod

It is the smallest unit of K8s

Deployment

Deployment creates a pod

Node

A node is a physical machine or a VM, think of it as a worker. Each node must have

  1. Kubelet Process / agent for communicating to controle plane
  2. Docker runtime env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment