1

I was trying to deploy a very basic Express app, a small server listening on 8080 on a EC2 server (Ubuntu 16.04) following this tutorial. On that server, it was created a Kubernetes cluster through kops 1.8.0. After that, I created a Dockerfile like the following:

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

After that, I built the image with docker build -t ccastelli/stupid_server:test1, I specified my credentials with docker login -u ccastelli, I copied the imaged ID from docker images, tagged it docker tag c549618dcd86 org/test:first_try and pushed with docker push org/test on a private repository in cloud.docker.com.

After that I created a cluster secret with kubectl create secret docker-registry ccastelli-regcred --docker-server=docker.com --docker-username=ccastelli --docker-password='pass' [email protected]

After that I created a deployment file:

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

I see from kubectl get pods that the image transitioned from ErrPullImage to ImagePullBackOff and it's not ready. Anyway the docker container was working on the client instance but not in the cluster. At this point, I'm a bit lost. What am I doing wrong? Thanks

Edit: message error:

Failed to pull image "org/test:first_try": rpc error: code = Unknown desc = Error response from daemon: repository pycomio/test not found: does not exist or no pull access

3
  • Do you host your docker private repository? If so, can the k8s cluster 1. resolve the domain properly and 2. can reach the port? Commented Mar 8, 2018 at 17:15
  • the private repo is on cloud.docker.com, I've added the error I get from the dashboard. Commented Mar 8, 2018 at 17:19
  • Try updating your secret to --docker-server=https://cloud.docker.com or your container image: cloud.docker.com/org/test or both Commented Mar 8, 2018 at 17:32

1 Answer 1

1

your --docker-server should be 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
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks you're right, I've also found this answer stackoverflow.com/questions/42267164/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.