【问题标题】:Kubernetes GKE in GCP replicas number doesn't matchGCP 副本数中的 Kubernetes GKE 不匹配
【发布时间】:2018-11-11 02:54:08
【问题描述】:

我有以下 yaml 文件,其中副本集为 3,但是当我在 yaml 和控制台中的 GKE 上部署它时,副本的数量只有一个。 当我部署时,创建了 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

谢谢你,问候

【问题讨论】:

  • 是否有用于部署的 Horizo​​ntal Pod Autoscaler (HPA)? kubectl -n <namespace> get hpa
  • 是的,我在编辑时添加它

标签: kubernetes replicaset google-kubernetes-engine


【解决方案1】:

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

感谢问候

【讨论】:

    猜你喜欢
    • 2023-03-26
    • 2020-04-15
    • 2018-06-02
    • 2020-07-13
    • 1970-01-01
    • 2021-10-31
    • 2018-06-25
    • 2019-02-03
    • 1970-01-01
    相关资源
    最近更新 更多