<p>Im have <code>k8s</code> app (Web api) which first exposed via <code>NodePort</code> (I've used port forwarding to run it and it works as expected)  </p>

<p>run it like <code>localhost:8080/api/v1/users</code></p>

<p>Than I've created a <code>service</code> with type <code>LoadBalancer</code> to expose it outside, which <strong>works as expected</strong>. </p>

<p>e.g. <code>http://myhost:8080/api/v1/users</code></p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: fzr
  labels:
    app: fzr
    tier: service
spec:
  type: LoadBalancer
  ports:
    - port: 8080
  selector:
    app: fzr
</code></pre>

<p>Now we need to make it <code>secure</code> and after reading about this topic we have decided to use <strong>ingress</strong> for it.</p>

<p>This is what I did </p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ctr-ingress
  selector:
    app: fzr
spec:
  ports:
    - name: https
      port: 443
      targetPort: https
</code></pre>

<p>now I want to run it like</p>

<p><code>https://myhost:443/api/v1/users</code></p>

<p>This is <strong>not working</strong>, im not able to run the application with port <code>443</code> as <code>https</code>, please advice? </p>

Jenny M
<p>It looks to me like you are using a yaml template for a type service to deploy your ingress but not correctly.  <code>targetPort</code> should be a numeric port, and anyway, I don't think "https" is a correct value (I might be wrong though).  </p>

<p>Something like this:</p>

<pre><code>apiVersion: v1
kind: Service
type: NodePort
metadata:
  name: fzr-ingress
spec:
  type: NodePort
  selector:
    app: fzr
  ports:
  - protocol: TCP
    port: 443
    targetPort: 8080
</code></pre>

<p>Now you have a nodeport service listening on 443 and forwarding the traffic to your fzr pods listening on port 8080.  </p>

<p>However, the fact you are listening on port 443 does nothing to secure your app by itself. To encrypt the traffic you need a TLS certificate that you have to make available to the ingress as a <code>secret</code>.  </p>

<p>If this seems somewhat complicated (because it is) you could look into deploying an Nginx ingress from a <a href="https://github.com/helm/charts/tree/master/stable/nginx-ingress" rel="nofollow noreferrer">helm chart</a></p>

<p>In any case your ingress yaml would look something like this:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
  name: gcs-ingress
  namespace: default
spec:
  rules:
  - host: myhost
    http:
      paths:
      - backend:
          serviceName: fzr
          servicePort: 443
        path: /api/v1/users
  tls:
  - hosts:
    - myhost
    secretName: myhosts-tls
</code></pre>

<p>More info on how to configure this <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#tls" rel="nofollow noreferrer">here</a></p>
