How to fetch and data from yaml file

kind: ConfigMap
apiVersion: v1
metadata:
  name: worker-recovery-checks
  namespace: kube-system
data:
  checkpod.json: |
    {
      "Check":"KUBEAPI",
      "Resource":"POD",
      "namespace":"",
      "PodFailureThresholdPercent":0,
      "FailureThreshold":30,
      "CorrectiveAction":"RELOAD",
      "CooloffSeconds":900,
      "IntervalSeconds":30,
      "TimeoutSeconds":10,
      "Enabled":true
    }

from above suppose there is configmap file i want to put value namespace in data checkpod.json which is in json part through command line without enter into yaml file,is there any way to do it

Hi @anu,

We don’t have K8s command to do it but you can use commands like sed to search and replace values on the file. Let’s say your ConfigMap is on a file named myConfig.yml.

So you can just try the following command :

sed 's/"namespace":.*/"namespace":"kube-system"/g' myConfig.yml > myConfig.yml

or

sed 's/""/"kube-system"/g' myConfig.yml > myConfig.yml

You can do more complex thing with sed and Regex.

You can see the following to get started on it :