kubernetes: Cannot specify client cert and client key in image pull secret

I have searched for all issues containing “client cert pull” and also “docker-registry”. I’ve located one issue which is strongly related, but not the same. Ideally mutual TLS authentication is handled in one improvement. #41040 Asks how to use a server cert (ca.crt) without adding to /etc/docker/certs.d on each node and seems to incorrectly states that the client cert and key can be specified with kubectl secret docker-registry (AFAIK, the client cert and client key that can be specified are used to connect to the API server. They are definitely not added to the generated secret).

Kubernetes version (use kubectl version):

Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"08e099554f3c31f6e6f07b448ab3ed78d0520507", GitTreeState:"clean", BuildDate:"2017-
01-12T04:57:25Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"08e099554f3c31f6e6f07b448ab3ed78d0520507", GitTreeState:"clean", BuildDate:"2017-
01-12T04:52:34Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}

Environment:

  • Cloud provider or hardware configuration: GKE with gCloud Shell for kubectl
  • OS (e.g. from /etc/os-release): Debian GNU/Linux 8 (jessie)
  • Kernel (e.g. uname -a): Linux cs-6282-devshell-vm-7d07fe2a-a8f5-4e2d-bf2b-e8c744a77ad3-2d1 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1 (2016-12-30) x86_64 GNU/Linux

What happened:

$ kubectl create secret docker-registry image-pull \
--docker-username=my-username \
--docker-password="my-password" \
--docker-server="my-registry.example.com" \
--client-certificate=/etc/docker/certs.d/my-registry.example.com/client.cert \
--client-key=/etc/docker/certs.d/my-registry.example.com/client.key \
--docker-email="my-email@example.com"
$ kubectl get secret image-pull -o yaml | grep dockercfg\: | awk '{print $2}' | base64 -D
{"my-registry.example.com":{"username":"my-username","password":"my-password","email":"my-mail@example.com","auth":"bXktdXNlcm5hbWU6bXktcGFzc3dvcmQ="}}
# No client cert!

What you expected to happen: I expect the client-certificate and client-key to be part of the secret so that they are used during image pull.

How to reproduce it (as minimally and precisely as possible): Create a client certificate and then attempt to add it to a pull secret:

# create a self-signed client certificate as an example
$ openssl req -nodes -new -x509 -keyout client.key -out client.cert
# other instructions above

In story form: Use a docker registry that requires a client certificate for authentication. Attempt to add a client cert to a pull secret and use that cert for pulling images. It seems that the only way to use a client cert is by adding the cert and key to the /etc/docker/certs.d/{registry} directory on every host. This is not possible in many environments, including GKE.

Anything else we need to know: Even if the client cert and key were stored within the Secret object, I think that’s only half the problem. The cert and key would also need to be used by docker for the image pull and I think the only supported method is files on the host. This might require changes upstream within docker to work? I don’t think kubectl will write the client cert and key onto each host, which may be an information leakage problem.

I’m creating this issue to initiate or locate a discussion about how to configure mutual TLS authentication/client cert authentication for image pulls.

Update: Perhaps Kubernetes could be a Docker Credential Helper?

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 11
  • Comments: 18 (5 by maintainers)

Most upvoted comments

This seems like it’s still an issue. Has no one used client certs to talk to a docker registry within Kubernetes?

Fastforward to 2023 still no support for mutual TLS authentication for pulling images.

@deepflame: You can’t reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.