Skip to content

Instantly share code, notes, and snippets.

@nitish24p
Created July 25, 2021 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nitish24p/300ee292d13d15a71188e9968ca74642 to your computer and use it in GitHub Desktop.
Save nitish24p/300ee292d13d15a71188e9968ca74642 to your computer and use it in GitHub Desktop.

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