<p>I have set up a baremetal k8 cluster ( 1 master node - intel NUC &amp; 2 worker nodes on Raspberry pi). I managed to set up a metal-lb load balance and nginx ingress controller.  I have launched two applications, ghost (listens on default port 2368) and nextcloud ( listens on default port 80) .  I'm trying to access the applications from public ip myhomeserver.io ( to access the ghost application) and nextcloud.myhomeserver.io ( to access the next cloud application). I can access the ghost application but I can't seem to access nextcloud.Given below are the yaml files for ingress and services. Not sure where am I going wrong.</p>

<pre><code>kubectl get services --all-namespaces
NAMESPACE       NAME                TYPE           CLUSTER-IP       EXTERNAL-IP       PORT(S)                      AGE
default         kubernetes          ClusterIP      10.96.0.1        &lt;none&gt;            443/TCP                      98d
ghost           ghost-service       ClusterIP      10.107.116.108   &lt;none&gt;            2368/TCP                     7h37m
ingress-nginx   ingress-nginx       LoadBalancer   10.109.177.223   192.168.178.200   80:31619/TCP,443:30365/TCP   7d23h
kube-system     kube-dns            ClusterIP      10.96.0.10       &lt;none&gt;            53/UDP,53/TCP,9153/TCP       98d
nextcloud       nextcloud-service   ClusterIP      10.105.24.162    &lt;none&gt;            8080/TCP                     137m

=============================================================================================================================
NAMESPACE   NAME                HOSTS                       ADDRESS           PORTS   AGE
ghost       ingress-ghost       myhomeserver.io             192.168.178.200   80      7d22h
nextcloud   ingress-nextcloud   nextcloud.myhomeserver.io   192.168.178.200   80      140m


=============================================================================================================================
cat ingress-object-ghost.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-ghost
  namespace: ghost

spec:
  rules:
  - host: myhomeserver.io
    http:
      paths:
      - backend:
          serviceName: ghost-service
          servicePort: 2368


=============================================================================================================================
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-nextcloud
  namespace: nextcloud

spec:
  rules:
  - host: nextcloud.myhomeserver.io
    http:
      paths:
      - backend:
          serviceName: nextcloud-service
          servicePort: 8080

================================================================================================================================

cat ingress-object-nextcloud.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-nextcloud
  namespace: nextcloud

spec:
  rules:
  - host: nextcloud.myhomeserver.io
    http:
      paths:
      - backend:
          serviceName: nextcloud-service
          servicePort: 8080
===================================================================================
apiVersion: apps/v1

kind: Deployment
metadata:
  name:
    deployment-nextcloud
  namespace: nextcloud
  labels:
    env: prod
    app: nextcloud-app

spec:
  template:
    metadata:
      name: nextcloud-app-pod
      labels:
        app:  nextcloud-app
        env:  production
    spec:
      containers:
        - name: nextcloud
          image: arm32v7/nextcloud
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 8080
          volumeMounts:
           - mountPath: /var/www/html
             name: nextcloud-data
          securityContext:
            privileged: True


      volumes:
      - name: nextcloud-data
        persistentVolumeClaim:
          claimName: pvc-nextcloud
      nodeSelector:
        kubernetes.io/arch: arm

  replicas: 2
  selector:
    matchLabels:
      app: nextcloud-app


================================================================================================================
apiVersion: v1
kind: Service
metadata:
  name: nextcloud-service
  namespace: nextcloud
  labels:
    app: nextcloud-app
spec:
  type: ClusterIP
  selector:
    app: nextcloud-app
  ports:
  - port: 8080
    targetPort: 8080
    protocol: TCP
</code></pre>

IT_novice
<p>Note your nginx ingress controller is running in the ghost namespace so it only knows about the ghost service. You need to have another ingress controller for your nextcloud namespace if you want to have an ingress there. If you don't want another ingress controller then you can resolve the nextcloud service by targeting its dns in the following way <code>servicename.namespacename.svc.cluster.local</code></p>

<p>On a side, there is not really a point in dividing your applications that much. Kubernetes already gives you enough privacy among applications in the same namespace.</p>

<p><strong>UPDATE</strong><br>
Ingress that works for you given you have only <code>1 INGRESS CONTROLLER</code>. Since there are two services I have added a path rule which will be rewritten to <code>/</code> so each service will receive a clean URI. Use <code>myhomeserver.io/ghost</code> to reach <code>ghost</code> and <code>myhomeserver.io/nextcloud</code> to reach nextcloud.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-ghost
  namespace: ghost
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: myhomeserver.io
    http:
      paths:
      - path: /ghost
        backend:
          serviceName: ghost-service
          servicePort: 2368
      - path: /nextcloud
        backend:
          serviceName: nextcloud-service.nextcloud.svc.cluster.local
          servicePort: 8080
</code></pre>

<p><strong>UPDATE 2</strong>
So your <code>ingress controller</code> is running in the ghost namespace. Thus, your  ingress <strong>has to be deployed in the ghost namespace.</strong> Note the http rules for each host. </p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-ghost
  namespace: ghost
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: myhomeserver.io
    http:
      paths:
      - path: /
        backend:
          serviceName: ghost-service
          servicePort: 2368
  - host: nextcloud.myhomeserver.io
    http:
      - path: /
        backend:
          serviceName: nextcloud-service.nextcloud.svc.cluster.local
          servicePort: 8080
</code></pre>
