Configure Kubernetes on Azure ACS to pull images from Artifactory

7/13/2017

I try to configure Kubernetes to pull images from our private Artifactory Docker repo.

First I configured a secret with kubectl:

kubectl create secret docker-registry artifactorysecret --docker-server=ourcompany.jfrog.io/path/list/docker-repo/ --docker-username=artifactory-user --docker-password=artipwd --docker-email=myemail

After creating a pod using kubectl with

apiVersion: v1
kind: Pod
metadata:
  name: base-infra
spec:
  containers:
    - name: api-gateway
      image: api-gateway
  imagePullSecrets:
    - name: artifactorysecret

I get a "ImagePullBackOff" error in Kubernetes:

 3m            3m              1       default-scheduler                                           Normal
Scheduled       Successfully assigned consort-base-infra to k8s-agent-ab2f29b2-2
  3m            0s              5       kubelet, k8s-agent-ab2f29b2-2   spec.containers{api-gateway}    Normal
Pulling         pulling image "api-gateway"
  2m            <invalid>       5       kubelet, k8s-agent-ab2f29b2-2   spec.containers{api-gateway}    Warning
Failed          Failed to pull image "api-gateway": rpc error: code = 2 desc = Error: image library/api-gateway:latest not found
  2m            <invalid>       5       kubelet, k8s-agent-ab2f29b2-2                               Warning
FailedSync      Error syncing pod, skipping: failed to "StartContainer" for "api-gateway" with ErrImagePull: "rpc error: code = 2 desc = Error: image library/api-gateway:latest not found"

  2m    <invalid>       17      kubelet, k8s-agent-ab2f29b2-2   spec.containers{api-gateway}    Normal  BackOff
Back-off pulling image "api-gateway"
  2m    <invalid>       17      kubelet, k8s-agent-ab2f29b2-2                                   Warning FailedSync
Error syncing pod, skipping: failed to "StartContainer" for "api-gateway" with ImagePullBackOff: "Back-off pulling image \"api-gateway\""

There is of course a latest version in the repo. I don't know what I'm missing here. It seems Kubernetes is able to log in to the repo...

-- user2262423
kubernetes

1 Answer

7/14/2017

Ok - I found out to connect Artifactory thanks to Pull image Azure Container Registry - Kubernetes

There are two things to pay attention to:

1) in the secret definition don't forget https:// in the server-attribute:

kubectl create secret docker-registry regsecret --docker-server=https://our-repo.jfrog.io --docker-username=myuser --docker-password=<your-pword> --docker-email=<your-email>

2) in the deployment descriptor use the full image path and specify the secret (or append it to the default ServiceAccount):

apiVersion: v1
kind: Pod
metadata:
  name: consort-base-infra-art
spec:
  containers:
    - name: api-gateway
      image: our-repo.jfrog.io/api-gateway
  imagePullSecrets:
    - name: regsecret
-- user2262423
Source: StackOverflow