Sobes.tech
Junior — Middle

How is an application deployed in a Kubernetes cluster?

sobes.tech AI

Answer from AI

Deploying an application in a Kubernetes cluster typically involves creating and applying manifests in YAML format, which describe the necessary resources: Deployment, Service, ConfigMap, and others.

Main steps:

  1. Create a Deployment that describes the container image, number of replicas, and update strategy.
  2. Create a Service to provide access to the pods (e.g., ClusterIP, NodePort, or LoadBalancer).
  3. Apply the manifests using the command kubectl apply -f <file.yaml>.

Example of a simple Deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: myapp-container
        image: myapp-image:latest
        ports:
        - containerPort: 80

After applying the manifest, Kubernetes will create the specified pods and ensure their operation according to the description.