有关kubernetes的求助

有没有用过k8s中的cronjob的

这是我的yaml文件

apiVersion: batch/v1
kind: CronJob
metadata: 
  name: cronjob
spec: 
  schedule: " */1 * * * * "
  jobTemplate: 
    spec: 
      template: 
        spec: 
          restartPolicy: OnFailure
          containers: 
          - name: busybox 
            image: busybox
            imagePullPolicy: IfNotPresent
            command: ["/bin/sh","-c","echo `date`;"]

为什么我启动任务后创建的容器会报这个错

Events:
  Type     Reason          Age                From               Message
  ----     ------          ----               ----               -------
  Normal   Scheduled       63s                default-scheduler  Successfully assigned default/cronjob-27576244--1-wh72p to k8s-worker-node1
  Normal   AddedInterface  63s                multus             Add eth0 [10.244.1.19/24] from cbr0
  Normal   Pulled          63s                kubelet            Container image "busybox" already present on machine
  Normal   Created         63s                kubelet            Created container busybox
  Normal   Started         63s                kubelet            Started container busybox
  Warning  FailedMount     61s (x3 over 62s)  kubelet            MountVolume.SetUp failed for volume "kube-api-access-hlcvm" : object "default"/"kube-root-ca.crt" not registered
kubernetes
395 views
Comments
登录后评论
Sign In
·

日志已经说原因了

MountVolume.SetUp failed for volume "kube-api-access-hlcvm" : object "default"/"kube-root-ca.crt" not registered

Volume 挂载失败了,默认证书没有注册,你是不是远程 kubectl 挂的?

·

试下增加这个 automountServiceAccountToken

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  serviceAccountName: build-robot
  automountServiceAccountToken: false
  ...

参考:MountVolume.SetUp failed for volume "kube-api-access-fcz9j" : object "default"/"kube-root-ca.crt" not registered