-
Notifications
You must be signed in to change notification settings - Fork 24
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
Adding eks-customer module #731
Conversation
@@ -0,0 +1,101 @@ | |||
module "eks" { | |||
source = "terraform-aws-modules/eks/aws" | |||
version = "20.14.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets make version variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this isn't possible due to terraform limitations. hashicorp/terraform#28912
namespace_service_accounts = ["${each.value.name}:${each.value.service_account}"] | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
while_repo_exists | ||
git clone "https://${GIT_REPO_USERNAME}:${GITLAB_OAUTH_TOKEN}@${GIT_HOST}/${GIT_REPO_PATH}" $gitops_sre_dir | ||
git config --global user.name "${GIT_REPO_USERNAME}" | ||
git config --global user.email "${GIT_REPO_USERNAME}@mattermost.com" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make it $GIT_REPO_URL
|
||
module "irsa" { | ||
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks" | ||
version = "5.44.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this version should be hardcoded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, let's make it variable Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this isn't possible due to terraform limitations. hashicorp/terraform#28912
@@ -0,0 +1,132 @@ | |||
#/usr/bin/env bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#/usr/bin/env bash | |
#!/usr/bin/env bash |
|
||
function create_cluster_folder() { | ||
echo "Creating custom values file" | ||
mkdir $gitops_apps_dir/${ENV}/helm-values/${CLUSTER_NAME} || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|| true
suppresses all errors, was there any reason for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to avoid errors when the file already exists.
sed -i "s/<CLUSTER_ID>/${CLUSTER_NAME}/g" $gitops_apps_dir/${ENV}/helm-values/${CLUSTER_NAME}/$utility_name-custom-values.yaml | ||
sed -i "s/<ENV>/${ENV}/g" $gitops_apps_dir/${ENV}/helm-values/${CLUSTER_NAME}/$utility_name-custom-values.yaml | ||
sed -i "s/<CLUSTER_ID>/${CLUSTER_NAME}/g" $gitops_apps_dir/${ENV}/helm-values/${CLUSTER_NAME}/$utility_name-custom-values.yaml | ||
sed -i "s/<CERTFICATE_ARN>/$certificate_arn/g" $gitops_apps_dir/${ENV}/helm-values/${CLUSTER_NAME}/$utility_name-custom-values.yaml | ||
sed -i "s/<PRIVATE_CERTIFICATE_ARN>/$private_certificate_arn/g" $gitops_apps_dir/${ENV}/helm-values/${CLUSTER_NAME}/$utility_name-custom-values.yaml | ||
sed -i "s/<VPC_ID>/${VPC_ID}/g" $gitops_apps_dir/${ENV}/helm-values/${CLUSTER_NAME}/$utility_name-custom-values.yaml | ||
sed -i "s/<PRIVATE_DOMAIN>/${PRIVATE_DOMAIN}/g" $gitops_apps_dir/${ENV}/helm-values/${CLUSTER_NAME}/$utility_name-custom-values.yaml | ||
sed -i "s/<IP_RANGE>/$allow_list_cidr_range/g" $gitops_apps_dir/${ENV}/helm-values/${CLUSTER_NAME}/$utility_name-custom-values.yaml | ||
sed -i "s/hostNetwork: false/hostNetwork: true/g" $gitops_apps_dir/${ENV}/helm-values/${CLUSTER_NAME}/$utility_name-custom-values.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe something
sed -i -e "s/<CLUSTER_ID>/${CLUSTER_NAME}/g" \
-e "s/<ENV>/${ENV}/g" \
-e "s/<CERTIFICATE_ARN>/$certificate_arn/g" \
... \
"$target_file"
since the target file is the same
sed -i "s/<CLUSTER_ID>/${CLUSTER_NAME}/g" $gitops_apps_dir/${ENV}/helm-values/${CLUSTER_NAME}/$utility_name-custom-values.yaml | ||
sed -i "s/<ENV>/${ENV}/g" $gitops_apps_dir/${ENV}/helm-values/${CLUSTER_NAME}/$utility_name-custom-values.yaml | ||
sed -i "s/<CLUSTER_ID>/${CLUSTER_NAME}/g" $gitops_apps_dir/${ENV}/helm-values/${CLUSTER_NAME}/$utility_name-custom-values.yaml | ||
sed -i "s/<CERTFICATE_ARN>/$certificate_arn/g" $gitops_apps_dir/${ENV}/helm-values/${CLUSTER_NAME}/$utility_name-custom-values.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a typo: CERTFICATE_ARN
maybe CERTIFICATE_ARN
clone_repo | ||
remove_utilities | ||
remove_helm_values | ||
wait_for_argocd | ||
remove_cluster | ||
clean_up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clone_repo and clean_up funcs exist in other script, will they be available in that main?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, because I'm "loading" them into the script
source $(dirname "$0")/utils.sh
clone_repo | ||
add_cluster | ||
create_cluster_folder | ||
deploy_utility | ||
clean_up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clone_repo and clean_up funcs exist in other script, will they be available in that main?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, because I'm "loading" them into the script
source $(dirname "$0")/utils.sh
@@ -0,0 +1,47 @@ | |||
#/usr/bin/env bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#/usr/bin/env bash | |
#!/usr/bin/env bash |
aws/eks-customer/scripts/utils.sh
Outdated
@@ -0,0 +1,88 @@ | |||
#/usr/bin/env bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#/usr/bin/env bash | |
#!/usr/bin/env bash |
echo "Commiting changes: Adding cluster ${CLUSTER_NAME}" | ||
commit_changes "Remove utilities: ${CLUSTER_NAME}" $gitops_apps_dir/${ENV}/helm-values | ||
fi | ||
echo "No helm values found for cluster ${CLUSTER_NAME}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message is printed regardless of whether the directory exists or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo "No helm values found for cluster ${CLUSTER_NAME}" | |
else | |
echo "No helm values found for cluster ${CLUSTER_NAME}" | |
fi |
not sure if that's better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
} | ||
|
||
function remove_cluster() { | ||
local cluster_id=$1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope! good catch. old value.
Summary
This PR will add a new module to create EKS clusters + deploy utilities using Argocd.
Ticket Link
https://mattermost.atlassian.net/browse/CLD-7696
Release Note