简体   繁体   中英

Traefik 2.0: How to assign global static IP with IngressRoute (CRD)?

Following the tutorial for Kubernetes (in my case on GKE) https://docs.traefik.io/v2.0/user-guides/crd-acme/ I am stuck on how to assign the global static IP (GKE wants a forwarding rule). Am I missing something (eg adding another ingress)? I understand that annotations are not possible in the IngressRoute. So how would I assign the global reserved IP?

The answer to question 3 on this Q&A online meetup ( https://gist.github.com/dduportal/13874113cf5fa1d0901655e3367c31e5 ) mentions that "classic ingress" is also possible with version 2.x. Does this mean I can set up traefik as in 1.x (like this: https://docs.traefik.io/user-guide/kubernetes/ ) use 2.x configuration and no need for CRD?

You do it like with every other Ingress Controller.

A good step-by-step instructions on how to assign a Static IP address to an Ingress are given on nginx-ingress`s website.

Follow the section called ' Promote ephemeral to static IP '

If to follow Traefik 2.0's exemplary manifests files made for Kubernetes, once you patch your Traefik's K8S Service (with kubectl patch traefik...), you can verify if IngressRoute's took effect with following command:

 curl -i http://<static-ip-address>:8000/notls -H 'Host: your.domain.com'

Update

apiVersion: v1
kind: Service
metadata:
  name: traefik
spec:
  ports:
    - protocol: TCP
      name: web
      port: 8000
    - protocol: TCP
      name: admin
      port: 8080
    - protocol: TCP
      name: websecure
      port: 4443
  selector:
    app: traefik
  type: LoadBalancer

and patch it with:

kubectl patch svc traefik -p '{"spec": {"loadBalancerIP": "<your_static_ip>"}}'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM