How can I update all ingress rules comments using kubectl?

3/1/2019

Good morning,

I have a k8s cluster where multiple ingress services share a pre generated self managed certificate in GCP.

My problem is that when the certificate expires, I need to update the yaml file with the name of the new cert and apply the modified yaml file for each of the ingress to update the certs. We do it, updating the environment variable and redeploying the application. I was thinking in a better way to do it that will not require to redeploy it, I was planning to use kubectl patch to do this, anyone has already have to done something similar?

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    ingress.gcp.kubernetes.io/pre-shared-cert: cert-abc
    ingress.kubernetes.io/forwarding-rule: fwd-abc
    ingress.kubernetes.io/https-forwarding-rule: https-fwd-abc
    ingress.kubernetes.io/https-target-proxy: tgt-https-abc
    ingress.kubernetes.io/ssl-cert: cert-abc
    ingress.kubernetes.io/static-ip: ip-abc
    ingress.kubernetes.io/target-proxy: tgt-http-abc
    ingress.kubernetes.io/url-map: lb-abc
    kubernetes.io/ingress.global-static-ip-name: sta-ip-abc
  creationTimestamp: 2019-01-29T22:38:10Z
  generation: 2
  name: abc-ingress
  namespace: abc  
spec:
  backend:
    serviceName: abc
    servicePort: 80

Thanks in advance for your help.

-- Eduardo Ruela
google-cloud-platform
google-kubernetes-engine
kubernetes

1 Answer

3/2/2019

We have similar challenges. kubectl apply works fine here as Hernan Garcia already pointed out.

A patch can do the same trick.

Our choice in fact way using helm which is quite easy to use and which makes it quite easy to update selectively values. Furthermore you have the option to rollback if something goes wrong, which is nice for automated deployments.

-- Randy
Source: StackOverflow