<p>I have a k8s cluster where I deploy some containers.</p>
<p>The cluster is accessible at microk8s.hostname.internal.</p>
<p>At this moment I have an application/container deployed that is accessible here: microk8s.hostname.internal/myapplication with the help of a service and an ingress.</p>
<p>And this works great.</p>
<p>Now I would like to deploy another application/container but I would like it accessible like this: otherapplication.microk8s.hostname.internal.</p>
<p>How do I do this?</p>
<p>Currently installed addons in microk8s:</p>
<pre><code>aasa@bolsrv0891:/snap/bin$ microk8s status
microk8s is running
high-availability: no
addons:
  enabled:
    dashboard            # (core) The Kubernetes dashboard
    dns                  # (core) CoreDNS
    helm                 # (core) Helm - the package manager for Kubernetes
    helm3                # (core) Helm 3 - the package manager for Kubernetes
    ingress              # (core) Ingress controller for external access
    metrics-server       # (core) K8s Metrics Server for API access to service metrics
</code></pre>
<p>Update 1:
If I portforward to my service it works.
I have tried this ingress:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minimal-ingress
  namespace: jupyter-notebook
  annotations:
    kubernetes.io/ingress.class: public
spec:
  rules:
  - host: jupyter.microk8s.hostname.internal
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: jupyter-service
            port:
              number: 7070
</code></pre>
<p>But I cant access it nor ping it. Chrome says:
jupyter.microk8s.hostname.internal’s server IP address could not be found.</p>
<p>My service looks like this:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: jupyter-service
  namespace: jupyter-notebook
spec:
  ports:
  - name: 7070-8888
    port: 7070
    protocol: TCP
    targetPort: 8888
  selector:
    app: jupyternotebook
  type: ClusterIP
status:
  loadBalancer: {}
</code></pre>
<p>I can of course ping microk8s.hostname.internal.</p>
<p>Update 2:</p>
<p>The ingress that is working today that has a context path: microk8s.boliden.internal/myapplication looks like this:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: public
    nginx.ingress.kubernetes.io/rewrite-target: /$1
  name: jupyter-ingress
  namespace: jupyter-notebook
spec:
  rules:
    - http:
        paths:
          - path: &quot;/jupyter-notebook/?(.*)&quot;
            pathType: Prefix
            backend:
              service:
                name: jupyter-service
                port:
                  number: 7070
</code></pre>
<p>This is accessible externally by accessing microk8s.hostname.internal/jupyter-notebook.</p>

Viktor Eriksson
<p>To do this you would have to configure a kube service, kube ingress and the configure your DNS.</p>
<p>Adding an entry into the <code>hosts</code> file would allow DNS resolution to <code>otherapplication.microk8s.hostname.internal</code></p>
<p>You could use <code>dnsmasq</code> to allow for wildcard resolution e.g. <code>*.microk8s.hostname.internal</code></p>
<p>You can test the dns reoslution using <code>nslookup</code> or <code>dig</code></p>
