<p>Here's the thing. I installed a kubernetes cluster on my jelastic account like this:</p>

<p><a href="https://i.stack.imgur.com/yKGHm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yKGHm.png" alt="enter image description here"></a></p>

<p>Then, I wanted to expose a service to the outside of the cluster. The HelloWorld is working out-of-the-box on the cluster, so I thought I could transform it to my needs easily. Upon cluster installation, browsing</p>

<pre><code>my-helloworld-test.my-jelastic-provider.com
</code></pre>

<p>works perfectly fine, i.e. I see the hello world html page with styling.</p>

<p>Now, in my future use-cases, I will want to access my services through</p>

<pre><code>my-helloworld-test.my-jelastic-provider.com/hello
</code></pre>

<p>or</p>

<pre><code>hello.my-helloworld-test.my-jelastic-provider.com
</code></pre>

<p>i.e. I'd like to setup a path for my service or a subdomain. I gathered I need to define an Ingress to make that happen. I've changed the <code>hello-kubernetes</code> service configuration to this:</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: hello-kubernetes
  namespace: default
spec:
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
  selector:
    app: hello-kubernetes
  type: ClusterIP
  sessionAffinity: None
  externalTrafficPolicy: Cluster
</code></pre>

<h2>Path to service</h2>

<p>I tried following ingress configuration to define a path to my service:</p>

<pre><code>kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: helloworld
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/ssl-redirect: 'false'
spec:
  rules:
    - http:
        paths:
          - path: /hello
            backend:
              serviceName: hello-kubernetes
              servicePort: 80
</code></pre>

<p>The goal is that browsing</p>

<pre><code>my-helloworld-test.my-jelastic-provider.com/hello
</code></pre>

<p>displays the pre-deployed helloworld application, instead of</p>

<pre><code>my-helloworld-test.my-jelastic-provider.com
</code></pre>

<p>I could write the helloworld application in such a way that its base url be <code>/hello</code>, but I learned from several blogs that it is possible to let that happen with kubernetes annotations. In particular, it seems like annotation <code>nginx.ingress.kubernetes.io/rewrite-target</code> would help, but I was not able to make it happen completely. Indeed, the above configuration shows me the helloworld application when I browse the <code>/hello</code> path, but unstyled:</p>

<p><a href="https://i.stack.imgur.com/YQDuL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YQDuL.png" alt="enter image description here"></a></p>

<p>How can I make the styling happen?</p>

<h2>Subdomain to service</h2>

<p>Another sexy possibility for that service would be to be displayed upon browsing</p>

<pre><code>hello.my-helloworld-test.my-jelastic-provider.com
</code></pre>

<p>i.e. as a subdomain of my jelastic environment. I've tried this configuration without success:</p>

<pre><code>kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: jenkins
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: 'false'
spec:
  rules:
    - http:
        paths:
          - host: hello.my-helloworld-test.my-jelastic-provider.com
            path: /
            backend:
              serviceName: hello-kubernetes
              servicePort: 80
</code></pre>

<p>What do I need to do to my jelastic environment so that the above host be browsable and exhibits the helloworld application?</p>

<h2>Kubernetes configuration</h2>

<pre><code>Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.6", GitCommit:"7015f71e75f670eb9e7ebd4b5749639d42e20079", GitTreeState:"archive", BuildDate:"2019-11-19T09:00:01Z", GoVersion:"go1.12.12", Co
mpiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.6", GitCommit:"7015f71e75f670eb9e7ebd4b5749639d42e20079", GitTreeState:"archive", BuildDate:"2019-11-19T08:45:41Z", GoVersion:"go1.12.12", Co
mpiler:"gc", Platform:"linux/amd64"}
</code></pre>

<p>on jelastic v.5.7.</p>

Laurent Michel
<p>Looks like there are 2 separate issues atm</p>

<ol>
<li>Are you sure that domain
hello.my-helloworld-test.my-jelastic-provider.com is following to a
correct IP? It is possible to add custom subdomains to the
environment, then use them for ingress rules, but that option
(custom subdomains) is now available through the <a href="https://docs.jelastic.com/api/#!/api/environment.Binder-method-AddDomains" rel="nofollow noreferrer">API</a> only </li>
<li>Incorrect annotation argument for nginx.ingress.kubernetes.io/rewrite-target, if you use nginx ingress controller try this one</li>
</ol>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: helloworld
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/ssl-redirect: 'false'
spec:
  rules:
    - http:
        paths:
          - path: /hello(/|$)(.*)
            backend:
              serviceName: hello-kubernetes
              servicePort: 80</code></pre>
</div>
</div>
</p>

<p><strong>UPD:</strong> 
We have additionally checked the issue together with Laurent Michel and discovered that problem was caused by absolute URIs in application so rewrite was not applied to CSS/images. Simplest solution - apply two ingress rules with different annotations (one with rewrite and one without). More advanced and correct way to go - shift such applications to separate subdomains so URIs could remain the same.</p>
