gcloud 入口负载均衡器/静态 ip [英] gcloud ingress loadbalancer / static ip
问题描述
已设置默认 gce 入口控制器与入口资源一起工作以响应主机名
Having set the default gce ingress controller working with ingresses resources set to respond to hostnames
拥有静态 ip(以我目前的观点)的优势在于,您永远不会想知道将域配置到何处,它将始终保持相同的 ip;另一方面,您可以随心所欲地提供尽可能多的服务
The advantage of having a static ip (in my very current point of view) is that you never wonder where to configure your domain to, it will always remain the same ip; and on the other side you can stick as much service as you want behind it
我是使用这个 gce 负载均衡器的新手,我可以像使用静态 ip 一样依赖它吗(意味着它永远不会改变)?或者是否需要添加一层以将静态 ip 指向负载均衡器?
I'm quite new using this gce loadbalancer, can I rely on it as I would with a static ip (meaning it'll never change) ? Or is there a layer to add to point a static ip to a loadbalancer ?
我问是因为您可以设置服务资源的 ip.但我还不知道如何用这个 lbc/ingress 组合做同样的事情——为一个入口分配一个静态 ip?
I'm asking because you can set the ip of a service resource. But I have no clue yet about doing the same with this lbc/ingress combo — assigning a static ip to an ingress ?
我查了一下,似乎存在一些转发"(静态 ip 到负载均衡器)……但我真的很感激一些有经验的帮助,至少最终能清楚地理解这一切
I've checked around, there seem to exist some 'forwarding' (static ip to load balancer)… but I'd really appreciate some experienced help on this one, at least to end up understanding it all clearly
最佳
推荐答案
我终于有了一个可行的解决方案.您必须使用 loadBalancerIP: x.x.x.x
添加一个 L4 服务,在其中放置一个先前保留的静态 IP,然后放置一个部署/RC 已经拥有的选择器,如下所示:
Finally I have a working solution. You gotta add an L4 Service using loadBalancerIP: x.x.x.x
where you put a previously reserved static IP, and then put a selector that the deployment/RC already has, like this:
更新 [2017 年 11 月]:静态 IP 应该是区域性的,并且与集群在同一区域
UPDATE [Nov-2017]: Static IP should be regional and in the same region as cluster
服务:
apiVersion: v1
kind: Service
metadata:
name: nginx-ingress-svc
spec:
type: LoadBalancer
loadBalancerIP: 104.155.55.37 # static IP pre-allocated.
ports:
- port: 80
name: http
- port: 443
name: https
selector:
k8s-app: nginx-ingress-lb
控制器:
apiVersion: v1
kind: ReplicationController
metadata:
name: nginx-ingress-rc
labels:
k8s-app: nginx-ingress-lb
spec:
replicas: 1
selector:
k8s-app: nginx-ingress-lb
template:
metadata:
labels:
k8s-app: nginx-ingress-lb
spec:
containers:
- image: eu.gcr.io/infantium-platform-20/nginx-ingress
imagePullPolicy: Always
name: nginx-ingress
ports:
- containerPort: 80
hostPort: 80
- containerPort: 443
hostPort: 443
args:
- -nginx-configmaps=staging/nginx-staging-config
解决方案提示来自以下示例:https://beroux.com/英文/文章/kubernetes/?part=3
Solution hint was sourced from this example: https://beroux.com/english/articles/kubernetes/?part=3
希望这会有所帮助.
这篇关于gcloud 入口负载均衡器/静态 ip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!