This repo demonstrates all the four ways environment variables could be set as described in the blog post here.
This example assumes the following:
- You have an existing Kubernetes cluster.
- You have a basic understanding of Kubernetes Pods, Secrets, and ConfigMaps.
Run make
to create all the resoures required in this demo.
Run make check
to show the following output:
app: Pizza = Flour + Cheese + Tomato
This indicates that the service running in the pod has appropriately extracted:
- app from the name field of the Pod specs
- Pizza from the string literal defined for MEAL environment variable in the Pod specs
- Flour from key-value pair defined in the env-app-config ConfigMap
- Cheese from the value of the ingredient key defined in the app-config ConfigMap
- Tomato from the value of the ingredient key defined in the app-secret Secret
Run make clean
to delete all resources created in this demo.
MIT License
Copyright (c) 2019 C A Boadu Jnr
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.