Keep elastic cloud credentials separately & securly

I am using metricbeat to monitor the K8s cluster. I was using the following config,

Here elastic cloud creds are referred like {ELASTIC_CLOUD_ID}, I am struggling to feed the credentials. Where should I define the {ELASTIC_CLOUD_ID}? I tried setting as an environment variable but the value is not replaced when execute the
kubectl apply -f metricbeat-kubernetes-7.4.yaml

Note: Hardcoding the in the metricbeat-kubernetes-7.4.yaml is an option (it works fine with that) but I cannot commit the config file to Github with the credentials.

What is the best way to handle that?
I don't think config map with variable an option here.

Found the answer, posting for others benefit,
The solution is very well documented on

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.