<p>I could get the kubectl working for creating configmap with a set of files with below command </p>

<pre><code>kubectl create configmap configmap2 --from-file foldername
</code></pre>

<p>where foldername contains files with keys and values</p>

<p>Now I want to create a K8s config map with the same folder using Java. I dont want to use any libraries. Is there any way I can achieve this?</p>

<p>Here is the API request that you have to make to the Kubernetes API server to create a ConfigMap:</p>

<blockquote>
  <p><a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#create-configmap-v1-core" rel="nofollow noreferrer"><code>POST /api/v1/namespaces/{namespace}/configmaps</code></a></p>
</blockquote>

<p>The data must be a ConfigMap JSON object as specified <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#configmap-v1-core" rel="nofollow noreferrer">here</a>.</p>

<p>If you don't use a library, you must also include the correct credentials in the request, which is usually a token (<code>Authorization: Bearer &lt;token&gt;</code>) or a certificate.</p>

<p><strong>Tip:</strong></p>

<p>You can use <code>kubectl create configmap -v 10 configmap2 --from-file foldername</code> (note <code>-v 10</code>) to see the exact HTTP request that kubectl makes to the API server.</p>
