title: How to patch a deployed Ingress resource on Kubernetes?
body: <p>I have the following Ingress resource:</p>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: main-ingress
    annotations:
      kubernetes.io/ingress.class: nginx
      nginx.ingress.kubernetes.io/ssl-redirect: "false"
      nginx.ingress.kubernetes.io/force-ssl-redirect: "false"
      nginx.ingress.kubernetes.io/proxy-read-timeout: "86400"
      nginx.ingress.kubernetes.io/proxy-send-timeout: "86400"
  
  spec:
    tls:
    - secretName: the-secret
      hosts:
        - sample.domain.com
        - sample2.domain.com
        - rabbit.domain.com
        - hub.domain.com
        - grafana.domain.com
  
    rules:
  
    - host: sample.domain.com
      http:
        paths:
        - path: /
          backend:
            serviceName: fe-srvc
            servicePort: 80
        - path: /api
          backend:
            serviceName: be-srvc
            servicePort: 80
  
    - host: sample2.domain.com
      http:
        paths:
        - path: /
          backend:
            serviceName: fe2-srvc
            servicePort: 80
        - path: /api
          backend:
            serviceName: be-srvc
            servicePort: 80
  
  ## The Extra Services ###
    - host: rabbit.domain.com
      http:
        paths:
        - path: /
          backend:
            serviceName: rabbitmq-srvc
            servicePort: 80
  </code></pre>
  
  <p>and I want to patch it after it is deployed.</p>
  
  <p>So I use this, to try and replace the <code>be-srvc</code> value with <code>some-srvc</code> :</p>
  
  <pre><code>kubectl patch ing/main-ingress --patch '{ "spec" : { "rules": [{"http":{"paths":[ {"- path":"/"},{"backend":{"serviceName":"other-srvc"}},{"servicePort":"80"} ] }}]}}'
  </code></pre>
  
  <p>and I get this error:</p>
  
  <pre><code>The Ingress "main-ingress" is invalid:
  * spec.rules[0].http.backend.serviceName: Required value
  * spec.rules[0].http.backend.servicePort: Invalid value: 0: must be between 1 and 65535, inclusive
  </code></pre>
  
  <p>Any insight would be appreciated!</p>