I am trying to make a deployment with a private do...
# kubernetes
b
I am trying to make a deployment with a private docker image on dockerhub so I create a secret .
Copy code
const secret = new k8s.core.v1.Secret("docker-registry-secret", {
    type: "kubernetes.io/dockerconfigjson",
    metadata: {
      name: "docker-registry-secret",
      // namespace: "default"  // adjust this if you're using a different namespace
    },
    data: {
      ".dockerconfigjson": pulumi.interpolate`{
            "auths": {
                "<https://index.docker.io/v1/>": {
                    "username": "${username}",
                    "password": "${password}",
                    "email": "${email}",
                    "auth": "${pulumi.secret(Buffer.from(`${username}:${password}`).toString('base64'))}"
                }
            }
        }`.apply(creds => Buffer.from(creds).toString("base64"))
    }
});
Then I use the secret
Copy code
const app = new k8s.apps.v1.Deployment(appDeploymentName, {
    spec: {
      selector: {matchLabels: appLabels},
      replicas: 1,
      template: {
        metadata: {labels: appLabels},
        spec: {
          containers: [{
            name: name,
            image: `${dockerImage}:${version}`,
          }],
          imagePullSecrets:[{
            name: secret.metadata.name
          }]
        },
      }
    }
  }, {dependsOn: [secret]});
But I keep getting the Error that it failed to pull the image: Failed to pull image myRepo/myImage. failed to authorize: failed to fetch oauth token: unexpected status: 401 Unauthorized
b
this looks like you’re creating a Kubernetes secret for docker hub, where is the auth issue occuring?
b
@billowy-army-68599 sorry please see edit.
I am using the secret in the above deployment