将 Kubernetes 与 Artifactory/Nginx 代理一起使用

Using Kubernetes with an Artifactory/Nginx proxy

几乎我在问如何设置 yaml/kubernetes 以使用我的 Artfiactory 来提取图像。

我是 Kubernetes 的新手,并且已经基于此 tutorial 在我的私人机器上成功安装了我想做的事情。

在工作中,我想使用 Kubernetes 来允许开发人员快速部署和扩展 docker 图像,但是我们在一个孤立的环境中工作。我们目前有 Nginx 和 Artifactory 与我们的 docker 客户端一起工作,如果我手动这样做,可以下载它工作所需的所有图像。

安装 Kubernetes 和 creation/linking pods 并发送作业一切顺利;但是,当我尝试 运行 selenium-hub-rc.yaml 时,当我检查该 pod 的描述 pods 时出现错误,

"Failed to "Startcontainer" for "POD" with ErrImagePull: "image pull failed for registry.access.redhat.com/rhel7/pod-infrastructure, this may be because there are no credentials on this request. details: (unable to ping registry endpoint https ://registry.access.redhat.com/v0/\nv2 ping attempt failed with error: get https ://regitry.access.redhat.com/v2: bad request \n v1 ping attemp failed with error: Get https ://registry.access.redhat.com/v1/_ping: Bad Request)"

现在我相信这里发生的是对 seleium 图像的依赖,pod-infrastructure 正在尝试通过 public 存储库而不是我的 Artifactory 存储库进行下载。

这就是我的问题所在,我一直在努力寻找一种方法,使我的节点对图像的请求将直接发送到我的 Artifactory。我目前尝试了多种方法,但都失败了。

这是我正在使用的一些配置。

我的 nginx 也设置为监听 8088 正常的 docker 请求并将它们转发到名为 docker-remote 的 Artifactory 仓库 它还设置为在 8089 上侦听 registry.access.redhat.com 请求并将其转发到红色远程 repo

很明显,我在 docker 上有 docker 的 Artifactory 回购 - docker.io 的远程和 redhat 回购

的 red-remote

nodes/pods 将 Hosts 文件指向红色-myproxy.mylab.lab 到 nginx 代理 myproxy.mylab.lab 和 docker.conf 文件以包含

INSECURE_REGISTRY='--insecure-registry myproxy.mylab.lab:8088' INSECURE_REGISTRY='--insecure-registry red-myproxy.mylab.lab:8089'

到目前为止一切正常,所以当我构建图像时,我使用 Seleium-hub-rc.yaml 用于创建 docker 个图像

# selenium-hub-rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
  name: selenium-hub
spec:
  replicas: 1
  selector:
    name: selenium-hub
  template:
    metadata:
      labels:
        name: selenium-hub
    spec:
      containers:
        - name: selenium-hub
          image: myproxy.mylab.lab:8088/selenium/hub
          ports:
            - containerPort: 4444 

差不多就这些了。我 运行 yaml,它给了我那个错误。我已经尝试在 docker.conf 和 fannel.conf 中设置代理只是为了看看我是否可以为任何默认请求提供指向我的 repo

的指针

HTTP_PROXY="http://red-proxy.mylab.lab:8089"

但失败了,我试过弄清楚 yaml 是如何做到的,但找不到任何东西,我在想也许我需要直接编辑 selenium 图像才能这样做吗?

我真的被这个问题难住了,但我敢肯定其他人正在使用 kunbernetes 隔离环境,并为它试图拉取的 docker 图像设置多个回购协议。

感谢您抽出时间查看我的问题,希望您能提供帮助!

我找到了答案,在 kubernetes 节点本身上使用行 # pod infrastructure container #KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=re‌​gistry.access.redhat‌​.com/rhel7/pod-infra‌​structure:latest" 编辑 /etc/kubernetes/kubelet 文件并更新它们以将 registry.redhat.com 的路径更改为我的代理服务器 red-proxy.mylab.lab:8089 成功了!我很高兴这个头痛的问题已经解决了:)

归功于 wiki.christophchamp.com/index.php?title=Kubernetes