我有一个示例Deployment.yaml,其中包含容器
kind: Pod
metadata:
generateName: test-pod-
spec:
containers:
- name: test-pod
image: test/mypod:v5.16
env:
- name: testenv
valueFrom:
configMapKeyRef:
name: kubernetes-config
key: type
volumeMounts:
- name: test-vol
mountPath: "/test/vol"
readOnly: true
这会创建一个具有随机名称test-pod-vdffg的豆荚
现在我想使用自定义资源定义来进行Pod生成 所以我在CRD下创建
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: testconfigs.demo.k8s.com
namespace: testns
spec:
group: demo.k8s.com
versions:
- name: v1
served: true
storage: true
scope: Namespaced
names:
plural: testpodconfigs
singular: testpodconfig
kind: TestPodConfig
还有这样的自定义资源
apiVersion: demo.k8s.com/v1
kind: TestPodConfig
metadata:
generateName: test-pod-
namespace: testns
spec:
image: test/mypod:v5.16
env:
- name: testenv
valueFrom:
configMapKeyRef:
name: kubernetes-config
key: type
在这里,我不确定image属性是否会将容器添加到PodSpec,因为它是一个简单的字符串。另外,如何使用客户端程序添加卷和环境变量。