DEV Community

Sid
Sid

Posted on

2 2

Kubernetes - First deployment

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.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

Deploy and scale your apps on AWS and GCP with a world class developer experience

Coherence makes it easy to set up and maintain cloud infrastructure. Harness the extensibility, compliance and cost efficiency of the cloud.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay