GKE Ingress 到具有 2 个公开端口的同一容器上的服务
GKE Ingress to services on same container with 2 exposed ports
我有一个 GKE 集群、一个静态 ip 和一个公开 2 个端口的 container/pod:8081(UI https) 和 8082 (WSS https)。我必须连接到同一 IP 上的 "UI Https" 和 "WSS Https"。 "WSS Https" 服务 没有 健康检查端点。
我是否需要使用 Isito、Consul、Nginx ingress 或某些服务网格来允许使用不同端口在同一 IP 上进行这些连接?
这可能吗?
我尝试过的事情:
- 具有 2 个独立入口服务的 GCP 全局 lb。第二个服务的 yaml 永远无法正常工作,但我可以通过 UI 添加另一个支持的服务。入口始终恢复为 "WSS Https" 服务的默认健康检查,并且它始终不健康。
- 使用静态 ip 将服务类型从
NodePort
更改为 LoadBalancer
。这将不允许我更改就绪检查并始终恢复原状。
- 具有 1 个入口和 2 个后端的 GCP GLIB 给我与上面相同的健康检查失败
- TCP 代理 - 不允许我设置相同的实例组。
下面是我的入口、服务和部署。
入口
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: app-ingress
namespace: myappnamespace
annotations:
kubernetes.io/ingress.global-static-ip-name: global-static-ip-name
labels:
app: appname
spec:
backend:
serviceName: ui-service
servicePort: 8081
tls:
- hosts:
- my-host-name.com
secretName: my-secret
rules:
- host: my-host-name.com
http:
paths:
- backend:
serviceName: ui-service
servicePort: 8081
- host: my-host-name.com
http:
paths:
- backend:
serviceName: app-service
servicePort: 8082
服务
---
apiVersion: v1
kind: Service
metadata:
labels:
name: ui-service
name: ui-service
namespace: myappnamespace
annotations:
cloud.google.com/app-protocols: '{"ui-https":"HTTPS"}'
beta.cloud.google.com/backend-config: '{"ports":{"8081":"cloud-armor"}}'
spec:
selector:
app: appname
ports:
- name: ui-https
port: 8081
targetPort: "ui"
protocol: "TCP"
selector:
name: appname
type: NodePort
---
apiVersion: v1
kind: Service
metadata:
labels:
name: app-service
name: app-service
namespace: myappnamespace
annotations:
cloud.google.com/app-protocols: '{"serviceport-https":"HTTPS"}'
beta.cloud.google.com/backend-config: '{"ports":{"8082":"cloud-armor"}}'
spec:
selector:
app: appname
ports:
- name: serviceport-https
port: 8082
targetPort: "service-port"
protocol: "TCP"
selector:
name: appname
type: NodePort
---
部署
apiVersion: apps/v1
kind: Deployment
metadata:
name: appname
namespace: myappnamespace
labels:
name: appname
spec:
replicas:1
selector:
matchLabels:
name: appname
strategy:
type: Recreate
template:
metadata:
name: appname
namespace: appnamespace
labels:
name: appname
spec:
restartPolicy: Always
serviceAccountName: myserviceaccount
containers:
- name: my-container
image: image
ports:
- name: service-port
containerPort: 8082
- name: ui
containerPort: 8081
readinessProbe:
failureThreshold: 3
httpGet:
path: /api/health
port: 8081
scheme: HTTPS
livenessProbe:
exec:
command:
- cat
- /version.txt
[......]
通过 Ingress 公开的服务必须响应来自负载均衡器的 health checks。
GKE Ingress 创建的外部 HTTP(S) 负载均衡器仅支持 https 流量的端口 443。
在这种情况下,您可能需要:
使用两个单独的 Ingress 资源为同一 IP 地址和端口上的两个不同主机名路由流量:
ui-https.my-host-name.com
wss-https.my-host-name.com
选择使用 Ambassador or Istio Virtual Service.
如果有帮助,请告诉我。
我有一个 GKE 集群、一个静态 ip 和一个公开 2 个端口的 container/pod:8081(UI https) 和 8082 (WSS https)。我必须连接到同一 IP 上的 "UI Https" 和 "WSS Https"。 "WSS Https" 服务 没有 健康检查端点。
我是否需要使用 Isito、Consul、Nginx ingress 或某些服务网格来允许使用不同端口在同一 IP 上进行这些连接?
这可能吗?
我尝试过的事情:
- 具有 2 个独立入口服务的 GCP 全局 lb。第二个服务的 yaml 永远无法正常工作,但我可以通过 UI 添加另一个支持的服务。入口始终恢复为 "WSS Https" 服务的默认健康检查,并且它始终不健康。
- 使用静态 ip 将服务类型从
NodePort
更改为LoadBalancer
。这将不允许我更改就绪检查并始终恢复原状。 - 具有 1 个入口和 2 个后端的 GCP GLIB 给我与上面相同的健康检查失败
- TCP 代理 - 不允许我设置相同的实例组。
下面是我的入口、服务和部署。
入口
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: app-ingress
namespace: myappnamespace
annotations:
kubernetes.io/ingress.global-static-ip-name: global-static-ip-name
labels:
app: appname
spec:
backend:
serviceName: ui-service
servicePort: 8081
tls:
- hosts:
- my-host-name.com
secretName: my-secret
rules:
- host: my-host-name.com
http:
paths:
- backend:
serviceName: ui-service
servicePort: 8081
- host: my-host-name.com
http:
paths:
- backend:
serviceName: app-service
servicePort: 8082
服务
---
apiVersion: v1
kind: Service
metadata:
labels:
name: ui-service
name: ui-service
namespace: myappnamespace
annotations:
cloud.google.com/app-protocols: '{"ui-https":"HTTPS"}'
beta.cloud.google.com/backend-config: '{"ports":{"8081":"cloud-armor"}}'
spec:
selector:
app: appname
ports:
- name: ui-https
port: 8081
targetPort: "ui"
protocol: "TCP"
selector:
name: appname
type: NodePort
---
apiVersion: v1
kind: Service
metadata:
labels:
name: app-service
name: app-service
namespace: myappnamespace
annotations:
cloud.google.com/app-protocols: '{"serviceport-https":"HTTPS"}'
beta.cloud.google.com/backend-config: '{"ports":{"8082":"cloud-armor"}}'
spec:
selector:
app: appname
ports:
- name: serviceport-https
port: 8082
targetPort: "service-port"
protocol: "TCP"
selector:
name: appname
type: NodePort
---
部署
apiVersion: apps/v1
kind: Deployment
metadata:
name: appname
namespace: myappnamespace
labels:
name: appname
spec:
replicas:1
selector:
matchLabels:
name: appname
strategy:
type: Recreate
template:
metadata:
name: appname
namespace: appnamespace
labels:
name: appname
spec:
restartPolicy: Always
serviceAccountName: myserviceaccount
containers:
- name: my-container
image: image
ports:
- name: service-port
containerPort: 8082
- name: ui
containerPort: 8081
readinessProbe:
failureThreshold: 3
httpGet:
path: /api/health
port: 8081
scheme: HTTPS
livenessProbe:
exec:
command:
- cat
- /version.txt
[......]
通过 Ingress 公开的服务必须响应来自负载均衡器的 health checks。
GKE Ingress 创建的外部 HTTP(S) 负载均衡器仅支持 https 流量的端口 443。
在这种情况下,您可能需要:
使用两个单独的 Ingress 资源为同一 IP 地址和端口上的两个不同主机名路由流量:
ui-https.my-host-name.com
wss-https.my-host-name.com
选择使用 Ambassador or Istio Virtual Service.
如果有帮助,请告诉我。