How to create config map and secrets using Go lang Kubernetes API
CodePudding user response:
You need to have your Kubernetes client configured with your Kubernetes cluster and then create ConfigMap/Secret struct and call Kubernetes API.
Here is a code example you can use:
cm := corev1.ConfigMap{
TypeMeta: metav1.TypeMeta{
Kind: "ConfigMap",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "my-config-map",
Namespace: "my-namespace",
},
Data: <config-map-data>,
}
clientset.CoreV1().ConfigMaps("my-namespace").Create(&cm)
Here you can find the doc for: