bitter-father-26598
10/02/2023, 1:38 PMconst 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
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 Unauthorizedbillowy-army-68599
bitter-father-26598
10/02/2023, 1:44 PM