在我们的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
但是它不起作用。实际上,此配置有效。但是ıt目前无法正常工作。
我尝试了卷装载:
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"}
答案 0 :(得分:2)
较新的IKS集群未安装Docker-它们使用容器式执行容器。
如果您仍然想在Jenkins上执行Docker,则可以将Kubernetes插件和Pod与dind容器一起使用,也可以基于Dind重建自己的jenkins-类似于:https://hub.docker.com/r/vixns/jenkins-dind/