我正在尝试将 Google Kubernetes Engine Ingress 正确配置为在端口 3000 上运行的负载平衡 Docker 应用程序。我显然在某个地方犯了一个明显的错误,但我不知道在哪里。Ingress 总是说机器不健康,但我能够验证 Web 应用程序正在运行并在 0.0.0.0:3000 上侦听。
除了所述问题之外,我的配置中的任何其他明确的陷阱也值得赞赏。
当前设置如下所示:
部署.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 1
selector:
matchLabels:
app: web
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
minReadySeconds: 5
template:
metadata:
labels:
app: web
spec:
containers:
- name: cloud-sql-proxy
image: gcr.io/cloudsql-docker/gce-proxy:1.17
command:
- "/cloud_sql_proxy"
- "-ip_address_types=PRIVATE"
- "-instances=project:us-central1:postgres=tcp:5432"
securityContext:
runAsNonRoot: true
- name: web
image: gcr.io/PROJECT_ID/IMAGE:TAG
ports:
- containerPort: 3000
env:
- name: MASTER_KEY
valueFrom:
secretKeyRef:
name: masterkey
key: MASTER_KEY
resources:
requests:
cpu: 100m
limits:
cpu: 100m
网络服务.yml
apiVersion: v1
kind: Service
metadata:
name: web-service
spec:
selector:
app: web
type: NodePort
ports:
- port: 3000
targetPort: 443
protocol: TCP
name: https
网络入口.yml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: web-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: staging-cluster
networking.gke.io/managed-certificates: cloudflare-origin
spec:
rules:
- host: staging.mydomain.com
http:
paths:
- backend:
serviceName: web-service
servicePort: 443
cloudflare-origin.yml *
apiVersion: networking.gke.io/v1beta2
kind: ManagedCertificate
metadata:
name: cloudflare-origin
spec:
domains:
- staging.mydomain.com
计算地址.yml
apiVersion: compute.cnrm.cloud.google.com/v1beta1
kind: ComputeAddress
metadata:
name: staging-cluster
spec:
location: global
定制化.yml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- gke/deployment.yml
- gke/config-connector.yml
- gke/compute-address.yml
- gke/cloudflare-origin.yml
- gke/web-service.yml
- gke/web-ingress.yml