【发布时间】: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
谢谢你,问候
【问题讨论】:
-
是否有用于部署的 Horizontal Pod Autoscaler (HPA)?
kubectl -n <namespace> get hpa -
是的,我在编辑时添加它
标签: kubernetes replicaset google-kubernetes-engine