GCP副本编号中的Kubernetes GKE不匹配

时间:2018-11-09 13:41:32

标签: kubernetes replicaset google-kubernetes-engine

我有以下yaml文件,副本设置为3,但是当我在yaml中和控制台中将其部署在GKE上时,副本的数量仅为一个。 当我部署时,将创建吊舱,但随后将其终止。我忘记了什么吗?

apiVersion: apps/v1
kind: Deployment
metadata:
  name: xxx-nginx
  namespace: xxx
  labels:
    app: xxx-nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: xxx-nginx
  template:
    metadata:
      labels:
        app: xxx-nginx
    spec:
      volumes:
      - name: xxx-nginx
        configMap:
          name: xxx-nginx-configmap
      containers:
      - name: xxx-nginx
        image: nginx:1.15.3
        imagePullPolicy: Always
        ports:
        - containerPort: 80
        volumeMounts:
        - mountPath: /etc/nginx/conf.d
          name: xxx-nginx
        readinessProbe:
          httpGet:
            path: /nginx-health
            port: 80
          initialDelaySeconds: 15
          timeoutSeconds: 1
          periodSeconds: 10
        livenessProbe:
          httpGet:
            path: /nginx-health
            port: 80
          initialDelaySeconds: 15
          timeoutSeconds: 1
          periodSeconds: 10
        resources:
          requests:
            memory: 128Mi
            cpu: 100m
          limits:
            memory: 128Mi
            cpu: 100m

这就是我在GCP控制台上看到的内容:

enter image description here

[编辑]

我还添加了HPA:

apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: xxxx-hpa
  namespace: xxx
  labels:
    app: xxx-hpa
spec:
  scaleTargetRef:
    kind: Deployment
    name: xxx-phpfpm
    apiVersion: apps/v1
  minReplicas: 1
  maxReplicas: 10
  targetCPUUtilizationPercentage: 60

谢谢,问候

1 个答案:

答案 0 :(得分:1)

谢谢@apisim的评论,我发现了问题... HPA命令,因此如果minReplicas为1,则生产中将只有一个吊舱...

谢谢!