Sobes.tech
Junior — Middle

Can you explain what a configuration file in Kubernetes is and what it is used for?

sobes.tech AI

Answer from AI

A configuration file in Kubernetes is a YAML or JSON file that describes the desired state of cluster objects such as Pod, Deployment, Service, and others.

It is intended for declarative management of Kubernetes resources: you specify what you want to achieve, and Kubernetes controllers ensure that the current state of the cluster matches this description.

The configuration file specifies parameters such as:

  • resource name
  • number of replicas
  • container image
  • environment variables
  • update policies

Example of a simple Deployment in YAML:

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:1.14.2
        ports:
        - containerPort: 80

This file can be applied with the command kubectl apply -f deployment.yaml, and Kubernetes will create or update the corresponding resources.

Can you explain what a configuration file in… - sobes.tech