【问题标题】:How to force kubernetes gitlab-runner to use the host network?如何强制 kubernetes gitlab-runner 使用宿主网络?
【发布时间】:2020-11-14 19:21:15
【问题描述】:

我需要让我的容器连接到 gitlab-runners 主机网络,以便针对我管道中的其他服务器运行 ansible。我正在使用 Kubernetes 运行器。

有没有办法强制 runner 使用宿主网络上的 pod?

【问题讨论】:

    标签: kubernetes gitlab gitlab-ci


    【解决方案1】:

    在不改变 kubernetes 集群中的任何内容的情况下,答案是在我的 gitlab 作业中使用以下命令将主机网络添加到容器 /etc/hosts 文件中:

     script:
        # use host network
        - echo "127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4" >> /etc/hosts
        - echo "::1         localhost localhost.localdomain localhost6 localhost6.localdomain6" >> /etc/hosts
    

    【讨论】:

      猜你喜欢
      • 2022-01-08
      • 2020-01-30
      • 2019-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多