Add rules to the ingress

how to add new http rules to ingress, without deleting or affecting old rules in the ingress

Can you provide an example of what you’re referring to?

As far as I’m aware, you would just apply the updated configuration.

So lets say you created this file named example-com.yaml and applied it via kubectl apply -f example-com.yaml (or used “create”).

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress-route
spec:
  rules:
  - host: example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: main-application-svc
            port:
              number: 80

What you would do from here is update example-com.yaml like so.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress-route
spec:
  rules:
  - host: example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: main-application-svc
            port:
              number: 80

      - path: /other-thing/
        pathType: Prefix
        backend:
          service:
            name: other-thing-svc
            port:
              number: 80

After which you would run kubectl apply -f example-com.yaml to update it.

1 Like