Home > Enterprise >  kubernetes: pods creation automation
kubernetes: pods creation automation

Time:12-19

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?

CodePudding user response:

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.

  • Related