简体   繁体   中英

Kubernetes deploy failed jenkins deployment "failed to create containerd task"

While deploying jenkins pod in our kubernetes cluster, kubernetes return the following error:

Error: failed to create containerd task: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/var/run/docker.sock\\\" to rootfs \\\"/run/containerd/io.containerd.runtime.v1.linux/k8s.io/jenkins/rootfs\\\" at \\\"/run/containerd/io.containerd.runtime.v1.linux/k8s.io/jenkins/rootfs/run\\\" caused \\\"not a directory\\\"\"": unknown Back-off restarting failed container

My Deployment yaml file:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: jenkins
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: jenkins
    spec:
      imagePullSecrets:
        - name: my-secret-key
      containers:
        - name: jenkins
          image: image-repo-url
          env:
            - name: JAVA_OPTS
              value: -Djenkins.install.runSetupWizard=false
          ports:
            - name: http-port
              containerPort: 8080
            - name: jnlp-port
              containerPort: 50000
          volumeMounts:
            - name: jenkins-home
              mountPath: /var/jenkins_home
            - name: docker-sock
              mountPath: /var/run/
            - name: docker-storage
              mountPath: /var/lib/docker
          securityContext:
            privileged: true
      volumes:
        - name: jenkins-home
          emptyDir: {}
        - name: docker-sock
          hostPath:
            path: /var/run/docker.sock
        - name: docker-storage
          emptyDir: {}

I tried for docker-sock volume:

- name: docker-sock
  hostPath:
  path: /var/run/docker.sock
  type: file
--- and ---
- name: docker-sock
  hostPath:
  path: /var/run/docker.sock
  type: Socket

But it doesn't work. Actually, this configuration was working. But ıt doesn't work right now.

I tried for volume mounts:

volumeMounts:
- name: jenkins-home
  mountPath: /var/jenkins_home
- name: docker-sock
  mountPath: /var/run/docker.sock

Deployment created. But Docker couldn't work.

We are using IBM Cloud Kubernetes Service.

Cluster Version:

1.15.11_1533

Kubernetes Api Version:

admissionregistration.k8s.io/v1beta1
apiextensions.k8s.io/v1beta1
apiregistration.k8s.io/v1
apiregistration.k8s.io/v1beta1
apps/v1
apps/v1beta1
apps/v1beta2
authentication.k8s.io/v1
authentication.k8s.io/v1beta1
authorization.k8s.io/v1
authorization.k8s.io/v1beta1
autoscaling/v1
autoscaling/v2beta1
autoscaling/v2beta2
batch/v1
batch/v1beta1
batch/v2alpha1
certificates.k8s.io/v1beta1
coordination.k8s.io/v1
coordination.k8s.io/v1beta1
events.k8s.io/v1beta1
extensions/v1beta1
metrics.k8s.io/v1beta1
networking.k8s.io/v1
networking.k8s.io/v1beta1
policy/v1beta1
rbac.authorization.k8s.io/v1
rbac.authorization.k8s.io/v1beta1
scheduling.k8s.io/v1
scheduling.k8s.io/v1beta1
storage.k8s.io/v1
storage.k8s.io/v1beta1
v1

Kubernetes version:

Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.5", GitCommit:"20c265fef0741dd71a66480e35bd69f18351daea", GitTreeState:"clean", BuildDate:"2019-10-15T19:16:51Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.11+IKS", GitCommit:"0562ba8a2dfdd05f7f8721ab4952c02fe1605860", GitTreeState:"clean", BuildDate:"2020-03-13T14:45:42Z", GoVersion:"go1.12.17", Compiler:"gc", Platform:"linux/amd64"}

Newer IKS clusters don't have Docker installed - they use containerd to execute containers.

If you still want to execute Docker on Jenkins you can either use Kubernetes plugin and pods with dind containers or rebuild your own jenkins based on dind - something like this: https://hub.docker.com/r/vixns/jenkins-dind/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM