我正在尝试部署一个非常基本的Express应用程序,一个在EC2服务器上监听8080的小型服务器(Ubuntu 16.04)following this tutorial。在该服务器上,它通过kops 1.8.0创建了一个Kubernetes集群。 之后,我创建了一个如下所示的Dockerfile:
FROM node:carbon
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin
# Create app directory
WORKDIR /usr/src/app
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm install
# Bundle app source
COPY . .
EXPOSE 8080
CMD [ "node", "server.js" ]
# At the end, set the user to use when running this image
USER node
之后,我使用docker build -t ccastelli/stupid_server:test1
构建了图片,我使用docker login -u ccastelli
指定了我的凭据,我从docker images
复制了图像ID,将其标记为docker tag c549618dcd86 org/test:first_try
并推送cloud.docker.com.
docker push org/test
之后,我使用kubectl create secret docker-registry ccastelli-regcred --docker-server=docker.com --docker-username=ccastelli --docker-password='pass' --docker-email=myemail@gmail.com
之后我创建了一个部署文件:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: stupid-server-deployment
spec:
replicas: 1
template:
metadata:
labels:
app: stupid-server
spec:
containers:
- name: stupid-server
image: org/test:first_try
imagePullPolicy: Always
ports:
- containerPort: 8080
imagePullSecrets:
- name: ccastelli-regcred
我从kubectl get pods
看到图片从ErrPullImage
转换为ImagePullBackOff
并且尚未准备就绪。无论如何,docker容器正在客户端实例上工作,但不在集群中。此时,我有点迷失了。我究竟做错了什么?
感谢
编辑:消息错误:
无法提取图像“org / test:first_try”:rpc错误:code = 未知的desc =来自守护进程的错误响应:存储库pycomio / test not 发现:不存在或没有拉取访问权
答案 0 :(得分:1)
你的--docker-server应该是index.docker.io
DOCKER_REGISTRY_SERVER=https://index.docker.io/v1/
DOCKER_USER=Type your dockerhub username, same as when you `docker login`
DOCKER_EMAIL=Type your dockerhub email, same as when you `docker login`
DOCKER_PASSWORD=Type your dockerhub pw, same as when you `docker login`
kubectl create secret docker-registry myregistrykey \
--docker-server=$DOCKER_REGISTRY_SERVER \
--docker-username=$DOCKER_USER \
--docker-password=$DOCKER_PASSWORD \
--docker-email=$DOCKER_EMAIL