我决定使用Buildkit的无根版本从Kubernetes的容器中构建Docker映像并将其推送到GCR(Google Container Registry)。
我发现了这个错误:
/moby.buildkit.v1.Control/Solve returned error: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to read dockerfile: failed to mount /home/user/.local/tmp/buildkit-mount859701112: [{Type:bind Source:/home/user/.local/share/buildkit/runc-native/snapshots/snapshots/2 Options:[rbind ro]}]: operation not permitted
字符串
我正在运行buildkitd
作为一个deployment
链接到一个service
,如buildkit文档所指定的。这些资源在托管在Google Kubernetes Engine上的Kubernetes集群内运行。
我正在使用以下YAML进行部署和服务
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: buildkitd
name: buildkitd
spec:
replicas: 1
selector:
matchLabels:
app: buildkitd
template:
metadata:
labels:
app: buildkitd
annotations:
container.apparmor.security.beta.kubernetes.io/buildkitd: unconfined
container.seccomp.security.alpha.kubernetes.io/buildkitd: unconfined
spec:
containers:
- name: buildkitd
image: moby/buildkit:master-rootless
args:
- --addr
- unix:///run/user/1000/buildkit/buildkitd.sock
- --addr
- tcp://0.0.0.0:1234
- --oci-worker-no-process-sandbox
readinessProbe:
exec:
command:
- buildctl
- debug
- workers
initialDelaySeconds: 5
periodSeconds: 30
livenessProbe:
exec:
command:
- buildctl
- debug
- workers
initialDelaySeconds: 5
periodSeconds: 30
securityContext:
runAsUser: 1000
runAsGroup: 1000
ports:
- containerPort: 1234
---
apiVersion: v1
kind: Service
metadata:
labels:
app: buildkitd
name: buildkitd
spec:
ports:
- port: 1234
protocol: TCP
selector:
app: buildkitd
型
它与没有TLS证书设置的buildkit documentation相同。
在另一个Pod中,我使用以下命令联系Buildkit守护程序:
./bin/buildctl \
--addr tcp://buildkitd:1234 \
build \
--frontend=dockerfile.v0 \
--local context=. \
--local dockerfile=. \
--output type=image,name=eu.gcr.io/$PROJECT_ID/test-image,push=true
型buildkitd
容器成功接收到请求,但抛出了上面的错误。buildctl
命令的输出如下:
#1 [internal] load .dockerignore
#1 transferring context: 2B done
#1 DONE 0.1s
#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 120B done
#2 DONE 0.1s
error: failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to read dockerfile: failed to mount /home/user/.local/tmp/buildkit-mount859701112: [{Type:bind Source:/home/user/.local/share/buildkit/runc-native/snapshots/snapshots/2 Options:[rbind ro]}]: operation not permitted
型
这是来自守护进程的错误。
让我印象深刻的是,我能够使用完全相同的YAML文件将buildkitd
容器化到minikube
集群中:
NAME READY STATUS RESTARTS AGE
pod/buildkitd-5b46d94f5d-xvnbv 1/1 Running 0 36m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/buildkitd ClusterIP 10.100.72.194 <none> 1234/TCP 36m
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 36m
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/buildkitd 1/1 1 1 36m
NAME DESIRED CURRENT READY AGE
replicaset.apps/buildkitd-5b46d94f5d 1 1 1 36m
型
我在minikube
内部部署服务和部署,并使用以下命令转发服务端口,以便能够访问minikube
外部的部署。
kubectl port-forward service/buildkitd 2000:1234
型
有了这个设置,我就可以毫无问题地执行我的buildctl
命令(图像构建和推送到GCR)。
我想知道为什么它在minikube
上工作,而不是在Google Kubernetes Engine上。
这里是容器启动日志,如果这是任何帮助
auto snapshotter: using native
NoProcessSandbox is enabled. Note that NoProcessSandbox allows build containers to kill (and potentially ptrace) an arbitrary process in the BuildKit host namespace. NoProcessSandbox should be enabled only when the BuildKit is running in a container as an unprivileged user.
found worker \"wdukby0uwmjyvf2ngj4e71s4m\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:buildkitd-5b46d94f5d-xvnbv org.mobyproject.buildkit.worker.snapshotter:native], platforms=[linux/amd64 linux/386]"
rootless mode is not supported for containerd workers. disabling containerd worker.
found 1 workers, default=\"wdukby0uwmjyvf2ngj4e71s4m\"
currently, only the default worker can be used.
TLS is not enabled for tcp://0.0.0.0:1234. enabling mutual TLS authentication is highly recommended
running server on /run/user/1000/buildkit/buildkitd.sock
running server on [::]:1234
型
3条答案
按热度按时间ffscu2ro1#
Rootless需要在主机上执行各种准备步骤(这需要在运行kubernetes节点的VM主机上的Kubernetes外部完成)。请参阅rootless documentation以获取完整的步骤列表。请注意,这些步骤因Linux发行版而异,因为不同的发行版已经执行了部分或全部这些先决条件步骤。
Ubuntu
Debian GNU/Linux
Arch Linux
openSUSE
Fedora 31及以后
CentOS 8
CentOS 7
vfhzx4xs2#
你可能会点击这个:https://github.com/moby/buildkit/issues/879
请使用GKE Ubuntu节点,而不是Google容器优化操作系统节点。
5q4ezhmt3#
我在Bottlerocket OS 1.14.3(aws-k8s-1.26)上有几乎相同的错误
字符串