0

I have a service that running nginx and some web app. k8s deploy manifest looks like:

kind: Service
...
...  
- port: 443
  targetPort: 30443
  protocol: TCP
  name: https
...
---

kind: Deployment
...
...
- containerPort: 443
  hostIP: my ip
  hostPort: 30443
  protocol: TCP

It works fine when I access it by https://ip:port or https://server_domain_name:port, but how can I set up nginx-ingress to get rid of port number and access it just by https://server_domain_name?

I've tried to search config examples like this one:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-service
            port:
              number: 443

but it's not working

1 Answer 1

0

Having your services defined correctly, something like below may assist you.

Note: please note that my cluster is running on old version and the apiVersion has been deprecated. You need to check and update the version accordingly to your cluster version.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
spec:
  rules:
  - host: domain1.com
    http:
      paths:
      - backend:
          serviceName: domain1-store-service
          servicePort: 80
  - host: domain2.com
    http:
      paths:
      - backend:
          serviceName: domain2-video-service
          servicePort: 80

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .