NelsonVasu
NelsonVasu

Reputation: 63

Creating ingress resource

How do I create an ingress(ping) to expose a single service(hello) given a path (/hello )and a port (6789) in a given namespace (dev)?

the following is right? Also how to verify the same?

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ping
  namespace: dev
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - path: /hello
        pathType: Prefix
        backend:
          service:
            name: hello
            port:
              number: 6789

Upvotes: 1

Views: 527

Answers (1)

Harsh Manvar
Harsh Manvar

Reputation: 30113

You might need to add the host into the ingress YAML if you are looking forward to use the domain for resolution like

hello-world.info forward the traffic to hello service.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
    - host: hello-world.info
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: web
                port:
                  number: 8080

to verify the changes you can use the Curl to check and test the endpoint also.

Once your YAML file is applied and ingress is created on cluster you can hit the endpoint and verify.

i would recommend checking out the part test your ingress :

https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/#test-your-ingress

Upvotes: 1

Related Questions