is there a way to use variables to set fields like name, labels, hostname in a Kubernetes yaml deployment for kubectl command ?
Like a .env file with docker-compose allows to use variables to define image, port, volumes... Or the values.yaml for Helm installs.
For example :
deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: $deploy_name
spec:
selector:
matchLabels:
app: $app
customer: $customer
env: $env
kube.env
deploy_name=prod-app
app=mysql
customer=customer1
env=prod
kubectl command :
kubectl apply -f deployment.yaml --values kube.env
I only found a way to set env variables for containers but not for the rest of the yaml deployment.