aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.51k stars 3.85k forks source link

aws-eks: addHelmChart not accepting SSL certificate from public JupyterHub helm chart #25747

Open youngjeong46 opened 1 year ago

youngjeong46 commented 1 year ago

Describe the bug

We are using EKS Blueprints to provision an EKS cluster with a JupyterHub addon. JupyterHub addon uses its public helm chart and adds to the EKS cluster using addHelmChart (jupyterhub v2.0 from https://hub.jupyer.org/helm-chart/). It has been working until recently, when it started producing an error with unknown authority, and rolls back.

The certificate was recently renewed per index.yaml, but the chart deploys successfully when using Helm CLI. We have explored the option of bypassing SSL using insecure-skip-tls-verify flag, but it is not an option available under addHelmChart nor is security best practice.

Expected Behavior

Deploys the helm chart successfully.

Current Behavior

When the CDK deploys with added JupyterHub addon, we get the following error:

Message returned: Error: b'Release "blueprints-addon-jupyterhub" does not exist. Installing it now.\nError: looks like "https://hub.jupyter.org/helm-chart/" is not a valid chart repository or cannot be reached: Get "https://hub.jupyter.org/helm-chart/index.yaml": x509: certificate signed by unknown authority\n'

Reproduction Steps

  1. git clone https://github.com/aws-quickstart/cdk-eks-blueprints.git
  2. In the directory, run npm i.
  3. Then deploy an example stack: npx cdk deploy blueprint-construct-dev

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.78.0

Framework Version

No response

Node.js Version

16.16.0

OS

13.3.1

Language

Typescript

Language Version

No response

Other information

No response

melodyyangaws commented 1 year ago

+1 have the same error when install the jupyerhub chart via the eks_cluster.add_helm_chart() in CDKv2 (Python). Manually helm install works though. How to workaround it in CDK?

pahud commented 1 year ago

How did you manually install the helm chart? Can you share command with full arguments? Are you suggesting to have an option in aws-eks to turn on insecure-skip-tls-verify for addHelmChart() ?

youngjeong46 commented 1 year ago

How did you manually install the helm chart? Can you share command with full arguments?

Yes, using helm cli: helm install blueprints-addon-jupyterhub jupyterhub/jupyterhub --version 2.0.0 -n jupyterhub --create-namespace

Are you suggesting to have an option in aws-eks to turn on insecure-skip-tls-verify for addHelmChart() ?

This would probably be a good immediate solution, although I'm not certain that would align with best practices.

nikhil-sharma31 commented 1 year ago

Is this resolved? I am also facing the same issue Even after using insecure-skip-tls-verify, it does not resolve

nikhil-sharma31 commented 1 year ago

I was able to resolve this by updating certificates on my server sudo yum update ca-certificates sudo yum reinstall ca-certificates

melodyyangaws commented 1 year ago

any update on the issue team? there are multiple CDK projects are impacted, including some workshop content for our public events.

melodyyangaws commented 1 year ago

How did you manually install the helm chart? Can you share command with full arguments?

just the usual helm install commandhelm install jhub jupyterhub/jupyterhub --values chart/jupyter-values.yaml --version 1.2.0 -n jupyter, it works. But the manual workaround doesn't fit in our case, since we have to automate the installation via CDK. A series of setups are depending on the jupyterhub installation outcome, such as ALB and CloudFront CDK templates. Is there any workaround in CDK so far?

javydekoning commented 1 year ago

I think add_helm_chart() uses a Custom Resource handler (node14.x).

Trusted CA's are hardcoded in NodeJS.

hub.jupyter.org uses GTS:

openssl s_client -servername hub.jupyter.org -connect hub.jupyter.org:443 -showcerts
CONNECTED(00000006)
depth=2 C = US, O = Google Trust Services LLC, CN = GTS Root R4
verify return:1
depth=1 C = US, O = Google Trust Services LLC, CN = GTS CA 2P2
verify return:1
depth=0 CN = jupyter.org
verify return:1
write W BLOCK
---
Certificate chain
 0 s:/CN=jupyter.org
   i:/C=US/O=Google Trust Services LLC/CN=GTS CA 2P2
-----BEGIN CERTIFICATE-----
MIID2zCCA4KgAwIBAgIQdEwksZMlZA4RcP9cTeZAhTAKBggqhkjOPQQDAjBGMQsw
CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzET
MBEGA1UEAxMKR1RTIENBIDJQMjAeFw0yMzA1MTcwMzMwMDlaFw0yMzA4MTUwMzMw
MDhaMBYxFDASBgNVBAMTC2p1cHl0ZXIub3JnMFkwEwYHKoZIzj0CAQYIKoZIzj0D
AQcDQgAErDLj8FR4nnkG7oOeTI0FbLSyabnuWOPibTK8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b5fsdexUuVGoB
MVwsDPGd7VC13Y0OBezt7FqFHDwqm8nnVdV/FkNyXNv9/AIxAN51NGqMcbexMOYK
pLC0zXfjNwvqBsZhmzCCQIM6MVyBID0rjjxPu7laIaHqAu6T5Q==
-----END CERTIFICATE-----
---
Server certificate
subject=/CN=jupyter.org
issuer=/C=US/O=Google Trust Services LLC/CN=GTS CA 2P2
---
No client certificate CA names sent
Server Temp Key: ECDH, X25519, 253 bits
---
SSL handshake has read 2094 bytes and written 375 bytes
---
New, TLSv1/SSLv3, Cipher is AEAD-CHACHA20-POLY1305-SHA256
Server public key is 256 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.3
    Cipher    : AEAD-CHACHA20-POLY1305-SHA256
    Session-ID:
    Session-ID-ctx:
    Master-Key:
    Start Time: 1686656154
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
---

The hardcoded root cert here: https://github.com/nodejs/node/blob/v14.x/src/node_root_certs.h#L3267-L3279

dgraeber commented 1 year ago

Thanks for more info! Our build (in CodeBuild) is leveraging Node16. I'd hate to modify our CICD to use charts that are embedded (rather than fetching from a repo). Any thoughts as to how to mitigate this via CDK constructs?

pepito-j commented 1 year ago

Doesn't look like it's actually being caused by NodeJS. Checking the handler, it uses Python 3.7 as it's runtime for handling HelmChart:

The associated code that runs the helm installation is here:

So, it seems like an issue with Python 3.7 certs instead. I updated the onEvent handler function to 3.8 out-of-band and was able to get a successful deployment.

melodyyangaws commented 1 year ago

great finding, thanks @pepito-j ! The python3.7 is already end of life support since last month (Jun 2023), do you think it's caused by the EOL? To unblock us quickly, could you please PR the code change and get the team reviewed? highly appreciate it.

melodyyangaws commented 1 year ago

CDK team, when can we have the fixed rollout? Our upcoming events are impacted, especially the one at the end of the year. Highly appreciate your attention and urgency in addressing the issue.