GCP 副本中的 Kubernetes GKE 数量不匹配

问题描述 投票:0回答:1

我有以下 yaml 文件,副本设置为 3,但是当我在 yaml 和控制台中将其部署到 GKE 上时,副本数量只有 1。

当我部署时,pod 会被创建,但随后会被终止。我是不是忘记了什么?

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 控制台上看到的内容:

[编辑]

我还添加了 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
kubernetes replicaset google-kubernetes-engine
1个回答
2
投票

谢谢@apisim 的评论,我发现了问题......

在 HPA 设置中,如果

minReplicas
为 1,则生产中将只有一个 pod...

© www.soinside.com 2019 - 2024. All rights reserved.