Sobes.tech
Junior — Middle

What methods can be used to deploy applications in a Kubernetes cluster?

sobes.tech AI

Answer from AI

In Kubernetes, applications can be deployed in several main ways:

  • kubectl apply — applying YAML manifests that describe objects (Deployment, Service, ConfigMap, etc.). This is the most basic and common method.

  • Helm — a package manager for Kubernetes that allows creating, versioning, and managing complex sets of resources as a single chart. It simplifies redeployment and updates.

  • Kustomize — a tool for managing Kubernetes configurations, enabling the creation of manifest variations without duplication.

  • Operators — special controllers that automate the management of applications and their lifecycle within the cluster.

  • GitOps — an approach where the cluster state is synchronized with a Git repository using tools (ArgoCD, Flux). It allows automating and controlling deployments through Git.

Example of a simple deployment using kubectl:

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

Command to apply:

kubectl apply -f deployment.yaml