在我们的 kubernetes 集群中部署 jenkins pod 时,kubernetes 返回以下错误:
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
我的部署 yaml 文件:
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: {}
我尝试了 docker-sock 卷:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
type: file
--- and ---
- name: docker-sock
hostPath:
path: /var/run/docker.sock
type: Socket
但它不起作用。实际上,这种配置是有效的。但它现在不起作用。
我尝试了卷安装:
volumeMounts:
- name: jenkins-home
mountPath: /var/jenkins_home
- name: docker-sock
mountPath: /var/run/docker.sock
部署已创建。但是 Docker 无法工作。
我们正在使用 IBM Cloud Kubernetes 服务。
集群版本:
1.15.11_1533
Kubernetes API 版本:
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 版本:
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"}