Having set the default gce ingress controller working with ingresses resources set to respond to hostnames

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

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 ?

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 ?

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

Best

share|improve this question
    
Same for nginx ingress controller, the fact is that if you delete the ingress controller RC the scheduler can deploy the new pod onto a new node and thus having a different static IP configured (on the new node). This also means that if the node falls down, the pod will be rescheduled and perform a failover but the static IP will also be changed so a fixed DNS record will fail to resolve. No way we have found until the moment to assign a fixed IP into the controller that implements the Ingress resource. – danigosa Oct 20 '16 at 19:18
    
Hello Dani; thx a lot for your comment. So you're basically saying "no static ip for an ingress", right ? At least for the moment – Ben Oct 20 '16 at 19:43
    
The most I found was this: beroux.com/english/articles/kubernetes/?part=3 – danigosa Oct 20 '16 at 21:05
    
That said, I tried it and it's working although not very stable, I'm still investigating, until now by deploying the ingress and just "bypassing" kube-proxy, no Service, directly getting IP from the node it works like a charm, but no way to fix the IP, this way described in the link it fixes the IP but no stability up to now... getting ERR_TIMED_OUT errors randomly, still searching for causes. – danigosa Oct 20 '16 at 21:10
up vote 5 down vote accepted

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:

UPDATE [Nov-2017]: Static IP should be regional and in the same region as cluster

Service:

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

Controller:

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

Solution hint was sourced from this example: https://beroux.com/english/articles/kubernetes/?part=3

Hope this helps.

share|improve this answer
    
Ok thanks a lot lot ! I will investigate… But umm, I'm still learning sorry to ask this. With the example you show here, you don't have an ingress right ? the cluster entry point is your nginx service ? – Ben Oct 20 '16 at 21:39
    
No, you have to have the ingress a side, so you create first the ingress, then configmap (if needed) and then the service and the controller, in this order. The ingress and configmap don't have anything to do with the IP thing, as long as ingress cannot define an static IP. – danigosa Oct 20 '16 at 21:41
    
In other words the controller looks for ingress resources in its cluster+namespace, no need to bind it to controller. Controller is an implementation in Golang that uses K8s api's to discover everything, yes it looks like black magic at first, but you can go and check the source code to see how it works (I did and indeed I have a version that enables more customization (it adds number of worker-processes, conns per worker, etc.: github.com/infantium/kubernetes-ingress – danigosa Oct 20 '16 at 21:46
    
ahah! big thanks I start to get the whole picture. Have to say Controller is the part I did not looked into (you can couple Service with Deployments)… but Controller is now named Deployments in v1beta1 ? – Ben Oct 20 '16 at 21:57
    
anyway I'll try it and follow up here when I'll make it / thx a lot lot – Ben Oct 20 '16 at 21:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.