You are currently viewing What Is Deploymen In Kubernetes

What Is Deploymen In Kubernetes

What Is Deployment In Kubernetes

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed ReplicaSet in Kubernetes.

In this blog post, we will discuss Deployment which provides declarative updates for Pods and ReplicaSets.

What is Deployment?

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.

Deployments represent a set of multiple, identical Pods with no unique identities. A Deployment runs multiple replicas of your application and automatically replaces any instances that fail or become unresponsive. In this way, Deployments help ensure that one or more instances of your application are available to serve user requests. Deployments are managed by the Kubernetes Deployment controller.

What Is Deploymen In Kubernetes

Deployments use a Pod template, which contains a specification for its Pods. The Pod specification determines how each Pod should look like: what applications should run inside its containers, which volumes the Pods should mount, its labels, and more. When a Deployment’s Pod template is changed, new Pods are automatically created one at a time.

Deployments are well-suited for stateless applications that use ReadOnlyMany or ReadWriteMany volumes mounted on multiple replicas, but are not well-suited for workloads that use ReadWriteOnce volumes. For stateful applications using ReadWriteOnce volumes, use StatefulSets. StatefulSets are designed to deploy stateful applications and clustered applications that save data to persistent storage, such as Compute Engine persistent disks. StatefulSets are suitable for deploying Kafka, MySQL, Redis, ZooKeeper, and other applications needing unique, persistent identities and stable hostnames.

Deployment manifest file syntax:

deploymentMetadata attributes:

  • annotations: Key value map stored with a resource for arbitrary metadata.
  • clusterName: The name of the cluster which the object belongs to.
  • creationTimestamp: Timestamp representing the server time when this object was created.
  • deletionGracePeriodSeconds: Seconds allowed for gracefully terminate before forcefully removed from the system.
  • deletionTimestamp: RFC 3339 date and time at which this resource will be deleted. Is not directly settable by a client.
  • finalizers: Must be empty before the object is deleted from the registry.
  • generateName: Optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided.
  • generation: A sequence number representing a specific generation of the desired state. Populated by the system. Read-only.
  • initializers: An initializer is a controller which enforces some system invariant at object creation time.
  • labels: Map of string keys and values that can be used to organize and categorize (scope and select) objects.
  • name: Name must be unique within a namespace.
  • namespace: Namespace defines the space within each name must be unique, default namespace is default.
  • ownerReferences: List of objects depended by this object.
  • resourceVersion: An opaque value that represents the internal version of this object used to determine when objects have changed.
  • selfLink: SelfLink is a URL representing this object. Populated by the system. Read-only.
  • uid: UID is the unique in time and space value for this object

deploymentSpec attributes:

  • minReadySeconds: Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0
  • paused: Indicates that the deployment is paused.
  • progressDeadlineSeconds: The maximum time in seconds for a deployment to make progress before it is considered to be failed. The deployment controller will continue to process failed deployments and a condition with a ProgressDeadlineExceeded reason will be surfaced in the deployment status. Note that progress will not be estimated during the time a deployment is paused. Defaults to 600s.
  • replicas: Replicas is the number of desired replicas. This is a pointer to distinguish between explicit zero and unspecified. Defaults to 1.
  • selector: Selector is a label query over pods that should match the Replicas count. If Selector is empty, it is defaulted to the labels present on the Pod template. Label keys and values that must match in order to be controlled by this replication controller, if empty defaulted to labels on Pod template.
  • strategy: The deployment strategy to use to replace existing pods with new ones.
  • template: Template is the object that describes the pod that will be created if insufficient replicas are detected.

Deployment Demo:

Step 1: Create a deployment.

Step 2: View deployment details.

Step 3: Update your deployment.

Step 4: Rolling back a deployment.

Step 5: Scale up and scale down number of replicas controlled by this deployment.

Step 6: Make a connection to the pod managed by deployment.

Step 7: Cleanup.

Hope you enjoyed this article. In real world sceanrios we hardly deploy a pod directly. Instead pods are deployed using pod controller. In the next blog post, we will discuss one of the pod controller services.

To get more details on Kubernetes you can follow the below link.

To get more details on Docker you can follow the below links.


Leave a Reply