question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[aws-eks] Support S3 private bucket repository from helm deployment

See original GitHub issue

Use Case

Right now helm deployment only support public github repository. We need to read the repository from s3 private repo

Proposed Solution

I would like to help to develop the feature but would like to hear your opinion on the approach

  1. Create a s3 presign url and use the presign url to deploy the chart new HelmChart(this, 'cortexHelm', { cluster: props.cluster, chart: props.presignUrl, namespace: props.environment.cluster.namespace, values: overrides, release: 'cortex' });

  2. install S3 plugin at lambda layer: https://github.com/aws-samples/aws-lambda-layer-kubectl Use the S3 plugin to read from S3 private repo while deploy helm chart: Plugin link: https://github.com/hypnoglow/helm-s3

Other

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:10
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

8reactions
nicolai86commented, Aug 21, 2020

Filling in some details here: Let’s assume you are a CDK user which has some privately developed Helm chart which you want to deploy via eks.HelmChart construct. For simplicity you use CDK already to upload your Helm chart to S3.

You need a way to have the eks.HelmChart construct download and use these private Helm charts. Today this doesn’t work because the custom cloudformation resource which executes helm doesn’t have permissions to access this object on S3, and as a CDK user there is no way to attach the right permissions because the handler role is private.

We can make this work by introducing a helper method on eks.HelmChart, fromAsset, which grants the kubectl handler role the permissions to access the object on S3. Because permissions are created as part of the eks.HelmChart.fromAsset method we have to ensure these permissions are narrow.

In code, this would look something like this:

new eks.HelmChart(this, 'private-helm-chart', {
  chart: eks.HelmChart.fromAsset('path/to/asset.tgz')
});

Under the hood, fromAsset will create a CDK Asset and attach s3:GetObject and kms:Decrypt to the kubectl handler role. We need to change the helm handler in python slightly, like this:

     # "log in" to the cluster
    subprocess.check_call([ 'aws', 'eks', 'update-kubeconfig',
        '--role-arn', role_arn,
        '--name', cluster_name,
        '--kubeconfig', kubeconfig
    ])

    # download helm chart if hosted on s3
    if (chart is not None) and (chart.startswith('s3://')):
        bucket_name_key = chart.split('//')[1]
        bucket_name = bucket_name_key.split('/')[0]
        object_key = '/'.join(bucket_name_key.split('/')[1:])
        local_path = '/'.join(('', 'tmp', os.path.basename(object_key)))
        s3 = boto3.client('s3')
        with open(local_path, 'wb') as f:
            s3.download_fileobj(bucket_name, object_key, f)
        chart = local_path

It’s important to use the CDK Asset construct here. First we want the helm chart file to be uploaded automatically when cdk deploy is executed. Next the uploaded Helm chart must be immutable, or we risk breaking deployments/ rollbacks. Assets help here because they generate names, containing the hash of the source file.

I think it’s a relatively small change which feels idiomatic as CDK has other classes which also provide fromAsset methods. When downloading the file inside the existing code we also don’t need custom lambda layers to begin with, and we don’t generate a pre-signed url either.

What are your thoughts here, @eladb ? Will this provide a good user experience while ensuring that CDK internally generates narrow & secure IAM policies?

6reactions
polothycommented, Sep 2, 2020

Not sure if this makes anything easier, but ECR now support OCI: https://aws.amazon.com/blogs/containers/oci-artifact-support-in-amazon-ecr/

Helm can then deploy a chart that is in ECR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploy Kubernetes resources and packages using Amazon ...
Initialize an S3 bucket as a Helm repository ; Add the Amazon S3 repository to Helm. To add the repository in the client...
Read more >
Create Cloud-Native Repositories Using Helm Charts (GitHub ...
Create Cloud-Native Repositories Using Helm Charts (GitHub,AWS S3). Helm is the application package manager running on top of Kubernetes.
Read more >
Using S3 As a Helm Repository - Medium
Using S3 As a Helm Repository. Simplify your Kubernetes deployments. If you know what the title means, you're likely looking to get right...
Read more >
Deploy to AWS EKS (Kubernetes) - Bitbucket - Atlassian Support
We'll use Bitbucket Pipelines to build and push a docker image to a container registry (Docker Hub). Also, we will show how to...
Read more >
scaffoldly/s3-private-versioned/aws | Terraform Registry
Description. Create a private and versioned S3 bucket with optional SNS notifications. Usage. module "emails_bucket_live" { source ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found