containers-roadmap icon indicating copy to clipboard operation
containers-roadmap copied to clipboard

[EKS] [BUG]: CSR is not returning the certificate after approval in 1.21

Open ahachete opened this issue 3 years ago • 23 comments
trafficstars

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

This is a potential bug, as a) it doesn't match the service expectations; b) it doesn't happen with any previous EKS version; c) it works as expected on other, non-EKS 1.21s.

Essentially, upon submitting a Certificate Signing Request, EKS 1.21 is returning success but not including the certificate in the CSR's .status.certificate field. To reproduce please try to run:

cd /tmp
cat <<EOF | cfssl genkey - | cfssljson -bare server
{
  "hosts": [
    "label-demo",
    "label-demo.default",
    "label-demo.default.svc",
    "label-demo.default.svc.cluster.local"
  ],
  "CN": "system:node:label-demo.default.svc",
  "key": {
    "algo": "ecdsa",
    "size": 256
  },
  "names": [
    {
      "O": "system:nodes"
    }
  ]
}
EOF

cat <<EOF | kubectl apply -f -
apiVersion: certificates.k8s.io/v1
kind: CertificateSigningRequest
metadata:
  name: label-demo
spec:
  request: $(cat /tmp/server.csr | base64 | tr -d '\n')
  signerName: kubernetes.io/kubelet-serving
  usages:
  - digital signature
  - key encipherment
  - server auth
EOF

The issue was discovered and documented in detail as part of the StackGres project. Please refer to the issue there for completeness.

ahachete avatar Dec 17 '21 18:12 ahachete

Same issue here. Any traction on a resolution?

cameojokes avatar Jan 20 '22 00:01 cameojokes

any updates here?

scbunn avatar Mar 02 '22 19:03 scbunn

I also encounter this issue..

heartTorres avatar Mar 08 '22 08:03 heartTorres

After a few hours of trying to figure out what's going on, I found this open issue. Could you please share any updates?

Lupunita avatar Mar 18 '22 12:03 Lupunita

By design EKS does not issue certificates for CSRs with signerName "kubernetes.io/kubelet-serving" unless the CSR was actually requested by a kubelet. EKS's custom signer validates this by checking that the requested SANs for CSRs with signerName kubernetes.io/kubelet-serving match an actual EC2 instance's IPs/DNS names. In other words, EKS does not issue certificates for CSRs with signerName kubernetes.io/kubelet-serving posing as kubelets, it only issues certificates for CSRs with signerName kubernetes.io/kubelet-serving for actual kubelets.

If you need a certificate for a non-kubelet application, for 1.21 and below use CSR v1beta1 API and signerName legacy-unknown. For 1.22 #1397 and above, we will be documenting an alternate approach because legacy-unknown is not supported.

mikestef9 avatar Mar 18 '22 18:03 mikestef9

@mikestef9 does EKS support a signer name of kubernetes.io/kube-apiserver-client for standard Kubernetes API server client certs? Looking through docs / forums/GH I can't see anything definitive, but I've noticed that in 1.21 and 1.19 if I use that I get a cert Approved but not issued?

raesene avatar Mar 19 '22 13:03 raesene

@mikestef9 with 1.22 out, I didn’t see that procedure in the blog post by @chris-short

cdenneen avatar Apr 05 '22 10:04 cdenneen

This is now covered in our documentation https://docs.aws.amazon.com/eks/latest/userguide/cert-signing.html. I will leave this issue open for a little while to make sure what we included in v1.22 launch meets the needs outlined in this issue.

mikestef9 avatar Apr 05 '22 16:04 mikestef9

@mikestef9 is there a docs page which mentions which signers are supported? I checked kubernetes.io/kube-apiserver-client on a 1.22 cluster but I'm still seeing approved but non-issued certs. What I'm not sure of is if that's by design or not.

raesene avatar Apr 05 '22 18:04 raesene

Can you clarify what you mean by which signers. From the doc, this is signer name we support

signerName: beta.eks.amazonaws.com/app-serving

mikestef9 avatar Apr 06 '22 00:04 mikestef9

@mikestef9 so in upstream Kubernetes there are a number of in-built signers as detailed here I'm looking at one of these kubernetes.io/kube-apiserver-client and what I'm seeing is that certificate requests can be approved using that signer but the certificates are never issued.

Looking at the EKS docs, I can't see a definitive list of supported signers, so I'm not sure if the behaviour I'm seeing is a bug or working as intended.

This is a quick screenshot of what I'm seeing on EKS the cert is approved ok, but never issued. image

raesene avatar Apr 06 '22 07:04 raesene

I found the same issue on k8s 1.21 using kubernetes.io/kube-apiserver-client as a signer name. What should be the right approach? If I move to k8s 1.22, am I expected to use only custom signer as the document suggested? IMHO, the built-in signer names should work. Thank you

The output from kubectl version command:

Server Version: version.Info{Major:"1", Minor:"21+", GitVersion:"v1.21.5-eks-bc4871b", GitCommit:"5236faf39f1b7a7dabea8df12726f25608131aa9", GitTreeState:"clean", BuildDate:"2021-10-29T23:32:16Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/amd64"}

cobu2b avatar Apr 07 '22 21:04 cobu2b

By design EKS does not issue certificates for CSRs with signerName "kubernetes.io/kubelet-serving" unless the CSR was actually requested by a kubelet. EKS's custom signer validates this by checking that the requested SANs for CSRs with signerName kubernetes.io/kubelet-serving match an actual EC2 instance's IPs/DNS names. In other words, EKS does not issue certificates for CSRs with signerName kubernetes.io/kubelet-serving posing as kubelets, it only issues certificates for CSRs with signerName kubernetes.io/kubelet-serving for actual kubelets.

@mikestef9, this breaks virtual-kubelet implementations that want to support kubectl logs/exec via the vk controller, where the CSR must be signed by kubelet-serving for the vk controller pod IP. Is there any way we could relax this design constraint? Or is there another way I could get a certificate trusted by the API server for kubelet serving?

adrienjt avatar Apr 15 '22 07:04 adrienjt

I found the same issue on eks v1.19.15-eks-9c63c4 , v1.20.11-eks-f17b81 using kubernetes.io/kube-apiserver-client as a signer name.

huangjiasingle avatar Apr 15 '22 20:04 huangjiasingle

For CSRs with server auth usage the docs https://docs.aws.amazon.com/eks/latest/userguide/cert-signing.html says to use beta.eks.amazonaws.com/app-serving signer.

But what signer to use for CSRs with client auth usage?

Alevsk avatar Apr 28 '22 06:04 Alevsk

I'm the same boat with signerName: kubernetes.io/kube-apiserver-client. Can't figure out a way of getting the client CSR approved.

muchtall avatar May 02 '22 18:05 muchtall

I'm having the same question: does eks support client auth anyway?

chuyee avatar Jun 01 '22 01:06 chuyee

I'm having a similar problem with Kubelet CSR's in EKS... I have some EKS clusters in 1.21 and 1.22 versions and some Kubelets started to request by CSR but many CSRs stood in pending or approved state and few CSRs with approved and issued state.

Captura de Tela 2022-06-04 às 00 39 56

The hostname-type is the same for LaunchTemplate and Subnets with IP Name type matching with SAN DNS and IP. All these CSRs are requested by real Kubelets and fails when ControlPlane or other tools try to comunicate with Kubelet in default TLS port.

Captura de Tela 2022-06-04 às 00 49 45

Even with hostname type ip-name doesn't work :( Some idea why in a few worker nodes works?

marcos-pinheiro-ml avatar Jun 04 '22 04:06 marcos-pinheiro-ml

We are running into this as well. We need client auth support for OPA admission controller webhooks. Do we have an actual issue to track client auth? We need kubernetes.io/kube-apiserver-client to issue the cert.

dclayton-godaddy avatar Jun 21 '22 15:06 dclayton-godaddy

We are also running into this issue because we need client auth support. Using the beta.eks.amazonaws.com/app-serving as signer, it errors with

    message: 'invalid usages for eks app serving certificate: [digital signature key encipherment client auth]'
    reason: SignerValidationFailure
    status: "True"
    type: Failed

Any workaround available?

mikeshng avatar Jun 26 '22 02:06 mikeshng

~~I'm hitting this issue as well when trying to setup Vault on EKS via the HashiCorp learn guide here.~~

Following the AWS Certificate Signing Instructions does indeed work when following the Standalone Vault TLS guide with the following caveats.

  • You must be using EKS version 1.22 or higher (I was using version 1.21)
  • You must update the signerName of the csr.yaml from kubernetes.io/kubelet-serving to beta.eks.amazonaws.com/app-serving. This results in the CSR being both Approved and Issued. I'll include the updated CSR for the HashiCorp guide below.
cat <<EOF >${TMPDIR}/csr.yaml
apiVersion: certificates.k8s.io/v1
kind: CertificateSigningRequest
metadata:
  name: ${CSR_NAME}
spec:
  groups:
  - system:authenticated
  request: $(cat ${TMPDIR}/server.csr | base64 | tr -d '\r\n')
  signerName: beta.eks.amazonaws.com/app-serving
  usages:
  - digital signature
  - key encipherment
  - server auth
EOF

And here's some sample output demonstrating that it worked:

$ kubectl create -f ${TMPDIR}/csr.yaml
certificatesigningrequest.certificates.k8s.io/vault-csr created

$ kubectl certificate approve ${CSR_NAME}
certificatesigningrequest.certificates.k8s.io/vault-csr approved

$ kubectl get csr ${CSR_NAME}
NAME        AGE   SIGNERNAME                           REQUESTOR          REQUESTEDDURATION   CONDITION
vault-csr   0s    beta.eks.amazonaws.com/app-serving   kubernetes-admin   <none>              Approved,Issued

$ kubectl get secret vault-server-tls -o jsonpath='{.data.vault\.crt}' --namespace=vault-namespace | base64 -d
-----BEGIN CERTIFICATE-----
MIIEEDCCAvigAwIBAgIUBMayz5vzpUL0LHhGyv/0LzdzEKEwDQYJKoZIhvcNAQEL
...
WpEPdQITdq6DY7ZumGBWWOoRhKNr75o8YRNiFjLopDvdh/Nu
-----END CERTIFICATE-----

stevenzamborsky avatar Jul 07 '22 20:07 stevenzamborsky

If you're using EKS on Fargate, check your cluster role if its trust relationship allows AssumeRole for "eks.amazonaws.com".

grraffe avatar Jul 15 '22 07:07 grraffe

The documentation provided https://docs.aws.amazon.com/eks/latest/userguide/cert-signing.html works to have an approved, issued CSR. But existing deployed mutatingwebhook configuration has started throwing following errors:

CSR was applied via local user having admin access.

Kubectl Version: Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.0", GitCommit:"cb303e613a121a29364f75cc67d3d580833a7479", GitTreeState:"clean", BuildDate:"2021-04-08T16:31:21Z", GoVersion:"go1.16.1", Compiler:"gc", Platform:"darwin/amd64"} Server Version: version.Info{Major:"1", Minor:"22+", GitVersion:"v1.22.10-eks-84b4fe6", GitCommit:"cc6a1b4915a99f49f5510ef0667f94b9ca832a8a", GitTreeState:"clean", BuildDate:"2022-06-09T18:24:04Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}

Error message: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes"

Anybody else encountering similar issues? The current CA bundle points to eks cluster certificate authority. what should be the right config here?

#Update 1: To get rid of the error, I update the caBundle config with contents of generated cert i.e cert.pem.

gvinayakk avatar Jul 25 '22 21:07 gvinayakk

And still, what about client auth? Is there any way to auth as a client in EKS cluster without IAM(and aws-cli on a local host)? Currently I can't auth using just plain client certificates, because I was unable to sign them.

mclayer avatar Sep 22 '22 06:09 mclayer

EKS currently does not support Kubelet client auth, hence we do not currently sign client certificates.

vipulsabhaya avatar Oct 28 '22 16:10 vipulsabhaya

"EKS currently does not support Kubelet client auth, hence we do not currently sign client certificates." Would save a lot of people a lot of trouble if that line was right at the top of the docs.

mrf avatar Feb 16 '23 01:02 mrf

By design EKS does not issue certificates for CSRs with signerName "kubernetes.io/kubelet-serving" unless the CSR was actually requested by a kubelet.

May I ask @mikestef9 why this design choise? Parting from Kubernetes standard just causes issues to users and in our case I did spent quite a few hours to figure out why a previously working subsystem suddenly broke.

Also having to use beta.eks.amazonaws.com/app-serving as the signerName just screams of something which will eventually break again. Best practise would to use only stable APIs and in this case EKS going backwards is not what I want from a stable product.

garo avatar Oct 06 '23 05:10 garo