-
Notifications
You must be signed in to change notification settings - Fork 272
add dev setup guide #656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add dev setup guide #656
Changes from 8 commits
fc0dedb
5d15aea
0e37d6c
65448f7
5b612aa
f72e407
d495557
94254c4
d122bfd
dd3878f
0434277
f71b780
4807978
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,4 +35,3 @@ jobs: | |
|
||
- name: make test | ||
run: make test | ||
working-directory: ./src |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
### Go ### | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
# Tools directory. | ||
bin/ | ||
|
||
# Generated symlinks. | ||
cmd/**/kodata/ | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
.idea/ | ||
|
||
# Output of the go build for the cmd binary | ||
/node-termination-handler | ||
# Kubernetes Generated files - skip generated files, except for vendored files | ||
!vendor/**/zz_generated.* | ||
|
||
### Go Patch ### | ||
/vendor/ | ||
/Godeps/ | ||
/build/ | ||
# Editor and IDE paraphernalia | ||
.idea | ||
*.swp | ||
*.swo | ||
*~ |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# Setup Development Environment | ||
|
||
## 1. Clone the repo | ||
|
||
```sh | ||
git clone --branch v2 https://github.com/aws/aws-node-termination-handler.git nthv2 | ||
cd nthv2 | ||
``` | ||
|
||
## 2. Set environment variables | ||
|
||
*Tip:* Several steps in this guide, and utility scripts, use environment variables. Saving these environment variables in a file, or using a shell extension like [direnv](https://direnv.net), will make it easy to restore your development environment in a new shell instance. | ||
|
||
```sh | ||
export CLUSTER_NAME=<name> | ||
export AWS_REGION=<region> | ||
``` | ||
|
||
## 3. Create a basic EKS Cluster | ||
cjerad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Skip this set if you already have an EKS cluster. | ||
|
||
```sh | ||
envsubst <resources/eks-cluster.yaml.tmpl | eksctl create cluster --kubeconfig "${PWD}/kubeconfig" -f - | ||
|
||
export KUBECONFIG="$PWD/kubeconfig" | ||
``` | ||
|
||
If you do not want to use `envsubst` you can copy the template file and substitute the referenced values. | ||
|
||
## 4. Create Infrastructure | ||
|
||
cjerad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```sh | ||
export INFRASTRUCTURE_STACK_NAME="nth-${CLUSTER_NAME}" | ||
|
||
aws cloudformation deploy \ | ||
--template-file resources/infrastructure.yaml \ | ||
--stack-name "${INFRASTRUCTURE_STACK_NAME}" \ | ||
--capabilities CAPABILITY_NAMED_IAM \ | ||
--parameter-overrides ClusterName="${CLUSTER_NAME}" | ||
|
||
export DEV_INFRASTRUCTURE_STACK_NAME="${INFRASTRUCTURE_STACK_NAME}-dev" | ||
|
||
aws cloudformation deploy \ | ||
--template-file resources/dev-infrastructure.yaml \ | ||
--stack-name "${DEV_INFRASTRUCTURE_STACK_NAME}" \ | ||
--parameter-overrides ClusterName="${CLUSTER_NAME}" | ||
|
||
export QUEUE_NAME=<name> | ||
export QUEUE_STACK_NAME="${INFRASTRUCTURE_STACK_NAME}-queue-${QUEUE_NAME}" | ||
|
||
aws cloudformation deploy \ | ||
--template-file resources/queue-infrastructure.yaml \ | ||
--stack-name "${QUEUE_STACK_NAME}" \ | ||
--parameter-overrides \ | ||
ClusterName="${CLUSTER_NAME}" \ | ||
QueueName="${QUEUE_NAME}" | ||
``` | ||
|
||
## 5. Connect Infrastructure to EKS Cluster | ||
|
||
```sh | ||
export CLUSTER_NAMESPACE=<namespace> | ||
export SERVICE_ACCOUNT_NAME="nth-${CLUSTER_NAME}-serviceaccount" | ||
|
||
eksctl create iamserviceaccount \ | ||
--cluster "${CLUSTER_NAME}" \ | ||
--namespace "${CLUSTER_NAMESPACE}" \ | ||
--name "${SERVICE_ACCOUNT_NAME}" \ | ||
--role-name "${SERVICE_ACCOUNT_NAME}" \ | ||
--attach-policy-arn $(./scripts/get-cfn-stack-output.sh "${INFRASTRUCTURE_STACK_NAME}" ServiceAccountPolicyARN) \ | ||
--role-only \ | ||
--approve | ||
|
||
export SERVICE_ACCOUNT_ROLE_ARN=$(eksctl get iamserviceaccount \ | ||
--cluster "${CLUSTER_NAME}" \ | ||
--namespace "${CLUSTER_NAMESPACE}" \ | ||
--name "${SERVICE_ACCOUNT_NAME}" \ | ||
--output json | \ | ||
jq -r '.[0].status.roleARN') | ||
``` | ||
|
||
## 6. Configure and Login to Image Repository | ||
|
||
```sh | ||
export KO_DOCKER_REPO=$(./scripts/get-cfn-stack-output.sh "${DEV_INFRASTRUCTURE_STACK_NAME}" RepositoryBaseURI) | ||
|
||
./scripts/docker-login-ecr.sh | ||
``` | ||
|
||
## 7. Build and deploy controller to EKS cluster | ||
|
||
```sh | ||
make apply | ||
``` | ||
|
||
### 7.1. (Optional) Providing additional Helm values | ||
|
||
The `apply` target sets some Helm chart values for you based on environment variables. To set additional Helm values use the `HELM_OPTS` make argument. For example: | ||
|
||
```sh | ||
make HELM_OPTS='--set logging.level=debug' apply | ||
``` | ||
|
||
## 8. Define and deploy a Terminator to EKS cluster | ||
|
||
```sh | ||
export TERMINATOR_NAME=<name> | ||
export QUEUE_URL=$(./scripts/get-cfn-stack-output.sh "${QUEUE_STACK_NAME}" QueueURL) | ||
|
||
envsubst <resources/terminator.yaml.tmpl >terminator-${TERMINATOR_NAME}.yaml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar to previous section, I think it's better to state what needs to be done (substitution) and let user decide how to do it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I view this as a how-to guide. When I'm reading a how-to guide I prefer clear and detailed instructions rather than the implementation being left as "an exercise for the reader". Specifically referencing the use of |
||
|
||
kubectl apply -f terminator-${TERMINATOR_NAME}.yaml | ||
``` | ||
|
||
If you do not want to use `envsubst` you can copy the template file and substitute the referenced values. | ||
|
||
## 9. Remove deployed controller from EKS cluster | ||
|
||
```sh | ||
make delete | ||
``` | ||
|
||
# Tear down Development Environment | ||
|
||
```sh | ||
make delete | ||
|
||
eksctl delete cluster --name "${CLUSTER_NAME}" | ||
|
||
aws cloudformation delete-stack --stack-name "${QUEUE_STACK_NAME}" | ||
|
||
./scripts/clear-image-repo.sh "$(./scripts/get-cfn-stack-output.sh ${DEV_INFRASTRUCTURE_STACK_NAME} ControllerRepositoryName)" | ||
./scripts/clear-image-repo.sh "$(./scripts/get-cfn-stack-output.sh ${DEV_INFRASTRUCTURE_STACK_NAME} WebhookRepositoryName)" | ||
aws cloudformation delete-stack --stack-name "${DEV_INFRASTRUCTURE_STACK_NAME}" | ||
|
||
aws cloudformation delete-stack --stack-name "${INFRASTRUCTURE_STACK_NAME}" | ||
``` |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.