Kubectl Installation

curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
echo $PATH
sudo mv kubectl /usr/local/bin/

Minikube Installation

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
chmod +x minikube-linux-amd64
sudo mv minikube-linux-amd64 /usr/local/bin/minikube
minikube start
minikube status

Kubectl Commands

CRUD Commands

kubectl create deployment [name]
kubectl edit deployment [name]
kubectl delete deployment [name]

Status of different K8s components

kubectl get `nodes | pods | services | replicasets | deployments`

Debugging pods

Kubectl logs [pod name]
kubectl exec -it containername -- bin/bash

Applying YAML files

kubectl apply -f some-deployment.yaml
kubectl apply -f some-service.yaml
kubectl apply -f some-secret.yaml
kubectl describe service some-service
kubectl get pods -o wide
kubectl get deployments -o yaml
kubectl get secrets
kubectl delete -f some-deployment.yaml
kubectl delete -f some-service.yaml
kubectl delete -f some-secret.yaml

Single Node Deployment Example

Creating secrets

echo -n 'username' | base64
echo -n 'yourpassword' | base64

Namespaces

kubectl get namespace
kubectl get ns
kubectl cluster-info
kubectl get configmap -n default
kubectl get configmap -n some-namespace
kubectl config set-context --current --namespace=NAMESPACE_NAME

Ingress

minikube addons enable ingress
minikube dashboard

Helms

helm install --values=my-values.yaml <chartname>
kubectl exec -it nginx -c sidecar -- /bin/sh
curl localhost
kubectl logs nginx -c nginx-container