<p>I've self hosted instances of <code>Gitlab</code> and <code>Kubernetes</code>. I'm trying to integrate both tools to implements a CI/CD. I'm trying to configure privary registry of self hosted Gitlab in Kubernetes, but  when Pod is starting, it fails when trying to pull image from registry.</p>
<p><strong>Deployment.yml</strong></p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
  namespace: ns-app
  labels:
    app: app
spec:
  replicas: 2
  selector:
    matchLabels:
      app: app
  template:
    metadata:
      labels:
        app.kubernetes.io/name: app
        app: app
    spec:
      containers:
        - name: app
          image: private-registry.gitlab.com/some-link/image:0.1.0
          ports:
            - containerPort: 8080
      imagePullSecrets:
        - name: regcred
</code></pre>
<p><strong>docker/config.json</strong></p>
<pre class="lang-json prettyprint-override"><code>{
  &quot;auths&quot;:
    {
      &quot;gitlab-registry.al.rn.leg.br&quot;:
        { 
            &quot;username&quot;: &quot;user&quot;,
            &quot;password&quot;: &quot;password&quot;
        }
    }
}
</code></pre>
<p><strong>secrets.yml</strong></p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Secret
metadata:
  name: regcred
  namespace: ns-app
type: Opaque
data:
  .dockerconfigjson: {{docker/config.json in base64}}
</code></pre>
<p>Pod is getting <strong>Forbidden 403</strong> error.</p>

v1d3rm3
<p>The problem is wrong <strong>type</strong> attribute of <strong>secrets.yml</strong>.</p>
<p>It should be: <strong>kubernetes.io/dockerconfigjson</strong></p>
<p>Final file:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Secret
metadata:
  name: regcred
  namespace: ns-app
type: kubernetes.io/dockerconfigjson
data:
  .dockerconfigjson: {{docker/config.json in base64}}
</code></pre>
