常见Pod控制器

  • Deployment 声明式更新控制室,用于发布无状态应用
  • ReolicaSet 副本集控制器,用于对Pod进行副本规模扩大或裁剪
  • StatefulSet 有状态副本集,用于发布有状态应用
  • DaemonSet 在k8s集群每一个Node上运行一个副本,用于发布监控或日志收集类等应用
  • Job 运行一次性作业任务
  • CronJob 运行周期性作业任务

创建 Deployment Controller

kubectl apply -f deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-app2
  labels: 
    app: nginx
spec:
  # 副本数
  replicas: 3 
  selector: 
    matchLabels:
      app: nginx 
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx-containers
        image: nginx:latest
        imagePullPolicy: IfNotPresent
        ports:
        - name: nginxport
          containerPort: 80

删除 Deployment Controller

kubectl.exe delete deployment nginx-app2

kubectl.exe delete -f deployment.yaml