Dynamic wildcard subdomain login for Kubernetes

I am currently using Kubernetes on GKE to serve different parts of my product on different Ingress subdomains. For example: api.mydomain.com

, console.mydomain.com

etc.

ingress.yml (current) :

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
spec:
  rules:
  - host: api.mydomain.com
    http:
      paths:
        - backend:
            serviceName: api-service
            servicePort: 80
  - host: console.mydomain.com
    http:
      paths:
        - backend:
            serviceName: console-service
            servicePort: 80

      

This works great with routing the L7 GCE to the appropriate locations. However, I would like to be able to deploy multiple deployments with feature-branching as subdomains for testing and demoing new features before going into production. It could be something like new-stylesheet.console.mydomain.com

or upgraded-algorithm.api.mydomain.com

, inspired by GitLab CI environments .

Here's a potential workflow for each deployment:

  • Create function-api-deployment.yml
  • Create function-api-service.yml
  • Update ingress.yml with new subdomain rule: feature.api.mydomain.com

    directionserviceName: feature-api-service

But listing and maintaining all subdomain-> service mappings would be messy with breaking deployments and creating a ton of GCE backends (the default quota is 5 ...) so it's not ideal.

Is there anything about Kubernete that I don't notice to handle this? Something like this is perfect for targeting a service based on a consistent subdomain:

ingress.yml (required)

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
spec:
  rules:
  - host: *.api.mydomain.com
    http:
      paths:
        - backend:
            serviceName: {value of *}-api-service
            servicePort: 80

      

+3


source to share


1 answer


Kubernetes, of course, don't have anything like wildcard domains, but you might want to use Helm

With slam you can modify templates inside your manifests so you can have your branch name in hand a values ​​file



From there you can use gitlab-ci to set the helm in the build pipeline, and if you set up your diagram correctly, you can specify the helse argument to the pipeline name.

There's a great blog post about this kind of workflow here - hopefully this helps you when you need to go.

+1


source







All Articles