I want keep version of all pods (App) in env inside namespace. so i can use them in yaml file to create deployment. or even in ci/cd makes devops easier.
right now developer must set the version in yaml file.
That's about the design principle, and that's the ideal approach to apply for your pipeline.
You don't have to save the exact
version of all your Pods inside the manifest file, just use the latest
or environment-like tag (e.g staging
or production
)
And in your pipeline, you could patch the deployment with the corresponding tag based on your build.
One example of this approach:
kubectl patch deployment $YOUR_DEPLOYMENT_NAME -p "{\"metadata\":{\"labels\":{\"image\":\"$YOUR_BUILD_STAGE-$PIPELINE_ID\"}},\"spec\":{\"revisionHistoryLimit\":2,\"template\":{\"spec\":{\"containers\":[{\"name\":\"$YOUR_CONTAINER_NAME\",\"image\":\"$DOCKER_IMAGE_NAME:$YOUR_BUILD_STAGE-$PIPELINE_ID\"}]}}}}"
If you want to use the environment variables in menifest file or in yaml file you can simply use the kubernetes secrets
& config maps
.
where can store the environment and use them during the deployment.