gpt4 book ai didi

azure - 使用 podman 作为 Kubernetes 上的非特权容器运行 Azure 自托管代理

转载 作者:行者123 更新时间:2023-12-03 03:36:18 26 4
gpt4 key购买 nike

我正在 Kubernetes 集群 1.22+ 上部署 Azure 自托管代理,步骤如下: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops#linuxInstructions

我将 podman 添加到自托管代理作为容器管理器,以下代码添加到自托管代理 Dockerfile:

# install podman
ENV VERSION_ID=20.04

RUN apt-get update -y && apt-get install curl wget gnupg2 -y && . ./etc/os-release && sh -c "echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list" && wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_${VERSION_ID}/Release.key -O- | apt-key add - && apt-get update -y && apt-get -y install podman && podman --version

在特权模式下运行容器时,一切运行顺利。

...
securityContext:
privileged: true
...

当切换到 privileged: false 并尝试连接到 podman 时,出现以下错误

level=warning msg="\"/\" is not a shared mount, this could cause issues or missing mounts with rootless containers"
Error: mount /var/lib/containers/storage/overlay:/var/lib/containers/storage/overlay, flags: 0x1000: permission denied

我用于连接的命令是:

podman login private.container.registry \
--username $USER \
--password $PASS \
--storage-opt mount_program=/usr/bin/fuse-overlayfs

如何在非特权模式下使用 podman?

最佳答案

问题与 Containerd 的 apparmor 配置文件拒绝 mount 系统调用有关,我现在通过在运行非特权模式时禁用容器的 apparmor 来修复它

...
template:
metadata:
labels:
app: vsts-agent-2
annotations:
container.apparmor.security.beta.kubernetes.io/kubepodcreation: unconfined
...
securityContext:
privileged: false #true

更好的方法是创建一个apparmor配置文件,允许安装并将其应用到容器

关于azure - 使用 podman 作为 Kubernetes 上的非特权容器运行 Azure 自托管代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73218371/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com