如何在 GKE 1.16 上启用启动探测?
How to enable startup probe on GKE 1.16?
我创建了一个部署,其中包含活动性和就绪性探测以及初始延迟,效果很好。如果我想用启动探测替换初始延迟,则 startupProbe
键及其嵌套元素在使用 kubectl apply
创建时永远不会包含在部署描述符中,并从 GKE 部署编辑器中的部署 yaml 中删除保存后
一个例子:
apiVersion: v1
kind: Namespace
metadata:
name: "test"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres-sleep
namespace: test
spec:
selector:
matchLabels:
app: postgres-sleep
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 50%
template:
metadata:
labels:
app: postgres-sleep
spec:
containers:
- name: postgres-sleep
image: krichter/microk8s-startup-probe-ignored:latest
ports:
- name: postgres
containerPort: 5432
readinessProbe:
tcpSocket:
port: 5432
periodSeconds: 3
livenessProbe:
tcpSocket:
port: 5432
periodSeconds: 3
startupProbe:
tcpSocket:
port: 5432
failureThreshold: 60
periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: postgres-sleep
namespace: test
spec:
selector:
app: httpd
ports:
- protocol: TCP
port: 5432
targetPort: 5432
---
其中 krichter/microk8s-startup-probe-ignored:latest
为
FROM postgres:11
CMD sleep 30 && postgres
我正在重用来自与 microk8s 相同问题的这个示例,我可以通过更改 kubelet
和 kubeapi-server
配置文件来解决它(如果你是,请参阅 https://github.com/ubuntu/microk8s/issues/770感兴趣的)。我认为这对于 GKE 集群是不可能的,因为它们不会公开这些文件,这可能是有充分理由的。
我认为该功能需要启用,因为它位于功能门之后。如何在版本 >= 1.16 的 Google Kubernetes Engine (GKE) 集群上启用它?目前我使用的是常规频道 1.16.8-gke.15 的默认值。
正如我在评论中提到的,我能够在我的测试环境中重现相同的行为,经过一些研究我找到了原因。
在 GKE 中,仅当您使用 Alpha 集群时才允许使用功能门。可以看到完整的功能门列表here
我创建了一个 alpha 集群并应用了相同的 yaml,它对我有用,startupProbe
就在那里。
因此,您将只能在 GKE Alpha 集群中使用 startupProbe
,请按照此 documentation 创建一个新集群。
注意 alpha 集群的限制:
- Alpha clusters have the following limitations:
- Not covered by the GKE SLA
- Cannot be upgraded
- Node auto-upgrade and auto-repair are disabled on alpha clusters
- Automatically deleted after 30 days
- Do not receive security updates
此外,Google不建议将其用于生产工作负载:
Warning: Do not use Alpha clusters or alpha features for production workloads. Alpha clusters expire after thirty days and do not receive security updates. You must migrate your data from alpha clusters before they expire. GKE does not automatically save data stored on alpha clusters.
我创建了一个部署,其中包含活动性和就绪性探测以及初始延迟,效果很好。如果我想用启动探测替换初始延迟,则 startupProbe
键及其嵌套元素在使用 kubectl apply
创建时永远不会包含在部署描述符中,并从 GKE 部署编辑器中的部署 yaml 中删除保存后
一个例子:
apiVersion: v1
kind: Namespace
metadata:
name: "test"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres-sleep
namespace: test
spec:
selector:
matchLabels:
app: postgres-sleep
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 50%
template:
metadata:
labels:
app: postgres-sleep
spec:
containers:
- name: postgres-sleep
image: krichter/microk8s-startup-probe-ignored:latest
ports:
- name: postgres
containerPort: 5432
readinessProbe:
tcpSocket:
port: 5432
periodSeconds: 3
livenessProbe:
tcpSocket:
port: 5432
periodSeconds: 3
startupProbe:
tcpSocket:
port: 5432
failureThreshold: 60
periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: postgres-sleep
namespace: test
spec:
selector:
app: httpd
ports:
- protocol: TCP
port: 5432
targetPort: 5432
---
其中 krichter/microk8s-startup-probe-ignored:latest
为
FROM postgres:11
CMD sleep 30 && postgres
我正在重用来自与 microk8s 相同问题的这个示例,我可以通过更改 kubelet
和 kubeapi-server
配置文件来解决它(如果你是,请参阅 https://github.com/ubuntu/microk8s/issues/770感兴趣的)。我认为这对于 GKE 集群是不可能的,因为它们不会公开这些文件,这可能是有充分理由的。
我认为该功能需要启用,因为它位于功能门之后。如何在版本 >= 1.16 的 Google Kubernetes Engine (GKE) 集群上启用它?目前我使用的是常规频道 1.16.8-gke.15 的默认值。
正如我在评论中提到的,我能够在我的测试环境中重现相同的行为,经过一些研究我找到了原因。
在 GKE 中,仅当您使用 Alpha 集群时才允许使用功能门。可以看到完整的功能门列表here
我创建了一个 alpha 集群并应用了相同的 yaml,它对我有用,startupProbe
就在那里。
因此,您将只能在 GKE Alpha 集群中使用 startupProbe
,请按照此 documentation 创建一个新集群。
注意 alpha 集群的限制:
- Alpha clusters have the following limitations:
- Not covered by the GKE SLA
- Cannot be upgraded
- Node auto-upgrade and auto-repair are disabled on alpha clusters
- Automatically deleted after 30 days
- Do not receive security updates
此外,Google不建议将其用于生产工作负载:
Warning: Do not use Alpha clusters or alpha features for production workloads. Alpha clusters expire after thirty days and do not receive security updates. You must migrate your data from alpha clusters before they expire. GKE does not automatically save data stored on alpha clusters.