This example uses kubetruth to patch a kubernetes deployment whenever dependent parameters change
Login to CloudTruth, and create an api key, then add it to your environment
export CLOUDTRUTH_API_KEY=your_api_key
(Optional) Setup minikube to test locally
minikube start
kubectl apply -f examples/deploymentpatch/deployment.yaml
kubectl describe deployment deploypatchtest
kubectl get deployment/deploypatchtest -o yaml | grep -A2 envFrom:
kubectl exec deployment/deploypatchtest -- printenv | grep MY_ENV
cloudtruth projects set deploypatchtest
cloudtruth --project deploypatchtest parameter set --value "Hello from patch" MY_ENV_HELLO
cloudtruth --project deploypatchtest parameter set --value "Goodbye from patch" MY_ENV_GOODBYE
Install kubetruth with the settings that enable deployment patching:
helm install --values examples/deploymentpatch/values.yaml --set appSettings.apiKey=$CLOUDTRUTH_API_KEY kubetruth cloudtruth/kubetruth
kubectl describe deployment kubetruth
kubectl logs deployment/kubetruth
Note that you can ignore the warning:
Skipping 'default:Deployment:deploypatchtest' as it doesn't have a label indicating it is under kubetruth management
This is expected as kubetruth won't touch any resources that it didn't create unless they are labelled like we do in the next step.
kubectl label deployment/deploypatchtest app.kubernetes.io/managed-by=kubetruth
kubectl exec deployment/kubetruth -- wakeup
kubectl get deployment/deploypatchtest -o yaml | grep -A2 envFrom:
kubectl exec deployment/deploypatchtest -- printenv | grep MY_ENV
cloudtruth --project deploypatchtest parameter set --value "A New Hello from patch" MY_ENV_HELLO
kubectl exec deployment/kubetruth -- wakeup
kubectl get deployment/deploypatchtest -o yaml | grep -A2 envFrom:
kubectl exec deployment/deploypatchtest -- printenv | grep MY_ENV