minikube无法访问远程Harbor注册表

时间:2017-11-13 12:04:26

标签: kubernetes docker-registry minikube harbor

即使使用minikube start --insecure-registry "<HARBOR_HOST_IP>"启动minikube,尝试运行包含image路径<HARBOR_HOST_IP>/app/server的部署yaml文件时,也会收到错误:

  

无法提取图像&#34; [HARBOR_IP] / app / server&#34;:rpc错误:代码= 2 desc =来自守护程序的错误响应:{&#34; message&#34;:&#34; Get https://[HARBOR_IP]/v1/_ping:拨打tcp [HARBOR_IP]:443:getsockopt:连接被拒绝&#34;}   同步窗格时出错

如何在minikube中正确设置insecure-registry

修改

使用80端口标记当前的docker镜像:

docker tag server <HARBOR_HOST_IP>:80/app/server

将其推送至Harbour注册服务器:

docker push <HARBOR_HOST_IP>:80/app/server

不幸的是,远程港口主持人否认:

The push refers to a repository [<HARBOR_HOST_IP>:80/app/server]
00491a929c2e: Preparing
ec4cc3fab4be: Preparing
e7d3ac95d998: Preparing
8bb050c3d78d: Preparing
4aa9e88e4148: Preparing
978b58726b5e: Waiting
2b0fb280b60d: Waiting
denied: requested access to the resource is denied

甚至将<HARBOR_HOST_IP>:80添加到本地insecure-registries列表。

2 个答案:

答案 0 :(得分:1)

如果您在与端口80上工作的docker注册表进行通信时始终定义端口80,则可以正常工作。

建立图像:

docker build -t <REGISTRY_IP>:80/<name> <path>

将其推送到注册表:

docker push <REGISTRY_IP>:80/<name>

使用此不安全的注册表启动minikube:

minikube start --insecure-registry <REGISTRY_IP>:80

创建部署:

kubectl create -f test.yaml

其中test.yaml是:

apiVersion: extensions/v1beta1                                                                                                                                                                          
kind: Deployment                                                                                                                                                                                        
metadata:                                                                                                                                                                                               
  name: test                                                                                                                                                                                     
spec:                                                                                                                                                                                                   
  template:                                                                                                                                                                                             
    metadata:                                                                                                                                                                                           
      labels:                                                                                                                                                                                           
        app: test                                                                                                                                                                                
    spec:                                                                                                                                                                                               
      containers:                                                                                                                                                                                       
      - image: 192.168.1.11:80/<name>                                                                                                                                                    
        name: test                                                                                                                                                                               
        imagePullPolicy: Always

答案 1 :(得分:1)

您是否在kubernetes中添加了秘密? 请参考链接以添加秘密:https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/

class TabContainer extends PureComponent {

  handleTabClick = key => {
    this.props.history.push(`/${key}`)   // < == router router v4
    browserHistory.push(`/${key}`);      // <== react router v3
  }

  render = () => (
    <Tabs defaultActiveKey="history" onChange={this.handleTabClick}>
      <TabPane tab="Tab 1" key="history">History</TabPane>
      <TabPane tab="Tab 2" key="math">Math</TabPane>
      <TabPane tab="Tab 3" key="science">Science</TabPane>
    </Tabs>
  )
}

然后使用kubernetes yaml中的秘密。

kubectl create secret docker-registry regcred --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>