Replies: 2 comments
-
You are correct in that you need the
Are you sure |
Beta Was this translation helpful? Give feedback.
0 replies
-
Closing this one since it has no interactions for a long time so it seems sorted out. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to build a pod in the controller, this pod needs a volume, and the type of the volume is a comfigmap, so I define a pod in the following way, omitting other unimportant fields, and only keeping the volume ↓↓↓
`Volumes: []corev1.Volume{
{
Name: podVolumeName,
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: zapi.Spec.ConfigMap,
},
The problem is that when I use kubernetes to create a pod, if I need to bind a volume to a configmap, then I must have a configMap.name field, as I saw in the kubernetes documentation ↓↓↓
But the ConfigMapVolumeSource object in the k8s.io/api/core/v1 package I referenced does not have a name field. I don't know if this is reasonable. I refer to the code of other operators, such as the prometheus operator. When they build a pod and need to mount the volume of the configmap, the name is not defined in pod.Spec.Volumes.VolumeSource.configMap, Only use this field LocalObjectReference. But if I don't define Name in my code and execute make install and make run, my controller will report an error, which is obviously an error that the pod cannot be created without this name field. I don't know what is causing this and how can I fix it, thanks a lot for the help from the team ↓↓↓
My environment is as follows ↓↓↓
Kubernetes Version ↓
1.18
Kubebuilder Version ↓
[root@VM-56-84-centos ~/operator/mycrd]# kubebuilder version Version: main.version{KubeBuilderVersion:"3.2.0", KubernetesVendor:"1.22.1", GitCommit:"b7a730c84495122a14a0faff95e9e9615fffbfc5", BuildDate:"2021-10-29T18:32:16Z", GoOs:"linux", GoArch:"amd64"}
go version and go.mod ↓
`go 1.16
require (
k8s.io/api v0.22.1
k8s.io/apimachinery v0.22.1
k8s.io/client-go v0.22.1
sigs.k8s.io/controller-runtime v0.10.0
)`
Beta Was this translation helpful? Give feedback.
All reactions