Write a Kubernetes YAML file that deploys a simple Nginx web server with the followingspecifications:a. The deployment should consist of 3 replicas.b. The container should use the official Nginx Docker image with the tag "latest".c. The container should expose port 80.d. The deployment should use a Kubernetes service to expose the web serveroutside the cluster. The service should use a NodePort type and expose port30080 on each node.e. Your YAML file should be named "nginx-deployment.yaml". You can assume thatthe cluster is already set up and running
Question
Write a Kubernetes YAML file that deploys a simple Nginx web server with the followingspecifications:a. The deployment should consist of 3 replicas.b. The container should use the official Nginx Docker image with the tag "latest".c. The container should expose port 80.d. The deployment should use a Kubernetes service to expose the web serveroutside the cluster. The service should use a NodePort type and expose port30080 on each node.e. Your YAML file should be named "nginx-deployment.yaml". You can assume thatthe cluster is already set up and running
Solution
Here is the Kubernetes YAML file that meets your specifications:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: NodePort
selector:
app: nginx
ports:
- protocol: TCP
port: 80
nodePort: 30080
This YAML file first defines a Deployment with 3 replicas of the Nginx Docker image. The container in each pod exposes port 80. Then, it defines a Service of type NodePort that exposes the Nginx web server outside the cluster by mapping each node's port 30080 to the pods' port 80.
Similar Questions
1.Question 1How do you create a ReplicaSet from scratch?1 pointApply a YAML file with the ‘kind’ attribute set to ‘ReplicaSet’.Use the ‘get pods’ command.Use the ‘scale’ command to scale the deployment.Apply a JSON file that includes the number of desired replicas.2.Question 2What Kubernetes object adds or deletes pods for scaling and redundancy?1 pointA Config MapA ReplicaSetA DaemonSetA Secret3.Question 3Which Kubernetes autoscaler type scales the Cluster?1 pointHorizontal Pod Autoscaler (HPA)Cluster Autoscaler (CA)You cannot autoscale a Kubernetes Cluster.Vertical Pod Autoscaler (VPA)4.Question 4How do you prepare your application to enable rolling updates?1 pointSet the maxSurge to 100%.Use autoscaling.Set the maxSurge to 50%.Add liveness and readiness probes to deployments.5.Question 5Which rolling update types ensure 100% app availability?1 pointBoth all-at-once and one-at-a-time updates and rollbacks ensure 100% app availability.All-at-once updates and rollbacks ensure 100% app availability.No rolling update types can ensure 100% app availability.One-at-a-time updates and rollbacks ensure 100% app availability.6.Question 6What does a ConfigMap do?1 pointProvides variables for your applicationVerifies that a Secret was createdMounts a file using the volumes plugin Provides sensitive information to your application7.Question 7What are three ways to create a ConfigMap? 1 pointBy using string literalsBy using an existing property or ‘key’ = ‘value’ fileBy adding another environment to the deployment descriptorBy providing a ConfigMap YAML descriptor file8.Question 8What are three ways to create a Secret?1 pointBy providing a ConfigMap YAML descriptor fileBy using a string literal By using volume mountsBy using environment variables 9.Question 9What does Service binding do? 1 pointManages configuration and credentials for back-end Services while protecting sensitive dataMakes Service credentials hidden.Calls the service without using binding credentials.Provides variables for your application10.Question 10What are the three required steps to bind the IBM Cloud Service to your Cluster? 1 pointErase the credential configuration file after credential setup.Provision an instance of the Service.Configure your app to access the credentials.Bind the Service to your Cluster to create credentials.
Please choose the best answer from the choices belowIdentify the node component of Kubernetes that ensures all pods and containers are healthy and running as expected.Container runtimeKubeletKube-apiserverKube-proxy
Which Kubernetes object is used to deploy a containerized application and manage its lifecycle?DeploymentConfigMapServiceNamespace
Which Kubernetes object is used to run a set of replicas for a pod on each node in the cluster?DeploymentReplicaSetStatefulSetDaemonSet
Explain architecture and working of Kubernetes
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.