0

While learning kubernetes, terms like kubectl, master node, api server etc come up regularly. Kubectl is client to interact with k8s cluster for doing stuff like creating pods, managing them etc. For eg, locally I use it to work with minikube.

But kubectl is more like manual interaction for running commands. In production environment pods are supposed to be spawn automatically as need arises. So how does that happen? Or is my understanding wrong about kubectl?

Mandroid
  • 6,200
  • 12
  • 64
  • 134

1 Answers1

3

For Production also you can use the Kubectl or Helm or kustomize to apply the YAML

ideally, in production you should be at the end applying the YAML to deploy the application.

You can choose the helm or kustomize to create or generate YAML as a specific application. once your YAML is ready you can apply the YAML using kubectl.

kubectl apply -f file-name.yaml

Or you can helm chart to deploy the relase of application.

helm install <chart-name>

Helm read more : https://helm.sh/docs/topics/charts/

Kustomize is K8s native config management Read more here: https://kustomize.io/

Ultimately you will be creating the YAML like below for app and applying using Kubectl either dev, stag or prod doesn't matter

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

Deploying using the kubectl cli without YAML is also fine but not much flexibility there.

While by looking at YAML you can get an idea of what is deployed and configuration.

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102
  • So all the deployment, creation of pods etc is automated without any human interference? – Mandroid Dec 18 '21 at 19:00
  • 1
    Yes you can create it, ci/cd. What you do is create single docker image which auto deploy to Dev, on human click get deployed to stag and if everything fine again on click get deployed to prod. But you can make it fully automated also but better keep release in hand – Harsh Manvar Dec 18 '21 at 19:36
  • Scaling is automatic in Kubernetes which create replicas of existing application and increase based on cpu and memory usage. But still you new to configure it using yaml first and apply – Harsh Manvar Dec 18 '21 at 19:38