如何将Docker的--privileged标志添加到Kubernetes pod spec容器YAML定义中

此问题:Teamcity Build won't run until Build Agents is configured with Docker?

我对teamcity-agent(Teamcity是一个构建服务器)部署有问题。这些代理是构建者,他们作为自己的豆荚来。因此,当我只是在不使用K8的情况下使用Docker的时候,我使用此命令来运行容器:

docker run -it -e SERVER_URL="<url to TeamCity server>"  \
    --privileged -e DOCKER_IN_DOCKER=start \    
    jetbrains/teamcity-agent 

因此,将这些环境变量添加到K8s容器定义并不难。我只需要定义此spec部分:

spec:
  containers:
    - name: teamcity-agent
      image: jetbrains/teamcity-agent:latest
      ports:
        - containerPort: 8111
      env:
        - name: SERVER_URL
          value: 10.0.2.205:8111
        - name: DOCKER_IN_DOCKER
          value: start

所以现在我也想拥有--privileged标志。我在link to guide上找到了我不太了解的文章。我加了

securityContext:
  allowPrivilegeEscalation: false // also tried 'true'

但是它不起作用。

有人可以指出在哪里看吗?

eywe0686 回答:如何将Docker的--privileged标志添加到Kubernetes pod spec容器YAML定义中

我认为您可以这样使用它

securityContext:
  privileged: true

请参阅this

本文链接:https://www.f2er.com/3146791.html

大家都在问