Skip to content

Instantly share code, notes, and snippets.

@arttuladhar
Last active April 28, 2021 06:25
Show Gist options
  • Save arttuladhar/c467f6c91a7f27b800a676d048437205 to your computer and use it in GitHub Desktop.
Save arttuladhar/c467f6c91a7f27b800a676d048437205 to your computer and use it in GitHub Desktop.

Core Concepts

  • Understand Kubernetes Primitives API
  • Create and Configure Basic Pods

Create Namespace

kubectl get namespaces
kubectl create namespace mynamespace --dry-run=clieent -o yaml
kubectl get po -n mynamespace
kubectl get pods -all-namespaces

Create, List and Describe Pod

kubectl run hello-nginx --image=nginx -n mynamespace --restart=Never --dry-run=client -o yamlm > hello-nginx.yaml
kubectl apply -f hello-nginx.yaml
kubectl get pods -n mynamespace

# Get Information about Pod
kubectl describe pod hello-nginx

# Get Pod Logs
kubectl logs hello-nginx

# Update Image for Existing Pod
kubectl set image pod/hello-nginx nginx=nginx:1.17.1

# Verify Image Updates
kubectl describe pod hello-nginx

# Get IP Address of Pod
kubectl get po hello-nginx -o wide

# Using Temp BusyBox to Hit the Nginx Server
kubectl run buxybox --image=busybox --rm -it --restart=Never -- wget -O- <ip_address>

# Delete Pod
kubectl delete pod hello-nginx

Expose Pod

kubectl expose po nginx --port=80 --target-port=9376 --type=NodePort

Create Deployment

kubectl create deployment hello-nginx-deploy --image=nginx --dry-run=client -o yaml > hello-deploy.yamml kubectl apply -f hello-deploy.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment