Yaz*_*tor 5 google-cloud-platform kubernetes
我正在开发一个 Kubernetes 集群,将服务从 GCloud Ingress 定向到我的服务。服务端点之一未能通过 HTTP 方式进行运行状况检查,但以 TCP 方式通过。
当我将 GCloud 内的运行状况检查选项更改为 TCP 时,运行状况检查通过,并且我的端点工作,但几分钟后,GCloud 上的运行状况检查将该端口重置回 HTTP,并且运行状况检查再次失败,给我一个我的端点上有 502 响应。
我不知道这是 Google Cloud 内部的错误还是我在 Kubernetes 中做错了什么。我已将我的 YAML 配置粘贴到此处:
名称空间
apiVersion: v1
kind: Namespace
metadata:
name: parity
labels:
name: parity
Run Code Online (Sandbox Code Playgroud)
存储类
apiVersion: storage.k8s.io/v1
metadata:
name: classic-ssd
namespace: parity
provisioner: kubernetes.io/gce-pd
parameters:
type: pd-ssd
zones: us-central1-a
reclaimPolicy: Retain
Run Code Online (Sandbox Code Playgroud)
秘密
apiVersion: v1
kind: Secret
metadata:
name: tls-secret
namespace: ingress-nginx
data:
tls.crt: ./config/redacted.crt
tls.key: ./config/redacted.key
Run Code Online (Sandbox Code Playgroud)
有状态集
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: parity
namespace: parity
labels:
app: parity
spec:
replicas: 3
selector:
matchLabels:
app: parity
serviceName: parity
template:
metadata:
name: parity
labels:
app: parity
spec:
containers:
- name: parity
image: "etccoop/parity:latest"
imagePullPolicy: Always
args:
- "--chain=classic"
- "--jsonrpc-port=8545"
- "--jsonrpc-interface=0.0.0.0"
- "--jsonrpc-apis=web3,eth,net"
- "--jsonrpc-hosts=all"
ports:
- containerPort: 8545
protocol: TCP
name: rpc-port
- containerPort: 443
protocol: TCP
name: https
readinessProbe:
tcpSocket:
port: 8545
initialDelaySeconds: 650
livenessProbe:
tcpSocket:
port: 8545
initialDelaySeconds: 650
volumeMounts:
- name: parity-config
mountPath: /parity-config
readOnly: true
- name: parity-data
mountPath: /parity-data
volumes:
- name: parity-config
secret:
secretName: parity-config
volumeClaimTemplates:
- metadata:
name: parity-data
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: "classic-ssd"
resources:
requests:
storage: 50Gi
Run Code Online (Sandbox Code Playgroud)
服务
apiVersion: v1
kind: Service
metadata:
labels:
app: parity
name: parity
namespace: parity
annotations:
cloud.google.com/app-protocols: '{"my-https-port":"HTTPS","my-http-port":"HTTP"}'
spec:
selector:
app: parity
ports:
- name: default
protocol: TCP
port: 80
targetPort: 80
- name: rpc-endpoint
port: 8545
protocol: TCP
targetPort: 8545
- name: https
port: 443
protocol: TCP
targetPort: 443
type: LoadBalancer
Run Code Online (Sandbox Code Playgroud)
入口
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-parity
namespace: parity
annotations:
#nginx.ingress.kubernetes.io/rewrite-target: /
kubernetes.io/ingress.global-static-ip-name: cluster-1
spec:
tls:
secretName: tls-classic
hosts:
- www.redacted.com
rules:
- host: www.redacted.com
http:
paths:
- path: /
backend:
serviceName: web
servicePort: 8080
- path: /rpc
backend:
serviceName: parity
servicePort: 8545
Run Code Online (Sandbox Code Playgroud)
问题
我已经编辑了主机名等,但这是我的基本配置。我还从这里的文档运行了一个 hello-app 容器进行调试: https: //cloud.google.com/kubernetes-engine/docs/tutorials/hello-app
这是/服务的入口端点指向的端口 8080 hello-app。这工作正常,不是问题,但只是为了澄清而在此处提到。
因此,这里的问题是,在 Google Cloud 上使用 GKE 和入口 LoadBalancer 创建集群(cluster-1Ingress 文件中的全局静态 IP 名称),然后在上述文件中创建 Kubernetes 配置后,运行状况检查失败/rpc当我转到 Google Compute Engine -> 运行状况检查 -> 端点的特定运行状况检查时,Google Cloud 上的端点/rpc。
当我编辑运行状况检查以不使用 HTTP 协议而是使用 TCP 协议时,端点的运行状况检查通过/rpc,我可以在之后很好地卷曲它,它会返回正确的响应。
问题是,几分钟后,相同的运行状况检查返回到 HTTP 协议,即使我将其编辑为 TCP,然后运行状况检查失败,当我再次卷曲它时,我收到 502 响应。
我不确定在 kubernetes 中创建 Ingress 之前是否有办法将 Google Cloud Health Check 配置附加到我的 Kubernetes Ingress。也不知道为什么它被重置,无法判断这是 Google Cloud 上的错误还是我在 Kubernetes 中做错的事情。如果您注意到我的statefulset部署,我已指定livenessProbe并readinessProbe使用 TCP 检查端口 8545。
650 秒的延迟是由于此处的票证问题造成的,该问题通过将延迟增加到 600 秒以上来解决(以避免提到的竞争条件):https ://github.com/kubernetes/ingress-gce/issues/34
我真的不确定为什么在我将其指定为 TCP 后,Google Cloud 运行状况检查会重置回 HTTP。任何帮助,将不胜感激。
我找到了一个解决方案,在 /healthz 端点上的有状态集上添加了一个用于运行状况检查的新容器,并配置了入口的运行状况检查以检查 kubernetes 分配的 8080 端口上的该端点作为 HTTP 类型的运行状况检查,这使它发挥作用。
当它是 TCP 时,重置发生的原因并不是很明显。
| 归档时间: |
|
| 查看次数: |
1567 次 |
| 最近记录: |