2017-09-15 109 views
0

我正在使用一個脫機羣集(機器沒有互聯網訪問),使用ansible和docker組合腳本部署docker圖像。 我的服務器是Centos7。 我在機器上建立了一個不安全的碼頭註冊表。我們將改變環境,並且我正在安裝kubernetes以管理我的容器拉動。Kubernet無法從不安全的註冊表中獲取答案,無法在離線羣集上從本地映像運行容器

我按照本指南安裝kubernetes: https://severalnines.com/blog/installing-kubernetes-cluster-minions-centos7-manage-pods-services

安裝後,我試圖推出一個測試吊艙。這裏是莢的YML,與

kubectl -f create nginx.yml 

這裏的YML推出:

apiVersion: v1 
    kind: Pod 
    metadata: 
     name: nginx 
    spec: 
     containers: 
     - name: nginx 
     image: [my_registry_addr]:[my_registry_port]/nginx:v1 

     ports: 
     - containerPort: 80 

我用kubectl描述得到什麼是錯的更多信息:

Name:  nginx 
    Namespace: default 
    Node:  [my node] 
    Start Time: Fri, 15 Sep 2017 11:29:05 +0200 
    Labels:  <none> 
    Status:  Pending 
    IP:  
    Controllers: <none> 
    Containers: 
     nginx: 
     Container ID:  
     Image:   [my_registry_addr]:[my_registry_port]/nginx:v1 
     Image ID:   
     Port:   80/TCP 
     State:   Waiting 
      Reason:   ContainerCreating 
     Ready:   False 
     Restart Count:  0 
     Volume Mounts:  <none> 
     Environment Variables: <none> 
    Conditions: 
     Type  Status 
     Initialized True 
     Ready  False 
     PodScheduled True 
    No volumes. 
    QoS Class: BestEffort 
    Tolerations: <none> 
    Events: 
     FirstSeen LastSeen Count From    SubObjectPath   Type  Reason  Message 
     --------- -------- ----- ----    ------------- -------- ------  ------- 
     2m  2m  1 {default-scheduler }    Normal  Scheduled Successfully assigned nginx to [my kubernet node] 
     1m  1m  2 {kubelet [my kubernet node]}   Warning  FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "Error while pulling image: Get https://index.docker.io/v1/repositories/library/[my_registry_addr]/images: dial tcp: lookup index.docker.io on [kubernet_master_ip]:53: server misbehaving" 

     54s 54s 1 {kubelet [my kubernet node]}  Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"[my_registry_addr]:[my_registry_port]\"" 

     8s 8s 1 {kubelet [my kubernet node]}  Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/[my_registry_addr]/images. You may want to check your internet connection or if you are behind a proxy." 

然後,我去我的節點和使用journalctl -xe

sept. 15 11:22:02 [my_node_ip] dockerd-current[9861]: time="2017-09-15T11:22:02.350930396+02:00" level=info msg="{Action=create, LoginUID=4294967295, PID=11555}" 
    sept. 15 11:22:17 [my_node_ip] dockerd-current[9861]: time="2017-09-15T11:22:17.351536727+02:00" level=warning msg="Error getting v2 registry: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)" 
    sept. 15 11:22:17 [my_node_ip] dockerd-current[9861]: time="2017-09-15T11:22:17.351606330+02:00" level=error msg="Attempting next endpoint for pull after error: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)" 
    sept. 15 11:22:32 [my_node_ip] dockerd-current[9861]: time="2017-09-15T11:22:32.353946452+02:00" level=error msg="Not continuing with pull after error: Error while pulling image: Get https://index.docker.io/v1/repositories/library/[my_registry_ip]/images: dial tcp: lookup index.docker.io on [kubernet_master_ip]:53: server misbehaving" 
    sept. 15 11:22:32 [my_node_ip] kubelet[11555]: E0915 11:22:32.354309 11555 docker_manager.go:2161] Failed to create pod infra container: ErrImagePull; Skipping pod "nginx_default(8b5c40e5-99f4-11e7-98db-f8bc12456ee4)": Error while pulling image: Get https://index.docker.io/v1/repositories/library/[my_registry_ip]/images: dial tcp: lookup index.docker.io on [kubernet_master_ip]:53: server misbehaving 
    sept. 15 11:22:32 [my_node_ip] kubelet[11555]: E0915 11:22:32.354390 11555 pod_workers.go:184] Error syncing pod 8b5c40e5-99f4-11e7-98db-f8bc12456ee4, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "Error while pulling image: Get https://index.docker.io/v1/repositories/library/[my_registry_ip]/images: dial tcp: lookup index.docker.io on [kubernet_master_ip]:53: server misbehaving" 
    sept. 15 11:22:44 [my_node_ip] dockerd-current[9861]: time="2017-09-15T11:22:44.350708175+02:00" level=error msg="Handler for GET /v1.24/images/[my_registry_ip]:[my_registry_port]/json returned error: No such image: [my_registry_ip]:[my_registry_port]" 

我確定我的碼頭配置是好的,因爲我每天都用ansible或mesos來使用它。

碼頭工人的版本是1.12.6,kubernet版本1.5.2

是別人有什麼我可以現在做的一些見解?我沒有發現這種用法的任何配置密鑰。

當我看到拉動失敗時,我手動拉動所有節點上的圖像。我把一個標籤,以確保kubernetes會盡量拉爲默認值,並設置「imagePullPolicy:IfNotPresent」

+0

是否使用auth或不使用私人註冊表?也請看看這是否有幫助https://blog.cloudhelix.io/using-a-private-docker-registry-with-kubernetes-f8d5f6b8f646 –

+0

它似乎Kubernetes不知道如何從您的私人註冊表中拉圖像看到https ://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/和https://kubernetes.io/docs/concepts/containers/images/#using-a-private-registry –

+0

它是沒有身份驗證的註冊表。這是不安全的,使用http。我在我的節點上編輯daemon.json文件以允許它們從註冊表中拉出。 –

回答

0

的語法用於指定泊塢窗圖像:

[docker_registry]/[image_name]:[image_tag] 

在你的manifest文件中,有使用「:」來分隔docker存儲庫主機和存儲庫正在監聽的端口。對於搬運工人私人註冊表我猜的默認端口是5000。 所以從

Image:   [my_registry_addr]:[my_registry_port]/nginx:v1 

改變你的形象聲明

Image:   [my_registry_addr]/nginx:v1 

此外,通過做檢查從工作節點的網絡連接到您的碼頭工人註冊表一個平。

ping [my_registry_addr] 

如果你仍然想檢查443端口被打開的註冊表中,你可以在主機上運行的泊塢窗註冊表

curl telnet://[my_registry_addr]:443 

希望幫助做一個tcp檢查該端口上。

+0

我的註冊表不安全,使用http進行配置。圖像標籤和拉是好的,我可以拉和推使用碼頭的指令。如果我只使用服務器地址進行標記,則docker不能再與他聯繫(導致我的註冊表在daemon.json文件中用[addr:port]定義)。 443端口聯繫失敗,但我想這是正常的,我沒有任何服務在該端口。 –

+0

但問題不僅在於,因爲當我使用本地呈現在我所有節點上的圖像「nginx:v1」時,kubernet仍然無法實現它。 –

0

我終於找到了什麼問題。

要工作,Kubernetes需要一個暫停容器。 Kubernetes試圖在互聯網上找到暫停容器。

我在我的註冊表中部署了一個自定義暫停容器,我爲此圖像設置了kubernetes暫停容器。

之後,kubernetes像一個魅力工作。

相關問題