这是特定于云提供商的,但是根据您的问题标记,您似乎正在使用Google Cloud Platform的Kubernetes Engine(GKE)。我的答案是针对这种情况的。
来自
使用Ingress设置HTTP负载平衡
教程:
gcloud compute addresses create web-static-ip —global
</code>
</pre>
在你的Ingress清单中:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: basic-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: “web-static-ip”
spec:
backend:
serviceName: web
servicePort: 8080
</code>
</pre>
如果你使用,你可以做类似的事情
服务而不是Ingress
:
apiVersion: v1
kind: Service
metadata:
name: helloweb
labels:
app: hello
spec:
type: LoadBalancer
loadBalancerIP: “web-static-ip”
selector:
app: hello
tier: web
ports:
port: 80
targetPort: 8080