Docker kubernetes - 未经授权:需要身份验证

时间:2018-01-20 17:30:51

标签: docker kubernetes

我已经设置了一个新的Kubernetes v1.5群集。

我使用以下方式在本地创建了一个新的docker镜像:

# MAIN IMAGE
FROM gcr.io/google_containers/nginx-slim

我使用命令创建了它:

docker build -t myapp:1 .

我可以看到图像是可用的并且正在运行:

docker ps | grep app
d6fc0508e56b        myapp:1                                                                                                                            "nginx -g 'daemon ..."   31 seconds ago      Up 30 seconds       0.0.0.0:32354->80/tcp 

现在我尝试在kubernetes部署中使用相同的图像。

kubectl run app-deployment --image myapp:1 --replicas=1 --port=80

但这样做并没有启动pod而我得到错误:

  19s   3s  2   {kubelet 10.0.0.17} spec.containers{app-deployment} Normal  Pulling     pulling image "myapp:1"
  18s   2s  2   {kubelet 10.0.0.17} spec.containers{app-deployment} Warning Failed      Failed to pull image "myapp:1": unauthorized: authentication required
  18s   2s  2   {kubelet 10.0.0.17}                 Warning FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "app-deployment" with ErrImagePull: "unauthorized: authentication required"

文件/root/.docker/config.json& /var/lib/kubelet/.dockercfg目前为空。在设置Kubernetes时是否有一些错过的东西?

1 个答案:

答案 0 :(得分:0)

由于您要构建自定义泊坞窗映像,因此必须在群集的每个节点中构建它,调度程序可以将其置于其中。

此外,您需要在PodSpec imagePullPolicy ifNotPresent中指定kubelet,以表明docker registry如果已经存在,则不会尝试下载您的图片。< / p>

这应该可以让您的图片正常工作,但我强烈建议您将图片推送到 <!-- Experience Name // Text Field --> <div class="row"> <div class="form-group"> <label>Experience Name</label> <%= f.text_field :name, placeholder: "Name of your experience", class: "form-control", required: true %> </div> </div> <!-- Experience Description // Text Area --> <div class="row"> <div class="form-group"> <label>Experience Description</label> <%= f.text_area :summary, rows: 5, placeholder: "Describe your experience", class: "form-control", required: true %> </div> </div> <!-- Location // Text Field --> <div class="row"> <div class="form-group"> <label>Location</label> <%= f.text_field :location, placeholder: "Where is your experience?", class: "form-control", required: true %> </div> </div> <!-- Length of Trip // Dropdown Select --> <div class="row"> <div class="select"> <div class="form-group"> <label>Category Type</label> <br/> <%= f.select :cat_help, [["Activity", 1], ["Food & Beverage", 2], ["Vista Point", 3]], id: "cat_help", prompt: "Select...", class: "form-control", required: true %> </div> </div> <!-- Length of Trip // Dropdown Select --> <div class="row"> <div class="col-md-3 select"> <div class="form-group"> <label>Length Type</label> <br/> <%= f.select :length, [["Daytrip", "Daytrip"], ["Overnight", "Overnight"], ["Weekend Getaway", "Weekend"], ["Multi-Day", "Multi-Day"]], id: "length", prompt: "Select...", class: "form-control", required: true %> </div> </div> <!-- Difficulty Rating // Dropdown Select --> <div class="row"> <div class="col-md-3 col-md-offset-1 select"> <div class="form-group"> <label>Difficulty</label> <br/> <%= f.select :difficulty, [["Light", "Light"], ["Moderate", "Moderate"], ["Advanced", "Advanced"], ["Extreme", "Extreme"]], id: "difficulty", prompt: "Select...", class: "form-control", required: true %> </div> </div> <!-- Group Size // Dropdown Select --> <div class="col-md-3 col-md-offset-1 select"> <div class="form-group"> <label>Group Size</label> <br/> <%= f.select :accomodate, [["1", 1], ["2-4", 2], ["5-8", 3], ["8+", 4]], id: "accomodate", prompt: "Select...", class: "form-control", required: true %> </div> </div> </div> <!-- Final Submit // Button --> <div> <%= f.submit "Create Your Experience", class: "btn btn-normal btn-block" %> </div> 并让节点从那里拉出来。