Sobes.tech
Junior — Middle

What steps are necessary to deploy and run an application in Kubernetes?

sobes.tech AI

Answer from AI

The typical steps for deploying and running an application in Kubernetes are:

  1. Preparing manifests — creating YAML files describing Kubernetes resources such as Deployment, Service, ConfigMap.

  2. Creating a Docker image — packaging the application into a container and uploading the image to a registry (Docker Hub, private registry).

  3. Applying manifests — using the command kubectl apply -f <file> to create objects in the cluster.

  4. Checking status — using kubectl get pods, kubectl describe, and kubectl logs to verify that pods are running and functioning correctly.

  5. Configuring access — creating services (Service) for accessing the application inside or outside the cluster.

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: myrepo/myapp:latest
        ports:
        - containerPort: 8080

After that:

kubectl apply -f deployment.yaml
kubectl get pods
kubectl expose deployment myapp-deployment --type=LoadBalancer --port=80 --target-port=8080

This is a basic process that can be expanded depending on application requirements and infrastructure.