我尝试使用minikube从本地docker镜像和docker hub部署kubernetes。但是两者都不起作用。
方法1: 使用保存并加载tar文件,创建图像,并且该图像可用于kubectl。
root@arun-desktop-e470:/var/local/dprojects/elasticsearch# kubectl get pods --all-namespaces -o jsonpath="{..image}" |tr -s '[[:space:]]' '\n' |sort |uniq -c|grep elk
2 elk/elasticsearch:latest
执行以下命令以创建部署:
kubectl run elastic --image=elk/elasticsearch:latest --port=9200
kubectl expose deployment elastic --target-port=9200 --type=NodePort
minikube service elastic --url
从kubectl描述pod命令,
Warning Failed 122m (x4 over 124m) kubelet, minikube Failed to pull image "elk/elasticsearch:latest": rpc error: code = Unknown desc = Error response from daemon: pull access denied for elk/elasticsearch, repository does not exist or may require 'docker login'
方法2: 我确实将映像推送到了我的docker hub仓库(https://hub.docker.com/r/get2arun/elk/tags),然后登录到终端中的docker hub并再次创建了部署。
按如下所示推送至docker hub,因此我有权将图像推入和拖入我的docker hub帐户。我已经检查了管理存储库下的“合作者”,并且有我的docker hub ID。
root@arun-desktop-e470:~# docker push get2arun/elk:elasticsearch_v1
The push refers to repository [docker.io/get2arun/elk]
19b7091eba36: Layer already exists
237c06a69e1c: Layer already exists
c84fa0f11212: Layer already exists
6ca6c301e2ab: Layer already exists
76dd25653d9b: Layer already exists
602956e7a499: Layer already exists
bde76be259f3: Layer already exists
2333287a7524: Layer already exists
d108ac3bd6ab: Layer already exists
elasticsearch_v1: digest: sha256:6f0b981b5dedfbe3f8e0291dc17fc09d32739ec3e0dab6195190ab0cc3071821 size: 2214
kubectl运行elasticsearch-v2 --image = get2arun / elk:elasticsearch_v1 --port = 9200
从kubectl描述pods命令:
Normal BackOff 21s kubelet, minikube Back-off pulling image "get2arun/elk:elasticsearch_v1"
Warning Failed 21s kubelet, minikube Error: ImagePullBackOff
Normal Pulling 7s (x2 over 24s) kubelet, minikube Pulling image "get2arun/elk:elasticsearch_v1"
Warning Failed 4s (x2 over 21s) kubelet, minikube Failed to pull image "get2arun/elk:elasticsearch_v1": rpc error: code = Unknown desc = Error response from daemon: pull access denied for get2arun/elk, repository does not exist or may require 'docker login'
我删除了代理设置,并尝试从打开的wifi帐户尝试访问,但仍然看到权限被拒绝。
此错误消息不足以识别问题,希望有某种方法可以缩小此类问题的范围。
答案 0 :(得分:2)
在方法1中,由于图像未推送到存储库,因此必须使用imagePullPolicy。
imagePullPolicy: Never
imagePullPolicy: IfNotPresent
如果您要使用本地映像/存储库,我认为IfNotPresent是理想的选择。根据您的要求使用。
kubectl run elastic --image=elk/elasticsearch:latest --port=9200 --image-pull-policy IfNotPresent