Skip to main content

Posts

Showing posts from January, 2021

Kubernetes: 3. Deployments

What is Deployment in Kubernetes? Deployment is a Kubernetes object It is a higher level object, above the replica set A Deployment provides declarative updates for Pods and ReplicaSets. You describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate. You can define Deployments to create new ReplicaSets, or to remove existing Deployments and adopt all their resources with new Deployments. A deployment automatically creates the replica set Replica set created by deployment should not be managed manually Uses of Deployment Run multiple instances of applications Upgrade the docker instances seamlessly - Upgrade one after the other - Rolling updates! Rollback the recent changes Upgrade the webservers / Scaling the environment / Update the resources - All at a single time Pause and Resume the upgrades deployment-definition.yaml apiVersion: apps/v1 kind: Deployment metadata:      name: myapp-deployment   

Kubernetes: 2. Replica Set

Replication Controller Replication Controller is a Kubernetes Controller Runs multiple instances of kubernetes pods in a cluster thus providing high availability Replication Controller and Replica Set have same functionality but they are different Replication Controller is the older way to scale the pods Selector labels is optional, if you dont specify then " .spec.template.metadata.labels " is defaulted Replica Set Replica Set is also Kubernetes Controller Replica Set are for having the desired number of Pods running, same as Replication Controller Kubernetes keeps a watch of the number of pods that should be running at any time and automatically creates/deletes based on the pods running What differentiates a Replica Set from Replication Controller is selector with set-based label requirements. Set based allow filtering keys according to a set of values. Three kinds of operators are supported: in notin exists Updating Replica Set Use kubectl edit rs <rs-name> and modi

Kubernetes: 1. Pod

CREATE NEW POD Every kubernetes pod has 4 root level properties. They are apiVersion kind metadata spec For a pod these are as below. metadata -> Data about the Pod, note that we cannot have anything we want here. Only allowed values have to be used. metadata -> labels. This can be any key:value pairs, think of this as custom properties.  spec -> containers -> "- name". This is list, because we can have multiple containers running in a pod. "-" Indicates its a list pod-definition.yaml apiVersion: v1 kind: Pod metadata:   name: myapp-pod   labels:     app: myapp     location: IN spec:   containers:   - name: nginx-container     image: nginx   - name: backend-db     image: redis The easy way to create a pod is using kubectl run kubectl run <pod-name> --image=<image-name> DELETE A POD Get the list of pods running and then delete the pod kubectl get pods kubectl delete pod <pod-name kubectl delete -f <pod-definition-file> -f  -> Fil