gpt4 book ai didi

kubernetes - 为 GKE 上的负载均衡器设置静态外部 IP

转载 作者:行者123 更新时间:2023-12-02 22:31:11 25 4
gpt4 key购买 nike

我正在尝试为 GKE 上的负载均衡器设置静态外部 IP,但没有成功。这是我的 Kubernetes 服务配置文件:

kind: Service
apiVersion: v1
metadata:
name: myAppService
spec:
selector:
app: myApp
ports:
- protocol: TCP
port: 3001
targetPort: 3001
type: LoadBalancer
loadBalancerIP: *********

这行不通。我希望看到我的外部 IP 为************,但它只是显示待处理:

➜  git:(master) kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ********* <none> 443/TCP 5m
myAppService ********* <pending> 3001:30126/TCP 5m

更多详细信息:

➜  git:(master) kubectl describe services
Name: kubernetes
Namespace: default
Labels: component=apiserver
provider=kubernetes
Annotations: <none>
Selector: <none>
Type: ClusterIP
IP: *********
Port: https 443/TCP
Endpoints: *********
Session Affinity: ClientIP
Events: <none>


Name: myAppService
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=myApp
Type: LoadBalancer
IP: *********
Port: <unset> 3001/TCP
NodePort: <unset> 30126/TCP
Endpoints:
Session Affinity: None
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
5m 20s 7 service-controller Normal CreatingLoadBalancer Creating load balancer
5m 19s 7 service-controller Warning CreatingLoadBalancerFailed Error creating load balancer (will retry): Failed to create load balancer for service default/myAppService: Cannot EnsureLoadBalancer() with no hosts

有什么想法吗?

最佳答案

这也让我陷入困境,我希望有人觉得这有帮助。

除了什么Dirk也就是说,如果您碰巧保留了全局静态 IP 地址而不是区域 IP 地址;您需要按照文档中的描述使用 Ingres:Configuring Domain Names with Static IP Addresses具体来说是步骤2b。

所以基本上你保留静态IP gcloud计算地址创建helloweb-ip --global

并添加一个安格尔:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: helloweb
# this is where you you add your reserved ip
annotations:
kubernetes.io/ingress.global-static-ip-name: helloweb-ip
labels:
app: hello
spec:
backend:
serviceName: helloweb-backend
servicePort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: helloweb-backend
labels:
app: hello
spec:
type: NodePort
selector:
app: hello
tier: web
ports:
- port: 8080
targetPort: 8080

如果您在步骤 2a 下选择键入“LoadBalancer”,该文档还描述了如何分配静态 IP。

关于kubernetes - 为 GKE 上的负载均衡器设置静态外部 IP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46944969/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com