-
Notifications
You must be signed in to change notification settings - Fork 115
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 kind-dev command to start a kind dev cluster #338
Open
Julian-Chu
wants to merge
9
commits into
aws-controllers-k8s:main
Choose a base branch
from
Julian-Chu:feat/add_kind-dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c936ecd
refactor controller-setup.sh
Julian-Chu 9829372
add kind-dev cmd
Julian-Chu c55529e
add info to run controller
Julian-Chu 7140ad3
update comment in run-dev.sh
Julian-Chu 177a044
rename to create-dev-cluster.sh
Julian-Chu 7779b28
refactor ensure_cluster
Julian-Chu 6e7926d
clean up
Julian-Chu 4c321c2
move args into top of function
Julian-Chu 4ed9f07
fix message
Julian-Chu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env bash | ||
|
||
# ./scripts/create-dev-cluster.sh quickly setup cluster for ACK development. It | ||
# ensures that a K8s cluster is accessible, then configures the ACK CRD, RBAC | ||
# but not install the controller | ||
|
||
set -Eeo pipefail | ||
|
||
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
ROOT_DIR="$SCRIPTS_DIR/.." | ||
|
||
AWS_SERVICE=$(echo "${AWS_SERVICE:-""}" | tr '[:upper:]' '[:lower:]') | ||
|
||
CONTROLLER_NAMESPACE=${CONTROLLER_NAMESPACE:-"ack-system"} | ||
|
||
CLUSTER_NAME="ack-dev-cluster-$AWS_SERVICE" | ||
|
||
source "$SCRIPTS_DIR/lib/aws.sh" | ||
source "$SCRIPTS_DIR/lib/common.sh" | ||
source "$SCRIPTS_DIR/lib/config.sh" | ||
source "$SCRIPTS_DIR/lib/logging.sh" | ||
|
||
source "$SCRIPTS_DIR/controller-setup.sh" | ||
source "$SCRIPTS_DIR/kind.sh" | ||
source "$SCRIPTS_DIR/run-e2e-tests.sh" | ||
|
||
run() { | ||
ensure_aws_credentials | ||
ensure_cluster "$CLUSTER_NAME" false | ||
local kubeconfig_path="$ROOT_DIR/build/clusters/$CLUSTER_NAME/kubeconfig" | ||
info_msg "After executing the above source command to set the kubeconfig to environment, " | ||
info_msg "run the following command to start the controller from the controller repo:" | ||
echo "" | ||
echo "go run ./cmd/controller/main.go --aws-region $(get_aws_region) --log-level debug --enable-development-logging" | ||
echo "" | ||
exit $? | ||
} | ||
|
||
ensure_inputs() { | ||
[[ -z "$AWS_SERVICE" ]] && { error_msg "Expected \`AWS_SERVICE\` to be defined"; exit 1; } || : | ||
} | ||
|
||
ensure_binaries() { | ||
check_is_installed "kubectl" | ||
} | ||
|
||
ensure_inputs | ||
ensure_binaries | ||
|
||
# The purpose of the `return` subshell command in this script is to determine | ||
# whether the script was sourced, or whether it is being executed directly. | ||
# https://stackoverflow.com/a/28776166 | ||
(return 0 2>/dev/null) || run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -30,16 +30,29 @@ source "$SCRIPTS_DIR/pytest-image-runner.sh" | |||||
|
||||||
ensure_cluster() { | ||||||
local cluster_create="$(get_cluster_create)" | ||||||
if [[ "$cluster_create" == true ]]; then | ||||||
local cluster_name=$(_get_kind_cluster_name) | ||||||
|
||||||
if [[ "$cluster_create" != true ]]; then | ||||||
info_msg "Testing connection to existing cluster ..." | ||||||
_ensure_existing_context | ||||||
else | ||||||
local cluster_name=$(get_cluster_name) | ||||||
local controller_install=${2:-true} | ||||||
# naming cluster in the following order: | ||||||
# 1. cluster_name is set in config file | ||||||
# 2. cluster_name is passed as function argument. using this for dev cluster | ||||||
# 3. generate cluster_name with random prefix | ||||||
[ -z "$cluster_name" ] && cluster_name=$1 | ||||||
[ -z "$cluster_name" ] && cluster_name=$(_get_kind_cluster_name) | ||||||
|
||||||
info_msg "Creating KIND cluster ..." | ||||||
setup_kind_cluster "$cluster_name" "$CONTROLLER_NAMESPACE" | ||||||
|
||||||
build_and_install_controller "$cluster_name" "$CONTROLLER_NAMESPACE" "$CONTROLLER_IMAGE_TAG" | ||||||
else | ||||||
info_msg "Testing connection to existing cluster ..." | ||||||
_ensure_existing_context | ||||||
info_msg "Installing CRDs , common and RBAC manifest..." | ||||||
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.
Suggested change
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. fixed 4ed9f07 |
||||||
install_crd_and_rbac "$CONTROLLER_NAMESPACE" | ||||||
|
||||||
if [[ "$controller_install" == true ]]; then | ||||||
build_and_install_controller "$cluster_name" "$CONTROLLER_NAMESPACE" "$CONTROLLER_IMAGE_TAG" | ||||||
fi | ||||||
fi | ||||||
} | ||||||
|
||||||
|
@@ -92,7 +105,7 @@ _ensure_existing_context() { | |||||
|
||||||
run() { | ||||||
ensure_aws_credentials | ||||||
ensure_cluster | ||||||
ensure_cluster "" | ||||||
|
||||||
build_and_run_tests | ||||||
exit $? | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you please move all of the positional arguments into local variables at the top of this method, so that it's clear what the inputs are. Then you can copy them into their respective variables further down in the method as needed.
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.
moved 4c321c2