yq replace value in manifest yaml
I have a k8s manifest file for loadbalancer below and cannot for the life of me get the $ipaddress be replaced with value, I have got to to overwrite whole file or part of or even just leave blank. How can I replace only the $ipaddress like in below
Tried as example 2 below:
yq e '.spec|=select(.loadBalancerIP) .ports.port = "172.16.87.98"' manifest.yaml yq e -i '(.spec|=select(.loadBalancerIP.$ipaddress) = "172.16.87.98"' manifest.yaml
apiVersion: v1
kind: Service
metadata:
name: my-lb-cluster
spec:
loadBalancerIP: $ipaddress
ports:
- name: ssl
port: 8080
selector:
role: webserver
sessionAffinity: None
type: LoadBalancer
Solution 1:
If the YAML is as simple as in your question, you can use:
yq e -i '.spec.loadBalancerIP = "172.16.87.98"' manifest.yaml
To update manifest.yaml
and set .loadBalancerIP
inside .spec
to "172.16.87.98"