Score:0

Assign domain name to kubernetes pod

cn flag

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

Score:0
us flag

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
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.