<p>Is there anyway to convert configuration files like xml to kubernetes configmap yaml file without using kubectl command ? Let’s say if I want to create xml files dynamically which in turn stored in git repo as configmap yaml and some operator can monitor for yaml changes and deploy it to the cluster.</p>

<blockquote>
  <p>configuration files like xml to kubernetes configmap yaml file without using kubectl command</p>
</blockquote>

<p>Sure, because the only thing <code>kubectl</code> does with <code>yaml</code> is immediately convert it to <code>json</code> and then <code>POST</code> (or <code>PUT</code> or whatever) to the kubernetes api with a <code>content-type: application/json;charset=utf-8</code> header (you can watch that take place via <code>kubectl --v=100 create -f my-thing.yaml</code>)</p>

<p>So, the answer to your question is to use your favorite programming language that has libraries for json (or the <a href="https://github.com/stedolan/jq#readme" rel="nofollow noreferrer">positively amazing jq</a>), package the XML as necessary, the use something like <a href="https://github.com/box/kube-applier#readme" rel="nofollow noreferrer">kube-applier</a> to monitor and roll out the change:</p>



<pre class="lang-py prettyprint-override"><code># coding=utf-8
import json
import sys

result = {
  "apiVersion": "v1",
  "kind": "ConfigMap",
  # etc etc
  "data": [],
}
for fn in sys.argv[1:]:
    with open(fn) as fh:
       body = fh.read()
    data.append({fn: body})
json.dump(result, sys.stdout)  # or whatever
</code></pre>
