<p>I have installed nginx ingress controller. As I understand that one of the main reasons to use ingress is to save money by not creating multiple load balancers.</p>
<p>My kubesphere-console service yaml manifest looks like below:</p>
<pre><code>cat kubesphere-console.yaml 
apiVersion: v1
kind: Service
metadata:
  annotations:
    meta.helm.sh/release-name: ks-core
    meta.helm.sh/release-namespace: kubesphere-system
  creationTimestamp: &quot;2022-05-30T04:51:22Z&quot;
  finalizers:
  - service.kubernetes.io/load-balancer-cleanup
  labels:
    app: ks-console
    app.kubernetes.io/managed-by: Helm
    tier: frontend
    version: v3.1.0
  name: ks-console
  namespace: kubesphere-system
  resourceVersion: &quot;785863&quot;
  uid: 8628c2d0-164b-499f-ac0c-254ac77aa48c
spec:
  allocateLoadBalancerNodePorts: true
  clusterIP: 10.0.29.29
  clusterIPs:
  - 10.0.29.29
  externalTrafficPolicy: Cluster
  internalTrafficPolicy: Cluster
  ipFamilies:
  - IPv4
  ipFamilyPolicy: SingleStack
  ports:
  - name: nginx
    nodePort: 30880
    port: 80
    protocol: TCP
    targetPort: 8000
  selector:
    app: ks-console
    tier: frontend
  sessionAffinity: None
  type: LoadBalancer
status:
  loadBalancer:
    ingress:
    - ip: 20.248.217.111
</code></pre>
<p>The kubesphere-console ingress route yaml manifest is like below:</p>
<pre><code>cat ingress-route-kubesphere.yaml 
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: kubesphere-console
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;false&quot;
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: ks-console
            port:
              number: 80
      - path: /(.*)
        pathType: Prefix
        backend:
          service:
            name: ks-console
            port:
              number: 80
---
</code></pre>
<p>I created ingress-controller on AKS cluster as like below:</p>
<pre><code>NAMESPACE=ingress-basic

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update

helm install ingress-nginx ingress-nginx/ingress-nginx \
  --create-namespace \
  --namespace $NAMESPACE \
  --set controller.service.annotations.&quot;service\.beta\.kubernetes\.io/azure-load-balancer-health-probe-request-path&quot;=/healthz
</code></pre>
<p>LB created for nginxingress-controller as like below</p>
<pre><code> k get svc -ningress-basic
NAME                                 TYPE           CLUSTER-IP    EXTERNAL-IP    PORT(S)                      AGE
ingress-nginx-controller             LoadBalancer   10.0.194.38   20.92.133.79   80:32703/TCP,443:31053/TCP   23h
ingress-nginx-controller-admission   ClusterIP      10.0.189.8    &lt;none&gt;         443/TCP                      23h
</code></pre>
<p>Kindly do note that I am not that great in Ingress resource/networking so I am still learning. My main intention is use one ingress controller to expose all applications</p>
<p>Example:</p>
<p>Kubesphere-console --&gt; Port 80 and Endpoint should be ksconsole</p>
<p>tekton-pipelines ----&gt; Port 80 and Endpoint should be tekton-dashboard</p>
<p>I shall sincerely appreciate any help.
P.S: I investigated the ingress control pod logs but no luck there or I really don't what they mean....</p>
<pre><code>k logs -f ingress-nginx-controller-6648b5dbb8-ntm8t -ningress-basic

10.240.0.4 - - [02/Jun/2022:12:29:42 +0000] &quot;GET /healthz HTTP/1.1&quot; 302 43 &quot;-&quot; &quot;Load Balancer Agent&quot; 194 0.002 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.000 302 6ea21ca50e247cc5d5e56975c8946fcc
10.240.0.4 - - [02/Jun/2022:12:29:42 +0000] &quot;GET /healthz HTTP/1.1&quot; 302 43 &quot;-&quot; &quot;Load Balancer Agent&quot; 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 1f2e1bfa0223e6b3b630a59fe7dba4d1
10.240.0.4 - - [02/Jun/2022:12:29:48 +0000] &quot;GET /healthz HTTP/1.1&quot; 302 43 &quot;-&quot; &quot;Load Balancer Agent&quot; 194 0.004 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.000 302 dbb5af0fd6426f783c337da06912e427
10.240.0.4 - - [02/Jun/2022:12:29:48 +0000] &quot;GET /healthz HTTP/1.1&quot; 302 43 &quot;-&quot; &quot;Load Balancer Agent&quot; 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 9fc084018c70c0f61f379e2266a056f8
10.240.0.4 - - [02/Jun/2022:12:29:54 +0000] &quot;GET /healthz HTTP/1.1&quot; 302 43 &quot;-&quot; &quot;Load Balancer Agent&quot; 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 f9e4c75d81aa0e7ff03e402dfdca2d35
10.240.0.4 - - [02/Jun/2022:12:29:54 +0000] &quot;GET /healthz HTTP/1.1&quot; 302 43 &quot;-&quot; &quot;Load Balancer Agent&quot; 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.000 302 187cc1fdb0fb1499c1ef040e8aeb5e01
10.240.0.4 - - [02/Jun/2022:12:30:00 +0000] &quot;GET /healthz HTTP/1.1&quot; 302 43 &quot;-&quot; &quot;Load Balancer Agent&quot; 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 9b3b1ae4165184ed16fa974be51cd460
10.240.0.4 - - [02/Jun/2022:12:30:00 +0000] &quot;GET /healthz HTTP/1.1&quot; 302 43 &quot;-&quot; &quot;Load Balancer Agent&quot; 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 eac2591d333af20ab1a3ee4052327291
10.240.0.4 - - [02/Jun/2022:12:30:06 +0000] &quot;GET /healthz HTTP/1.1&quot; 302 43 &quot;-&quot; &quot;Load Balancer Agent&quot; 194 0.004 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.000 302 f08f30018bcfd229adb1ed36b6473563
10.240.0.4 - - [02/Jun/2022:12:30:06 +0000] &quot;GET /healthz HTTP/1.1&quot; 302 43 &quot;-&quot; &quot;Load Balancer Agent&quot; 194 0.002 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.000 302 f157141e253c7fcc61008440ff047605
10.240.0.4 - - [02/Jun/2022:12:30:12 +0000] &quot;GET /healthz HTTP/1.1&quot; 302 43 &quot;-&quot; &quot;Load Balancer Agent&quot; 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 6ba07067e1345b665e16a3cab03ee50c
10.240.0.4 - - [02/Jun/2022:12:30:12 +0000] &quot;GET /healthz HTTP/1.1&quot; 302 43 &quot;-&quot; &quot;Load Balancer Agent&quot; 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 4978c44153381d1aac6bc959c4afa72d
10.240.0.4 - - [02/Jun/2022:12:30:18 +0000] &quot;GET /healthz HTTP/1.1&quot; 302 43 &quot;-&quot; &quot;Load Balancer Agent&quot; 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 fc1e6e7fd4f4219ef6ca38689275035a
10.240.0.4 - - [02/Jun/2022:12:30:18 +0000] &quot;GET /healthz HTTP/1.1&quot; 302 43 &quot;-&quot; &quot;Load Balancer Agent&quot; 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.000 302 1e286ef7a2b36a5b04521e59657e0433

</code></pre>

hungrylearnerbenicewithme
<p>Usually, you can access your services directly through the external IP (wildcard) of the ingress-controller svc if you create an ingress without a specified host. You can set a domain name for the ingress after configuring DNS resolution correctly.</p>
<p>Here is an example of exposing both <code>ks-apiserver</code> and <code>ks-console</code> through nginx-ingress-controller.</p>
<p>nginx controller svc</p>
<pre><code>root@master:~# kubectl -n ingress-nginx get svc
NAME                                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
ingress-nginx-controller             NodePort    10.233.11.24    &lt;none&gt;        80:30882/TCP,443:31054/TCP   15m
ingress-nginx-controller-admission   ClusterIP   10.233.18.191   &lt;none&gt;        443/TCP                      37m
</code></pre>
<p>ingress of <code>ks-apiserver</code> and <code>ks-console</code></p>
<pre><code>root@master:~# kubectl -n kubesphere-system get ing api -o yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    kubesphere.io/creator: admin
  creationTimestamp: &quot;2022-06-02T08:48:48Z&quot;
  generation: 8
  name: kubesphere
  namespace: kubesphere-system
  resourceVersion: &quot;982261&quot;
  uid: f8f6cadf-874c-4996-8759-3467ac33d61c
spec:
  ingressClassName: nginx
  rules:
  - host: api.172.31.50.170.nip.io
    http:
      paths:
      - backend:
          service:
            name: ks-apiserver
            port:
              number: 80
        path: /
        pathType: ImplementationSpecific
  - host: console.172.31.50.170.nip.io
    http:
      paths:
      - backend:
          service:
            name: ks-console
            port:
              number: 80
        path: /
        pathType: ImplementationSpecific
status:
  loadBalancer:
    ingress:
    - ip: 172.31.50.170
</code></pre>
<p>Verify the ingresses</p>
<pre><code>$ curl http://api.172.31.50.170.nip.io:30882/
{
  &quot;kind&quot;: &quot;Status&quot;,
  &quot;apiVersion&quot;: &quot;v1&quot;,
  &quot;metadata&quot;: {

  },
  &quot;status&quot;: &quot;Failure&quot;,
  &quot;message&quot;: &quot;forbidden: User \&quot;system:anonymous\&quot; cannot GET path \&quot;/\&quot;&quot;,
  &quot;reason&quot;: &quot;Forbidden&quot;,
  &quot;details&quot;: {

  },
  &quot;code&quot;: 403
}%
$ curl http://console.172.31.50.170.nip.io:30882/
Redirecting to &lt;a href=&quot;/login&quot;&gt;/login&lt;/a&gt;.%
</code></pre>
