0% found this document useful (0 votes)
23 views9 pages

Kubernetes A Hands On Task Based On Deployment 1728874761

Uploaded by

arunkumar.pasham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views9 pages

Kubernetes A Hands On Task Based On Deployment 1728874761

Uploaded by

arunkumar.pasham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Kubernetes

A hands-on task based on

Deployment

A Kubernetes Deployment is an object that manages the creation and update


of pods that run an application workload:
Declarative updates: Deployments describe the desired state of the
application, and the Deployment Controller adjusts the actual state to
match.
Controlled rollout: Deployments allow for the controlled release of
new code updates.
Rollback: Deployments enable the ability to roll back to an earlier
version of the deployment.
Scaling: Deployments can scale the number of replica pods to meet
demand.
Resource allocation: Deployments can adjust the amount of resources
allocated to each pod.
Task:
Create a deployment and NodePort service for the pods with the following
container images
a) docker.io/nginx
b) quay.io/libpod/banner
c) docker.io/pengbai/docker-supermario

a) Creating deployment and NodePort service for pod with “docker.io/nginx” container image

Define the deployment attributes as following in a yaml file

Explanation:

apiVersion: Specifies the version of the Kubernetes API used for this resource.
kind: Indicates that this resource is a Deployment.
metadata: Contains identifying information about the Deployment, such as its name and
labels.
replicas: Defines the desired number of Pods to be maintained by the Deployment.
selector: Specifies the criteria for selecting Pods that the Deployment will manage.
template: Describes the structure and specifications for the Pods created by the
Deployment.
containers: Lists the containers to be run within each Pod.
name: Specifies the name of the container within the Pod.
image: Indicates the container image to be used for creating the Pods.
ports: Defines the network ports exposed by the container.
containerPort: Specifies the port that the container will listen on for incoming traffic.
Create the deployment using the above file

kubectl create -f <file_name>

Successfully created a deployment following is the replicaset for the pods

Pods with “docker.io/nginx” image created successfully

Now let’s Create a NodePort service to make the application accessible from outside the cluster

Create a yaml file that defines the attributes for the required service

Explanation:

apiVersion: Specifies the API version for the Service resource, indicating it is part of the core
Kubernetes API.
kind: Indicates that this resource is a Service, which provides stable access to one or more
Pods.
metadata: Contains identifying information about the Service, including its name and labels.
name: The name of the Service, used to uniquely identify it within the namespace.
labels: Key-value pairs used to organize and select resources within Kubernetes.
app: A label indicating that this Service is associated with the nginx application.
spec: Defines the desired state and configuration for the Service.
type: Specifies that the Service should be accessible externally using the NodePort type.
selector: Defines how the Service selects the Pods to route traffic to based on labels.
ports: Configures the port settings for the Service, including the exposed and forwarded
ports.
port: The port exposed by the Service for external access.
targetPort: The port on the selected Pods to which the Service should forward traffic.
nodePort: The port on each Node where the Service is accessible externally.

Create the service using above file


Kubectl create -f <file_name>

Successfully created service for the nginx pods

Thus, the application is accessible for the clients outside the cluster
b) Creating deployment and NodePort service for the pods with “quay.io/libpod/banner”
image

Create a yaml file to define the deployment attributes as required

Here we will choose the “quay.io/libpod/banner” image in the image field

Create the deployment using the above file

Successfully created a replicaset for managing the “quay.io/libpod/banner”pods


Pods with the image “quay.io/libpod/banner” created successfully

Creating Service:
Define the Nodeport service attributes in a YAML file

Here we will assign the port 30002

Created a nodeport service using the above file “libpod-service”

Successfully created NodePort service for the pods with “quay.io/libpod/banner” image
Thus, the application is accessible outside the cluster through port we assigned

c) Creating deployment and Nodeport for pods with “docker.io/pengbai/docker-supermario”


container image

Now write a YAML file to define all the required attributes for creating deployment that manages
pods with the container image “docker.io/pengbai/docker-supermario”
Here we will use the mentioned image in the image field and expose the port 8080 required by this
application

Create the deployment using the file above

Successfully created replicaset for managing the pods

Pods with the required image created successfully

Creating service for making the application accessible externelly

In the YAMl file use port number 30003 for the current deployment and make sure to use
appropriate labels for pod-service connectivity
Create service using the yaml file

And our supermario application is deployed successfully

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy