Layers for Abstraction

  1. Starts with Deployment
  2. ReplicaSet
  3. pods
  4. container

For example, when running kubectl get pods its name will comprise of following:

<deployment-name>-<replicaset>-<pod> : nginx-depl-5c8bf76b5b-8brzb

Deployment

‼️You are generally not creating pods but creating "Deployment"

CRUD happens on "deployment" level and everything else just follows automatically

Replicaset

# Get nodes
$- kubectl get nodes

# Get pods
$- kubectl get pods

# Get services
$- kubectl get services

# Get deployments
$- kubectl get deployment

# Get replicaset
$- kubectl get replicaset

# Create deployment
$- kubectl create deployment <deployment-name>

# Get yaml file for deployment
# this way you can change anything in default deployment 
# created by command above
$- kubectl get deployment <deployment-name> -o yaml > /tmp/nginx.yaml

# After any changes in yaml file, apply the changes
$- kubectl apply -f <path-to-yaml-file>

# Edit deployment
$- kubectl edit deployment <deployment-name>

# Gives all the state information
$- kubectl describe pods <pod-name>

# Get the logs of pod and what all applications has printing
$- kubectl logs <pod-name>

# Get appliation container from the pod, it looks pretty much like docker exec
$- kubectl exec -it <pod-name> -- bin/bash

# Delete all the replicasets and pods
# leave deployment-name empty to delete all deployments
$- kubectl delete deployment <deployment-name>

Layers of abstraction

Deployment

commands

Create nginx deployment

ReplicaSet