Kubernetes Basic Notes

Kubectl Installation

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

Minikube Installation

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

Kubectl Commands

CRUD Commands

1kubectl create deployment [name]
2kubectl edit deployment [name]
3kubectl delete deployment [name]

Status of different K8s components

1kubectl get `nodes | pods | services | replicaset | deployments`

Debugging pods

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

Applying YAML files

 1kubectl apply -f some-deployment.yaml
 2kubectl apply -f some-service.yaml
 3kubectl apply -f some-secret.yaml
 4kubectl describe service some-service
 5kubectl get pod -o wide
 6kubectl get deployment -o yaml
 7kubectl get secret
 8kubectl delete -f some-deployment.yaml
 9kubectl delete -f some-service.yaml
10kubectl delete -f some-secret.yaml

Single Node Deployment Example

Creating secrets

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

Namespaces

1kubectl get namespace
2kubectl get ns
3kubectl cluster-info
4kubectl get configmap -n default
5kubectl get configmap -n some-namespace
6kubectl config set-context --current --namespace=NAMESPACE_NAME

Ingress

1minikube addons enable ingress
2minikube dashboard

Helms

1helm install --values=my-values.yaml <chartname>
2kubectl exec -it nginx -c sidecar -- /bin/sh
3curl localhost
4kubectl logs nginx -c nginx-container
comments powered by Disqus