Skip to content

Commit

Permalink
Merge pull request #1765 from weaveworks/custom-dev-env
Browse files Browse the repository at this point in the history
make dev cluster creation more configurable
  • Loading branch information
makkes authored Oct 28, 2022
2 parents c82a163 + 5461f34 commit c8d1ae2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ tilt_modules

# build flag artifacts
tools/core-files

# ignore custom scripts and generated config
/tools/custom/
/tools/kind-config.yaml
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ reconcile from a GitOps repository in your personal GitHub account. It will also
create a file containing local settings such as your GitOps repository that the
enterprise Helm chart will use in the next step.

### Customizing your development environment

#### Custom kind configuration

The `reboot.sh` script has the capability to patch the default kind config
using custom configuration provided in the `./tools/custom/` directory. Place
any configuration you'd like in a file matching the pattern `kind-cluster-patch-*.yaml`
in that directory and it will get merged into the base configuration.

#### Custom scripts

The `reboot.sh` script will execute all scripts it finds in `./tools/custom/` that
match the file name pattern `*.sh` after creating the cluster and installing
all components.

### Start environment

To start the development environment, run
Expand Down
4 changes: 4 additions & 0 deletions tools/dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ binarypath="https://kind.sigs.k8s.io/dl/v${version}/kind-${goos}-${goarch}"
[clusterctl]
version="1.1.3"
binarypath="https://github.com/kubernetes-sigs/cluster-api/releases/download/v${version}/clusterctl-${goos}-${goarch}"

[yq]
version="4.28.2"
binarypath="https://github.com/mikefarah/yq/releases/download/v${version}/yq_${goos}_${goarch}"
25 changes: 23 additions & 2 deletions tools/reboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,17 @@ tool_check() {

do_kind() {
tool_check "kind"
tool_check "yq"

if [ -n "$(ls "$(dirname "$0")"/custom/kind-cluster-patch-*.yaml 2> /dev/null)" ] ; then
"${TOOLS}"/yq eval-all '. as $item ireduce ({}; . *d $item)' "$(dirname "$0")"/kind-cluster-with-extramounts.yaml "$(dirname "$0")"/custom/kind-cluster-patch-*.yaml > "$(dirname "$0")"/kind-config.yaml
else
cp "$(dirname "$0")"/kind-cluster-with-extramounts.yaml "$(dirname "$0")"/kind-config.yaml
fi

${TOOLS}/kind delete cluster --name "$KIND_CLUSTER_NAME"
${TOOLS}/kind create cluster --name "$KIND_CLUSTER_NAME" \
--config "$(dirname "$0")/kind-cluster-with-extramounts.yaml"
--config "$(dirname "$0")/kind-config.yaml"
}

do_capi(){
Expand Down Expand Up @@ -82,10 +89,11 @@ add_files_to_git(){
mkdir -p "/tmp/$GITHUB_REPO/clusters/bases/networkpolicy"
cp "$(dirname "$0")/git-files/wego-admin.yaml" "/tmp/$GITHUB_REPO/clusters/bases/rbac/wego-admin.yaml"
cp "$(dirname "$0")/git-files/flux-system-networkpolicy.yaml" "/tmp/$GITHUB_REPO/clusters/bases/networkpolicy/flux-system-networkpolicy.yaml"
cd "/tmp/$GITHUB_REPO"
pushd "/tmp/$GITHUB_REPO"
git add clusters/bases
git commit -m "Add wego-admin role"
git push origin main
popd
}

# Steps we ask you to do in https://docs.gitops.weave.works/docs/cluster-management/getting-started/
Expand All @@ -94,13 +102,26 @@ follow_capi_user_guide(){
kubectl create secret generic my-pat --from-literal GITHUB_TOKEN="$GITHUB_TOKEN" --from-literal GITHUB_USER="$GITHUB_USER" --from-literal GITHUB_REPO="$GITHUB_REPO"
}

run_custom_scripts(){
pwd
echo "$(dirname "$0")"
for f in "$(dirname "$0")"/custom/*.sh ; do
echo "$f"
if [ -x "$f" ] ; then
echo executing "$f"
$f
fi
done
}

main() {
github_env_check
do_kind
do_capi
do_flux
create_local_values_file
follow_capi_user_guide
run_custom_scripts
}

main

0 comments on commit c8d1ae2

Please sign in to comment.