This example uses kubetruth to apply a kubernetes deployment whenever dependent parameters change (e.g. image_version
)
It provides 2 variants:
values-simple.yaml
: The deployment templates are fairly simple and hosted within the cloudtruth templating system (deploy.yaml.tmpl
). Sharing of templates across multiple projects has not yet been implemented in the cloudtruth engine, so this method is not very modular and you'll have to fully define the deployment template for each project. However, it is a lot easier to grokvalues-modular.yaml
: The deployment templates are defined within kubetruth and as such can be reused across multiple projects, as well as setting up the metadata to make use of the kubetruth ability to apply to multiple namespaces/environments within the same cluster
If you set this up within your own infrastructure, then you can easily deploy from CI after test/build by running the cloudtruth cli to set the new version.
Login to CloudTruth, and create an api key, then add it to your environment
export CLOUDTRUTH_API_KEY=your_api_key
cloudtruth projects set deploytest
cloudtruth --project deploytest parameter set --value nginx app_name
cloudtruth --project deploytest parameter set --value 80 app_port
cloudtruth --project deploytest parameter set --value nginx image_name
cloudtruth --project deploytest parameter set --value 1.20 image_version
# Only needed when using the values-simple.yaml variant
cloudtruth --project deploytest template set --body examples/deployment/deploy.yaml.tmpl deployment
(Optional) Setup minikube to test locally
minikube start
To try the simple variant, install kubetruth with the following settings:
helm install --values examples/deployment/values-simple.yaml --set appSettings.apiKey=$CLOUDTRUTH_API_KEY kubetruth cloudtruth/kubetruth
OR to try the modular variant, install kubetruth like:
helm install --values examples/deployment/values-modular.yaml --set appSettings.apiKey=$CLOUDTRUTH_API_KEY kubetruth cloudtruth/kubetruth
kubectl describe deployment kubetruth
kubectl logs deployment/kubetruth
kubectl describe deployment nginx | grep -i image
minikube service nginx # force a 404 to see nginx version string
cloudtruth --project deploytest parameter set --value 1.21 image_version
kubectl describe deployment nginx | grep -i image
minikube service nginx # force a 404 to see nginx version string