Deploying new stuff
Start a new pod using deployments as follows:
kubectl run "<deployment-name>" --image "<container-image>" "<commands-passed-on-to-container-image>"
This creates 3 resources - deployment, repliac sets and finally a pod / pods.
A deployment consists of one or more replica sets, replica sets consists of pods.
Deployment allows scaling, rolling updated and rollbacks. A replica set makes sure given number of identical pods are running, it also allows scaling.
Since deployment "manages" it's replica sets, configuration in deployment will override changes in replica set configuration made from CLI.
Watching logs for a running pod
# Logs for a deployment
kubectl logs "deploy/<deployment-name>"
# You can use common switches like tail and follow with this
kubectl logs "deploy/<deployment-name> --tail 1 -f"
Logs command can only pull logs from one pod, if you have multiple identical pods running, logs will stick to just one pod till that gets terminated.
You can also pull logs for a specific pod - using get pods to get pod ID, use that ID with logs command.
Scaling pods
kubectl scale "deploy/<deployment-name>" --replicas "<number>"
It'll scale no. of pods to new replicas number.
Deleting resource
kubectl delete "<resource-type>/<resource-id>"
Delete send SIGTERM to shut down pod gracefully, as soon as one pod is in "Terminating" state, replica set will start a new one to match total replicas configuration. Once grace period expired, Kubernetes will then kill container in "Terminating" state, this grace period is configurable to suite variety of application lifecycles.
Top comments (0)