Difference between revisions of "Helm diff"
Jump to navigation
Jump to search
Line 20: | Line 20: | ||
https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release | https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release | ||
+ | |||
+ | ``` | ||
+ | #!/bin/bash | ||
+ | set -e | ||
+ | # helm plugin install https://github.com/databus23/helm-diff | ||
+ | # helm repo add external-secrets https://charts.external-secrets.io | ||
+ | |||
+ | kubectl create namespace external-secrets --dry-run=client -o yaml | kubectl apply -f - | ||
+ | |||
+ | helm_cmd(){ | ||
+ | echo "Running helm $1 upgrade." | ||
+ | helm $1 upgrade --install external-secrets \ | ||
+ | external-secrets/external-secrets \ | ||
+ | -n external-secrets \ | ||
+ | --set installCRDs=true | ||
+ | } | ||
+ | |||
+ | lines=$(helm_cmd diff) | ||
+ | if [[ $(echo $lines | wc -l) > 0 ]]; then | ||
+ | echo "$lines" | grep "^+\|^-" | ||
+ | echo "Helm changes detected." | ||
+ | echo "Running helm upgrade in 5."; sleep 5 | ||
+ | helm_cmd | ||
+ | fi | ||
+ | ``` |
Revision as of 19:26, 6 January 2023
This is a great plugin for helm.
helm plugin install https://github.com/databus23/helm-diff
helm diff upgrade -n mynamespace myapp foo/myapp -f custom-values.yaml
You could use it like so
#!/bin/bash lines=$(helm diff upgrade -n mynamespace myapp foo/myapp -f custom-values.yaml) if [[ $(echo $lines | wc -l) > 0 ]]; then echo "$lines" | grep "^+\|^-" echo "Helm changes detected." echo "Running upgrade in 5."; sleep 5 helm upgrade --install -n mynamespace myapp foo/myapp -f custom-values.yaml fi
You can use terraform helm provider as well.
https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release
#!/bin/bash set -e # helm plugin install https://github.com/databus23/helm-diff # helm repo add external-secrets https://charts.external-secrets.io kubectl create namespace external-secrets --dry-run=client -o yaml | kubectl apply -f - helm_cmd(){ echo "Running helm $1 upgrade." helm $1 upgrade --install external-secrets \ external-secrets/external-secrets \ -n external-secrets \ --set installCRDs=true } lines=$(helm_cmd diff) if [[ $(echo $lines | wc -l) > 0 ]]; then echo "$lines" | grep "^+\|^-" echo "Helm changes detected." echo "Running helm upgrade in 5."; sleep 5 helm_cmd fi