To make our deployment accessible to outer world we need to create a service in k8s.
Creating a service to make it accessible
kubectl expose deployment hello-node --type=LoadBalancer --port=8080 (8080 is internal port of the pod)
To get services
kubectl get services
Using minikube
minikube service hello-node
To delete service
kubectl delete service hello-node
To delete deployment
kubectl delete deployment hello-node
To get namespaces
kubectl get namespaces
By default everything is done in default namespace.
To get pods in a particular namespace
kubectl get pods --namespace <namespace>
To get pods from all namespaces
kubectl get pods --all-namespaces
Creating a namespace
kubectl create namespace <namespace>
Draining nodes in k8s
kubectl drain <node_name>
This can be done only if there is no DaemonSet on the k8s node. DaemonSet means pods that are tied to each node. if any DaemonSet is running on the k8s cluster then we can use the following to ignore the DaemonSet:
kubectl drain <node_name> --ignore-daemonsets
Once we drain a node, the node will still be a part of the cluster, now if we want to allow other pods to run on those nodes then we should uncorden that node.