Kubernetes Commands
Set namespace in context
kubectl config set-context --current --namespace=MY-NAMESPACE
Set config in powershell
$env:KUBECONFIG = "C:\Users\USER\.kube\mykube-cluster\config"
Expose Service as NodePort
kubectl expose service mychart-dj-2762-m1-mychart-redis-master --type=NodePort --name=test-redis-master
kubectl expose service crunchy-primary-service --type=NodePort --name=test-crunchy-primary
Expose Deployment as Service
kubectl expose deployment mychart-test-service --port=8080 --target-port=8080 --name=mychart-test-service-svc
How to do Port Forward
kubectl port-forward mychart-dj-2762-m1-mychart-redis-master-0 7000:6379
Delete pods forcefully
kubectl delete pod --force --grace-period=0 -n NAMESPACE LIST_OF_PODIDs
Restart all services
kubectl rollout restart deploy
kubectl rollout restart deployment my-chart
Get logs for all pods of a deployment
kubectl logs deployment/vsphere-csi-controller
Get logs for all containers of all pods of a deployment
kubectl logs --all-containers=true deployment/vsphere-csi-controller
Get stateful details
kubectl get statefulset kubectl get svc -n dj2849 dj2849-redis-master -o yaml > test.yaml