如何解决client-go 使用 configmap 作为卷创建一个 Pod
我正在实施一个准入 webhook,它应该添加一个 sidecar 容器,其配置需要从 configmap
按照当前流程,假设 configmap
存在于集群中,我只需要 VolumeMounts
它。
我正在 client-go 中尝试以下代码:
pod.Spec.Volumes = append(pod.Spec.Volumes,corev1.Volume{
Name: "startup-config",VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
v1.LocalObjectReference{
Name: "my-configmap",},})
但是我收到了 too few values in "k8s.io/api/core/v1".ConfigMapVolumeSource literal
错误
由于 configmap
对象已存在于集群中,因此除了 Name
的 configmap
之外,我不想/不需要提供任何其他字段
我在这里缺少什么?
ps:文档提到 ConfigMapVolumeSource
中的所有其他字段都是可选的。
我想实现一些简单的事情:
apiVersion: v1
kind: Pod
metadata:
name: dapi-test-pod
spec:
containers:
- name: test-container
image: k8s.gcr.io/busybox
command: [ "/bin/sh","-c","ls /etc/config/" ]
volumeMounts:
- name: config-volume
mountPath: /etc/config
volumes:
- name: config-volume
configMap:
# Provide the name of the ConfigMap containing the files you want
# to add to the container
name: special-config
YAML 清单只是一个例子。我想要达到的目标
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。