diff --git a/README.md b/README.md index 13707b2..82d6ffb 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,71 @@ podinfo-746d58c87-gjkdl 1/1 Running 0 2m3s podinfo-746d58c87-qfjwk 1/1 Running 0 2m3s ``` +### 4. (Alternative) Using AWS CodeCommit for source control +You can also use [AWS CodeCommit](https://aws.amazon.com/codecommit/) to host your private repository. In order to do so, follow the step below. + +#### 4.1. Create and clone your AWS Codecommit repository + +Create an AWS Codecommit repository using +``` +aws codecommit create-repository --repository-name MyDemoRepo --repository-description "My demonstration repository" +``` + +Setup your git credentials in AWS IAM following those [instructions](https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-gc.html) (Steps 1, 2, 3 only). + +Clone the repository using the below command. Replace `YOUR-AWS_REGION` with your AWS region (e.g. eu-west-1). Use your newly created git credentials when asked for. +``` +git clone https://git-codecommit..amazonaws.com/v1/repos/MyDemoRepo my-demo-repo +``` + +#### 4.2. Copy and Push the GitHub repository content to your new repository + +Clone the repository `git clone https://github.com/aws-samples/aws-cdk-eks-fluxv2-example.git ./github-repository` + +copy the content to our AWS Codecommit repository `(mkdir my-demo-repo/k8s-config; cp -R github-repository/k8s-config/* my-demo-repo/k8s-config) &` + +Commit and push the changes `(cd my-demo-repo; git add .; git commit -m "first commit"; git push) &` + +#### 4.3. Setting up the SSH connection to AWS Codecommit + +Follow Step 3 of on this [page](https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-ssh-unixes.html) of the AWS Codecommit documentation. + +#### 4.4. Deploy the infrastructure + +Jump into the the `github-repository/infra/` directory and deploy the CDK stack, passing along a set of parameters to +the CDK command. These parameters define which git repository, branch, and path in that repository +that will be used for initial flux bootstrapping of the cluster. + +```shell +cd github-repository/infra/ + +npm i + +cdk deploy InfraStack \ + --parameters FluxRepoURL="ssh://@git-codecommit..amazonaws.com/v1/repos/MyDemoRepo" \ + --parameters FluxRepoBranch="master" \ + --parameters FluxRepoPath="./k8s-config/clusters/demo" +``` + +### 4.5. Create a Kubernetes secret +Use the following script to craft and apply the secret to the flux-system namespace + +```bash +#!/bin/sh +cat <.amazonaws.com 2>/dev/null|grep -E '^git-codecommit..amazonaws\.com'|base64 | tr -d '\n') + identity: $(cat ${HOME}/.ssh/codecommit_rsa |base64 | tr -d '\n') + 'identity.pub': $(cat ${HOME}/.ssh/codecommit_rsa.pub|base64 | tr -d '\n') +EOF +``` + ## Security See [CONTRIBUTING](CONTRIBUTING.md) for more information. diff --git a/infra/lib/addons/aws-lbc.ts b/infra/lib/addons/aws-lbc.ts index 4a8e22a..fcd3602 100644 --- a/infra/lib/addons/aws-lbc.ts +++ b/infra/lib/addons/aws-lbc.ts @@ -22,7 +22,7 @@ export class AWSLoadBalancerController extends cdk.Construct { }); const awsLbcCrdsUrl = 'https://raw.githubusercontent.com/aws/eks-charts/master/stable/aws-load-balancer-controller/crds/crds.yaml' - const awsLbcCrdsManifest = yaml.loadAll(request.default('GET', awsLbcCrdsUrl).getBody().toString()); + const awsLbcCrdsManifest : any = yaml.loadAll(request.default('GET', awsLbcCrdsUrl).getBody().toString()); const awsLbcCrdsManifestResource = props.cluster.addManifest('awsLbcCrdManifest', ...awsLbcCrdsManifest); const chart = props.cluster.addHelmChart('AWSLBCHelmChart', {