Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<YOUR-AWS_REGION>.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://<YOUR_SSH_KEY_ID>@git-codecommit.<YOUR_AWS_REGION>.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 <<EOF | kubectl -n flux-system apply -f -
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: github-keypair
namespace: flux-system
data:
known_hosts: $(ssh-keyscan -t rsa git-codecommit.<YOUR-AWS-REGION>.amazonaws.com 2>/dev/null|grep -E '^git-codecommit.<YOUR-AWS-REGION>.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.
Expand Down
2 changes: 1 addition & 1 deletion infra/lib/addons/aws-lbc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down