Resolved: Kubernetes ingress with backend serviceName regex/wildcard or selector


Hi all we have a Flink application with blue-green deployment which we get using the Flink operator.
Flinkk8soperator for Apache Flink. The operator spins up the following three K8s services after a deployment:
my-flinkapp-14hdhsr (Top level service)
The idea is that one of the two among blue green would be active and would have pods (either blue or green).
And a selector to the the active one would be stored in the top level myflinkapp-14hdhsr service with the selector flink-application-version=blue. Or green. As follows:
Labels:  flink-app=my-flinkapp
Annotations:       <none>
Selector:          flink-app=my-flinkapp,flink-application-version=blue,flink-deployment-type=jobmanager,
I have an ingress defined as follows which I want to use to point to the top level service.
apiVersion: extensions/v1beta1
kind: Ingress
  annotations: /$2 |
      proxy_set_header Accept-Encoding "";
      sub_filter '<head>' '<head> <base href="/happy-flink-ui/">'; "true" "https://$host/oauth2/auth" "https://$host/oauth2/start?rd=$escaped_request_uri"
  name: flink-secure-ingress-my-flink-app
  namespace: happy-flink-flink
    - host:
          - path: /happy-flink-ui(/|$)(.*)
              serviceName: my-flinkapp-14hdhsr // This works but....
              servicePort: 8081
The issue I am facing is that the top level service keeps changing the hash at the end as the flink operator changes it at every deployment.. eg. myflinkapp-89hddew .etc.
So I cannot have a static service name in the ingress definition.
So I am wondering if an ingress can choose a service based on a selector or a regular expression of the service name which can account for the top level app service name plus the hash at the end.
The flink-app-hash (i.e the hash part of the service name – 14hdsr) is also part of the Labels in the top level service. Anyway I could leverage that?
Wondering if default backend could be applied here?
Have folks using Flink operator solved this a different way?


Unfortunately that’s not possible OOB to use any kind of regex/wildcards/jsonpath/variables/references inside .backend.serviceName inside Ingres controller. You are able to use regex only in path: Ingress Path Matching
And its not going to be implemented soon: Allow variable references in backend spec is in the hanged stage.
Would be very interesting to hear any possible solution for this. It was previously discussed on stack, however without any progress:

If you have better answer, please add a comment about this, thank you!


If you like this answer, you can give me a coffee by click here (view Ads)