<p>My DigitalOcean kubernetes cluster is unable to pull images from the DigitalOcean registry. I get the following error message:</p>
<pre><code>Failed to pull image &quot;registry.digitalocean.com/XXXX/php:1.1.39&quot;: rpc error: code = Unknown desc = failed to pull and unpack image 
&quot;registry.digitalocean.com/XXXXXXX/php:1.1.39&quot;: failed to resolve reference 
&quot;registry.digitalocean.com/XXXXXXX/php:1.1.39&quot;: failed to authorize: failed to fetch anonymous token: unexpected status: 401 Unauthorized
</code></pre>
<p>I have added the kubernetes cluster using DigitalOcean Container Registry Integration, which shows there successfully both on the registry and the settings for the kubernetes cluster.</p>
<p><a href="https://i.stack.imgur.com/hOkVJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hOkVJ.png" alt="enter image description here" /></a></p>
<p>I can confirm the above address `registry.digitalocean.com/XXXX/php:1.1.39 matches the one in the registry. I wonder if I’m misunderstanding how the token / login integration works with the registry, but I’m under the impression that this was a “one click” thing and that the cluster would automatically get the connection to the registry after that.</p>
<p>I have tried by logging helm into a registry before pushing, but this did not work (and I wouldn't really expect it to, the cluster should be pulling the image).</p>
<p>It's not completely clear to me how the image pull secrets are supposed to be used.</p>
<p>My helm deployment chart is basically the default for API Platform:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include &quot;api-platform.fullname&quot; . }}
  labels:
    {{- include &quot;api-platform.labels&quot; . | nindent 4 }}
spec:
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  {{- end }}
  selector:
    matchLabels:
      {{- include &quot;api-platform.selectorLabels&quot; . | nindent 6 }}
  template:
    metadata:
      {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        {{- include &quot;api-platform.selectorLabels&quot; . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include &quot;api-platform.serviceAccountName&quot; . }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      containers:
        - name: {{ .Chart.Name }}-caddy
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: &quot;{{ .Values.caddy.image.repository }}:{{ .Values.caddy.image.tag | default .Chart.AppVersion }}&quot;
          imagePullPolicy: {{ .Values.caddy.image.pullPolicy }}
          env:
            - name: SERVER_NAME
              value: :80
            - name: PWA_UPSTREAM
              value: {{ include &quot;api-platform.fullname&quot; . }}-pwa:3000
            - name: MERCURE_PUBLISHER_JWT_KEY
              valueFrom:
                secretKeyRef:
                  name: {{ include &quot;api-platform.fullname&quot; . }}
                  key: mercure-publisher-jwt-key
            - name: MERCURE_SUBSCRIBER_JWT_KEY
              valueFrom:
                secretKeyRef:
                  name: {{ include &quot;api-platform.fullname&quot; . }}
                  key: mercure-subscriber-jwt-key
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
            - name: admin
              containerPort: 2019
              protocol: TCP
          volumeMounts:
            - mountPath: /var/run/php
              name: php-socket
          #livenessProbe:
          #  httpGet:
          #    path: /
          #    port: admin
          #readinessProbe:
          #  httpGet:
          #    path: /
          #    port: admin
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
        - name: {{ .Chart.Name }}-php
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: &quot;{{ .Values.php.image.repository }}:{{ .Values.php.image.tag | default .Chart.AppVersion }}&quot;
          imagePullPolicy: {{ .Values.php.image.pullPolicy }}
          env:
            {{ include &quot;api-platform.env&quot; . | nindent 12 }}
          volumeMounts:
            - mountPath: /var/run/php
              name: php-socket
          readinessProbe:
            exec:
              command:
                - docker-healthcheck
            initialDelaySeconds: 120
            periodSeconds: 3
          livenessProbe:
            exec:
              command:
                - docker-healthcheck
            initialDelaySeconds: 120
            periodSeconds: 3
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
      volumes:
      - name: php-socket
        emptyDir: {}
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
</code></pre>
<p>How do I authorize the kubernetes cluster to pull from the registry? Is this a helm thing or a kubernetes only thing?</p>
<p>Thanks!</p>

<p>The problem that you have is that you do not have an <a href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/" rel="nofollow noreferrer">image pull secret</a> for your cluster to use to pull from the registry.</p>
<p>You will need to add this to give your cluster a way to authorize its requests to the cluster.</p>
<h2>Using the DigitalOcean kubernetes Integration for Container Registry</h2>
<p>Digital ocean provides a way to add image pull secrets to a kubernetes cluster in your account. You can link the registry to the cluster in the settings of the registry. Under &quot;DigitalOcean Kuberentes Integration&quot; select edit, then select the cluster you want to link the registry to.</p>
<p><img src="https://i.stack.imgur.com/Gq6sG.png" alt="DigitalOceanKubernetesIntegration" /></p>
<p>This action adds an image pull secret to all namespaces within the cluster and will be used by default (unless you specify otherwise).</p>
