<p>How to create config map and secrets using Go lang Kubernetes API</p>

Ashok Kumar
<p>You need to have your <a href="https://github.com/kubernetes/client-go" rel="noreferrer">Kubernetes client</a> configured with your Kubernetes cluster and then create ConfigMap/Secret struct and call Kubernetes API.</p>
<p>Here is a code example you can use:</p>
<pre class="lang-golang prettyprint-override"><code>cm := corev1.ConfigMap{
  TypeMeta: metav1.TypeMeta{
    Kind:       &quot;ConfigMap&quot;,
    APIVersion: &quot;v1&quot;,
  },
  ObjectMeta: metav1.ObjectMeta{
    Name:      &quot;my-config-map&quot;,
    Namespace: &quot;my-namespace&quot;,
  },
  Data: &lt;config-map-data&gt;,
}

clientset.CoreV1().ConfigMaps(&quot;my-namespace&quot;).Create(&amp;cm)
</code></pre>
<p>Here you can find the doc for:</p>
<ul>
<li><a href="https://pkg.go.dev/k8s.io/api@v0.23.0/core/v1#ConfigMap" rel="noreferrer">ConfigMap</a></li>
<li><a href="https://pkg.go.dev/k8s.io/api@v0.23.0/core/v1#Secret" rel="noreferrer">Secret</a></li>
</ul>
