Skip to content

Recreate kind cluster on every evg host reboot #32

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions scripts/dev/delete_om_projects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ delete_project "${NAMESPACE}"

if [[ "${WATCH_NAMESPACE:-}" != "" && "${WATCH_NAMESPACE:-}" != "*" ]]; then
for ns in ${WATCH_NAMESPACE/,// }; do
delete_project "${ns}" || true
if [[ "${ns}" != "${NAMESPACE}" ]]; then
delete_project "${ns}" || true
fi
done
fi


3 changes: 2 additions & 1 deletion scripts/dev/evg_host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ configure() {

sync() {
rsync --verbose --archive --compress --human-readable --recursive --progress \
--delete --delete-excluded --max-size=1000000 --prune-empty-dirs \
--delete --max-size=1000000 --prune-empty-dirs \
-e ssh \
--include-from=.rsyncinclude \
--exclude-from=.gitignore \
Expand Down Expand Up @@ -115,6 +115,7 @@ recreate-kind-cluster() {

tunnel() {
shift 1
get-kubeconfig
# shellcheck disable=SC2016
api_servers=$(yq '.contexts[].context.cluster as $cluster | .clusters[] | select(.name == $cluster).cluster.server' < "${kubeconfig_path}" | sed 's/https:\/\///g')
echo "Extracted the following API server urls from ${kubeconfig_path}: ${api_servers}"
Expand Down
15 changes: 15 additions & 0 deletions scripts/dev/kindclusters.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Recreate kind clusters at boot
After=docker.service
Requires=docker.service

[Service]
Type=oneshot
WorkingDirectory=/home/ubuntu/ops-manager-kubernetes
Environment=HOME=/home/ubuntu
ExecStart=/home/ubuntu/ops-manager-kubernetes/scripts/dev/recreate_kind_clusters.sh
ExecStart=/home/ubuntu/ops-manager-kubernetes/scripts/dev/recreate_kind_cluster.sh kind
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
4 changes: 1 addition & 3 deletions scripts/dev/recreate_kind_clusters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ set -Eeou pipefail
source scripts/dev/set_env_context.sh
source scripts/funcs/kubernetes

if [[ "${DELETE_KIND_NETWORK:-"false"}" == "true" ]]; then
delete_kind_network
fi
kind delete clusters --all

# first script prepares registry, so to avoid race it have to finish running before we execute subsequent ones in parallel
# To future maintainers: whenever modifying this bit, make sure you also update coredns.yaml
Expand Down
3 changes: 3 additions & 0 deletions scripts/dev/setup_evg_host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ sudo sysctl -w fs.inotify.max_user_instances=8192
echo "Increasing fs.inotify.max_user_watches"
sudo sysctl -w fs.inotify.max_user_watches=10485760

sudo cp /home/ubuntu/ops-manager-kubernetes/scripts/dev/kindclusters.service /etc/systemd/system/kindclusters.service
sudo systemctl enable kindclusters.service

# retrieve arch variable off the shell command line
ARCH=${1-"amd64"}

Expand Down