Reputation: 1149
I have a tool working on K8s that uses four configuration files:
falco-config/falco.yaml
falco-config/falco_rules.local.yaml
falco-config/falco_rules.yaml
falco-config/k8s_audit_rules.yaml
At deployment time I create the config map for this tool using the command:
kubectl create configmap falco-config --from-file=..../falco-config/
It creates a ConfigMap with these four files. Now suppose I only want to update the falco_rules.yaml
but I don't have (for different reasons) the other files. Which kubectl command can help me to do that? I searched for a solution on K8s doc and Stackoverflow with no luck.
Another question is, is there an example out there to do the same via K8s API in Javascript?
NOTE: I have read this question: Kubectl update configMap but it doesn't address the modify via API and the fact that I need to only update one file while the whole configuration is composed by 4 files.
Upvotes: 3
Views: 2669
Reputation: 498
Unfortunately there is no way to update specific fields of the ConfigMap in one go. Assuming that the ConfigMap resource has been already created, you could work around this as follows:
kubectl get configmap <name> --export -o yaml > config.yaml
to fetch the ConfigMap resource locallyconfig.yaml
so that the values of falco_rules.yaml
are properly injected. This can be done programmatically.kubectl apply -f config.yaml
to reconfigure the existing ConfigMap resourceUpvotes: 3