Trying to have different URLs to the same kubernetes instance

Hi everybody,

An other employee deploy a kubernetes with traefik for our platform.
He left the company and now, I'm in charge of this part.
I'm not confident with kubernetes, treafik.... I'm verry sorry if my problem is obvious.

I would like to have two differents URLs pointing to the same application :
https://app.tenant1.com
https://app.tenant2.com

He let me a note for this part :

Add a new DNS on an environment

Let's assume we want to add a new DNS (app.tenant2.com) pointing on staging environment.

Add dns in certificate

Open k8s/staging/platform/certificate.yml file and add DNS to dnsNames: list like this:

spec:
  commonName: app.tenant1.com
  secretName: platform-cert
  dnsNames:
    - app.tenant1.com
    - app.tenant2.com

Run the following command to update certificate:

kubectl apply -f k8s/staging/platform/certificate.yml

Add dns in ingress route

Open k8s/staging/platform/ingress.yml file and add DNS to match: value like this:

spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`app.tenant1.com`) || Host(`app.tenant2.com`)

Run the following command to update certificate:

kubectl apply -f k8s/staging/platform/ingress.yml

I tried but, of course, it does not work at the first strike ^^

Treafik takes an error with a middleware : middleware "headers-default@file" does not exist

I don't know how to study my case, should I restart Treafik ?

This is my certificate.yml :

---
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
  name: platform-cert
  namespace: staging
  labels:
    "use-http01-solver": "true"
spec:
  commonName: app.tenant1.com
  secretName: platform-cert
  dnsNames:
    - app.tenant1.com
    - app.tenant2.com
  issuerRef:
    name: letsencrypt
    kind: ClusterIssuer

And my ingress.yml :

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: platform
  namespace: staging
  annotations:
    # add an annotation indicating the issuer to use.
    cert-manager.io/cluster-issuer: letsencrypt
    kubernetes.io/ingress.class: traefik  # Custom Ingress
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`app.tenant1.com`) || Host(`app.tenant2.com`)
      kind: Rule
      middlewares:
        - name: headers-default@file
      services:
        - name: platform
          port: 3000
  tls:
    secretName: platform-cert

Does anybody have an idea ?
I can send you more files if needed.

Thank you very much :grinning:

Ok, even when I come back with only one tenant, it does not work.
I miss a command to restart something I guess :confused:

So.... I didn't have the last version of the yaml.........

Good versions :

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: platform
  namespace: staging
  annotations:
    # add an annotation indicating the issuer to use.
    cert-manager.io/cluster-issuer: letsencrypt
    kubernetes.io/ingress.class: traefik  # Custom Ingress
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`app.tenant1.com`) || Host(`app.tenant2.com`)
      kind: Rule
      middlewares:
        - name: staging-security-headers@kubernetescrd
        - name: redirect-web-to-443@internal
      services:
        - name: platform
          port: 3000
          namespace: staging
  tls:
    secretName: platform-cert
---
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
  name: platform-cert
  namespace: staging
  labels:
    "use-http01-solver": "true"
spec:
  commonName: app.tenant1.com
  secretName: platform-cert
  dnsNames:
    - app.tenant1.com
    - app.tenant2.com
  issuerRef:
    name: letsencrypt
    kind: ClusterIssuer

Sorry for the useless post.

Have a good day :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.