5
respostas

Kubernetes pull image from Gitlab

Boa tarde,

Estou tentando pegar a no yaml de configuração do yaml usando o codigo abaixo:

apiVersion: apps/v1 kind: Deployment metadata: name: backend-deployment labels: app: backend-deployment spec: selector: matchLabels: app: backend-pod template: metadata: labels: app: backend-pod spec: containers: - image: registry.gitlab.com// name: container-backend-apistructure ports: - containerPort: 8086 imagePullSecrets: - name: gitlab-auth

Configurei a secret com o comando abaixo: kubectl create secret docker-registry gitlab-auth --docker-server=registry.gitlab.com --docker-username= --docker-password= --docker-email=

mas no console do kubernetes eh exibido a mensagem abaixo:

5 respostas

Olá Marco,

Acabou não saindo a mensagem de erro, poderia por favor colocar ela aqui para darmos uma olhada?

Obrigado

Mensagem: Cannot pull image 'registry.gitlab.com/maribeiro30/api-structure' from the registry. Check Pod's events to see more details

abaixo o yaml retirado do console do google cloud:

apiVersion: v1 kind: Pod metadata: annotations: kubernetes.io/limit-ranger: 'LimitRanger plugin set: cpu request for container container-backend-apistructure' creationTimestamp: "2020-01-28T17:28:25Z" generateName: backend-deployment-66bc7f4c64- labels: app: backend-pod pod-template-hash: 66bc7f4c64 name: backend-deployment-66bc7f4c64-p6l65 namespace: default ownerReferences:

  • apiVersion: apps/v1 blockOwnerDeletion: true controller: true kind: ReplicaSet name: backend-deployment-66bc7f4c64 uid: 970a4340-41f3-11ea-9e8f-42010a9e003f resourceVersion: "6453556" selfLink: /api/v1/namespaces/default/pods/backend-deployment-66bc7f4c64-p6l65 uid: 970ebeee-41f3-11ea-9e8f-42010a9e003f spec: containers:
  • image: registry.gitlab.com/maribeiro30/api-structure imagePullPolicy: Always name: container-backend-apistructure ports:
    • containerPort: 8086 protocol: TCP resources: requests: cpu: 100m terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts:
    • mountPath: /var/run/secrets/kubernetes.io/serviceaccount name: default-token-kvkkb readOnly: true dnsPolicy: ClusterFirst enableServiceLinks: true nodeName: gke-pai-structure-default-pool-53b8886b-smnz priority: 0 restartPolicy: Always schedulerName: default-scheduler securityContext: {} serviceAccount: default serviceAccountName: default terminationGracePeriodSeconds: 30 tolerations:
  • effect: NoExecute key: node.kubernetes.io/not-ready operator: Exists tolerationSeconds: 300
  • effect: NoExecute key: node.kubernetes.io/unreachable operator: Exists tolerationSeconds: 300 volumes:
  • name: default-token-kvkkb secret: defaultMode: 420 secretName: default-token-kvkkb status: conditions:
  • lastProbeTime: null lastTransitionTime: "2020-01-28T17:28:25Z" status: "True" type: Initialized
  • lastProbeTime: null lastTransitionTime: "2020-01-28T17:28:25Z" message: 'containers with unready status: [container-backend-apistructure]' reason: ContainersNotReady status: "False" type: Ready
  • lastProbeTime: null lastTransitionTime: "2020-01-28T17:28:25Z" message: 'containers with unready status: [container-backend-apistructure]' reason: ContainersNotReady status: "False" type: ContainersReady
  • lastProbeTime: null lastTransitionTime: "2020-01-28T17:28:25Z" status: "True" type: PodScheduled containerStatuses:
  • containerID: docker://6bfec96c0580f043b1074e34d0daec375bbf6cc48a91b41ce46f2127620e4302 image: registry.gitlab.com/maribeiro30/api-structure:latest imageID: docker-pullable://registry.gitlab.com/maribeiro30/api-structure@sha256:c5a80481c0ccfed46d846fb031c4ddea23107d21cced52e7517a6d9aa975da13 lastState: terminated:
    containerID: docker://6bfec96c0580f043b1074e34d0daec375bbf6cc48a91b41ce46f2127620e4302
    exitCode: 0
    finishedAt: "2020-01-28T17:29:18Z"
    reason: Completed
    startedAt: "2020-01-28T17:29:18Z"
    name: container-backend-apistructure ready: false restartCount: 3 state: waiting:
    message: Back-off pulling image "registry.gitlab.com/maribeiro30/api-structure"
    reason: ImagePullBackOff
    hostIP: 10.158.0.3 phase: Running podIP: 10.28.1.9 qosClass: Burstable startTime: "2020-01-28T17:28:25Z"

Eventos:

Back-off pulling image "registry.gitlab.com/maribeiro30/api-structure" BackOff 28 de jan. de 2020 15:34:35 29 de jan. de 2020 09:18:37 4695 Error: ImagePullBackOff Failed 28 de jan. de 2020 15:34:35 29 de jan. de 2020 09:13:29 4672

Olá Marco,

Pelo que vi está aparecendo erro ImagePullBackOff, isso normalmente ocorre quando a imagem não está mais disponível ou você não configurou a permissão de acesso para essa imagem.

Sua configuração imagePullPolicy está como Always, com isso o Kubernetes sempre irá tentar fazer o acesso a essa imagem, mas como ele não consegue fazer esse acesso, ocorre o erro ImagePullBackOff.

Como sugestão, tente verificar se esta imagem está disponível e se você possui as permissões.

Att

Rafael a imagem esta disponivel e aabaixo, como foi configurado as permissão de acesso permissão com a url documentação para atribuir as permissões:

kubectl create secret docker-registry gitlab-auth --docker-server=registry.gitlab.com --docker-username=maribeiro30 --docker-password= --docker-email=

Essa secret eh referenciada no yaml atraves da chave: imagePullSecrets: - name: gitlab-auth

referencia documentação: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/