<p>Hi all we have a Flink application with blue-green deployment which we get using the Flink operator.</p>
<p><a href="https://github.com/lyft/flinkk8soperator" rel="nofollow noreferrer">Flinkk8soperator</a> for Apache Flink. The operator spins up the following three K8s services after a deployment:</p>
<pre><code>my-flinkapp-14hdhsr (Top level service)
my-flinkapp-green
my-flinkapp-blue
</code></pre>
<p>The idea is that one of the two among blue green would be active and would have pods (either blue or green).</p>
<p>And a selector to the the active one would be stored in the top level <code>myflinkapp-14hdhsr</code> service with the selector <code>flink-application-version=blue</code>. Or green. As follows:</p>
<pre><code>Labels:  flink-app=my-flinkapp
         flink-app-hash=14hdhsr
         flink-application-version=blue
Annotations:       &lt;none&gt;
Selector:          flink-app=my-flinkapp,flink-application-version=blue,flink-deployment-type=jobmanager,
</code></pre>
<p>I have an ingress defined as follows which I want to use to point to the top level service.</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_set_header Accept-Encoding &quot;&quot;;
      sub_filter '&lt;head&gt;' '&lt;head&gt; &lt;base href=&quot;/happy-flink-ui/&quot;&gt;';
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
    nginx.ingress.kubernetes.io/auth-url: &quot;https://$host/oauth2/auth&quot;
    nginx.ingress.kubernetes.io/auth-signin: &quot;https://$host/oauth2/start?rd=$escaped_request_uri&quot;
  name: flink-secure-ingress-my-flink-app
  namespace: happy-flink-flink
spec:
  rules:
    - host: flinkui-myapp.foo.com
      http:
        paths:
          - path: /happy-flink-ui(/|$)(.*)
            backend:
              serviceName: my-flinkapp-14hdhsr // This works but....
              servicePort: 8081
</code></pre>
<p>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.</p>
<p>So I cannot have a static service name in the ingress definition.</p>
<p>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.</p>
<p>The <code>flink-app-hash</code> (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?</p>
<p>Wondering if default backend could be applied here?</p>
<p>Have folks using Flink operator solved this a different way?</p>

Ace McCloud
<p>Unfortunately that's not possible OOB to use any kind of <code>regex/wildcards/jsonpath/variables/references</code> inside <code>.backend.serviceName</code> inside Ingres controller.
You are able to use regex only in <code>path</code>: <a href="https://kubernetes.github.io/ingress-nginx/user-guide/ingress-path-matching/" rel="nofollow noreferrer">Ingress Path Matching</a></p>
<p>And its not going to be implemented soon: <a href="https://github.com/kubernetes/ingress-nginx/issues/7739" rel="nofollow noreferrer">Allow variable references in backend spec</a> is in the hanged stage.</p>
<p>Would be very interesting to hear any possible solution for this. It was previously discussed on stack, however without any progress: <a href="https://stackoverflow.com/a/60810435/9929015">https://stackoverflow.com/a/60810435/9929015</a></p>
