Fix docker push unauthorized: mount config.json, not .dockerconfigjson
Confirmed via a direct token request to Harbor's own token endpoint
(same username/password from harbor-robot-dockerconfig) that the
robot account genuinely has push access to homelab/demo-go-app —
Harbor returned a valid token with actions:[pull,push]. So the actual
`docker push` failure ("unauthorized... action: push") wasn't a
permissions problem at all.
Root cause: kubernetes.io/dockerconfigjson secrets are required to
store their data under the fixed key `.dockerconfigjson`. Mounting
the secret without remapping that key meant the file that actually
landed at /root/.docker was named `.dockerconfigjson`, not
`config.json` — the only filename docker's CLI reads for stored
credentials. Docker found nothing there and pushed unauthenticated,
which Harbor correctly rejected. Adds an items: remap so the mounted
file is named config.json.
This commit is contained in:
@@ -72,3 +72,18 @@ spec:
|
||||
- name: docker-config
|
||||
secret:
|
||||
secretName: harbor-robot-dockerconfig
|
||||
# kubernetes.io/dockerconfigjson secrets store their data under
|
||||
# the fixed key `.dockerconfigjson` (mandated, since that's what
|
||||
# kubelet reads for imagePullSecrets) — without this remap, the
|
||||
# mounted file at /root/.docker is literally named
|
||||
# `.dockerconfigjson`, not `config.json`, which is the only
|
||||
# filename the docker CLI itself ever reads for stored
|
||||
# credentials. Docker found nothing there and silently pushed
|
||||
# unauthenticated, which Harbor correctly rejected as
|
||||
# unauthorized — confirmed the robot account/credentials
|
||||
# themselves were fine the whole time by requesting a push token
|
||||
# directly from Harbor's token endpoint with the same username/
|
||||
# password and getting one back with push access granted.
|
||||
items:
|
||||
- key: .dockerconfigjson
|
||||
path: config.json
|
||||
|
||||
Reference in New Issue
Block a user