have a local domain rgpd.local for my local app with Kubernetes / Traefik

10/22/2019

Right now, I can test my local apps with: http://localhost/rgpd/api/...

Here is my rgpd-ingress.yaml

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: rgpd-ingress
  namespace: rgpd
  annotations:
    kubernetes.io/ingress.class: traefik
spec:
  rules:
  - http:
      paths:
      - path: /rgpd/api
        backend:
          serviceName: rgpd-api-local
          servicePort: "rgpd-port"

I would like to change it to: rgpd.local

So I changed it to:

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: rgpd-ingress
  namespace: rgpd
  annotations:
    kubernetes.io/ingress.class: traefik
spec:
  rules:
  - host: rgpd.local
    http:
      paths:
      - backend:
         serviceName: rgpd-api-local
         servicePort: "port-rgpd"

But now, if I enter old url, I get 404 and I can't connect the new one neither.

Here are my files:

Deployment:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    reloader.stakater.com/auto: "true"
  labels:
    app: rgpd-api-local
  name: rgpd-api-local
  namespace: rgpd
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: rgpd-api-local
    spec:
      containers:
        - image: rgpd_api:local
          envFrom:
            - secretRef:
                name: rgpd-env
          name: rgpd-api-local
          ports:
            - containerPort: 10000

And service:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: rgpd-api-local
  name: rgpd-api-local
  namespace: rgpd
spec:
  type: NodePort
  ports:
  - name: "rgpd-port"
    port: 10000
  selector:
    app: rgpd-api-local

Why can't it work ?

-- Juliatzin
kubernetes
kubernetes-ingress
traefik
traefik-ingress

2 Answers

10/25/2019

Add an entry in hosts file: /etc/hosts rgpd.local 127.0.0.1

-- Palash Goel
Source: StackOverflow

10/25/2019

update /etc/hosts or just supply Host header i.e curl -H "Host: rgpd.local" 127.0.0.1

-- Stepan Vrany
Source: StackOverflow