Skip to content
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

Use k0sproject/bootloose in place of footloose for smoke tests #552

Merged
merged 8 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 32 additions & 22 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ jobs:
strategy:
matrix:
image:
- quay.io/footloose/ubuntu18.04
- quay.io/footloose/centos7
#- quay.io/footloose/amazonlinux2
- quay.io/footloose/debian10
# - quay.io/footloose/fedora29
- quay.io/k0sproject/bootloose-alpine3.18
- quay.io/k0sproject/bootloose-amazonlinux2023
- quay.io/k0sproject/bootloose-debian12
- quay.io/k0sproject/bootloose-fedora38
- quay.io/k0sproject/bootloose-rockylinux9
- quay.io/k0sproject/bootloose-ubuntu20.04
name: Basic 1+1 smoke
needs: build
runs-on: ubuntu-20.04
Expand All @@ -101,14 +102,19 @@ jobs:
- {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}}
- {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}}
- {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}}
- {"name":"Docker Layer Caching For Footloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}
- {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}

- name: Run smoke tests
env:
LINUX_IMAGE: ${{ matrix.image }}
run: make smoke-basic

smoke-files:
strategy:
matrix:
image:
- quay.io/k0sproject/bootloose-ubuntu20.04
- quay.io/k0sproject/bootloose-alpine3.18
name: Basic file upload smoke
needs: build
runs-on: ubuntu-20.04
Expand All @@ -127,12 +133,16 @@ jobs:
- {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}}
- {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}}
- {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}}
- {"name":"Docker Layer Caching For Footloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}
- {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}

- name: Run smoke tests
run: make smoke-files

smoke-dynamic:
strategy:
matrix:
image:
- quay.io/k0sproject/bootloose-alpine3.18
name: Basic dynamic config smoke
needs: build
runs-on: ubuntu-20.04
Expand All @@ -151,7 +161,7 @@ jobs:
- {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}}
- {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}}
- {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}}
- {"name":"Docker Layer Caching For Footloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}
- {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}

- name: Run smoke tests
run: make smoke-dynamic
Expand All @@ -175,7 +185,7 @@ jobs:
- {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}}
- {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}}
- {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}}
- {"name":"Docker Layer Caching For Footloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}
- {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}

- name: Run OS override smoke test
run: make smoke-os-override
Expand All @@ -184,11 +194,10 @@ jobs:
strategy:
matrix:
image:
- quay.io/footloose/ubuntu18.04
- quay.io/footloose/centos7
#- quay.io/footloose/amazonlinux2
#- quay.io/footloose/debian10
#- quay.io/footloose/fedora29
- quay.io/k0sproject/bootloose-alpine3.18
- quay.io/k0sproject/bootloose-amazonlinux2023
- quay.io/k0sproject/bootloose-rockylinux9
- quay.io/k0sproject/bootloose-ubuntu20.04
k0s_from:
- v1.21.6+k0s.0
name: Upgrade
Expand All @@ -209,7 +218,7 @@ jobs:
- {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}}
- {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}}
- {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}}
- {"name":"Docker Layer Caching For Footloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}
- {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}

- name: Run smoke tests
env:
Expand All @@ -221,8 +230,8 @@ jobs:
strategy:
matrix:
image:
- quay.io/footloose/ubuntu18.04
- quay.io/footloose/centos7
- quay.io/k0sproject/bootloose-rockylinux9
- quay.io/k0sproject/bootloose-ubuntu20.04

name: Apply + reset
needs: build
Expand All @@ -242,7 +251,7 @@ jobs:
- {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}}
- {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}}
- {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}}
- {"name":"Docker Layer Caching For Footloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}
- {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}

- name: Run smoke tests
env:
Expand All @@ -253,8 +262,9 @@ jobs:
strategy:
matrix:
image:
- quay.io/footloose/ubuntu18.04
- quay.io/footloose/centos7
- quay.io/k0sproject/bootloose-alpine3.18
- quay.io/k0sproject/bootloose-rockylinux9
- quay.io/k0sproject/bootloose-ubuntu20.04

name: Apply + backup + reset + restore
needs: build
Expand All @@ -274,7 +284,7 @@ jobs:
- {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}}
- {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}}
- {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}}
- {"name":"Docker Layer Caching For Footloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}
- {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}

- name: Run smoke tests
env:
Expand All @@ -300,7 +310,7 @@ jobs:
- {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}}
- {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}}
- {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}}
- {"name":"Docker Layer Caching For Footloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}
- {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true}

- name: Run init smoke test
run: make smoke-init
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ INFO Tip: To access the cluster you can now fetch the admin kubeconfig using:
INFO k0sctl kubeconfig
```

You can find example Terraform and Footloose configurations in the [examples/](examples/) directory.
You can find example Terraform and [bootloose](https://github.com/k0sproject/bootloose) configurations in the [examples/](examples/) directory.

## Installation

Expand Down
File renamed without changes.
File renamed without changes.
30 changes: 15 additions & 15 deletions smoke-test/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

footloose := $(shell which footloose)
ifeq ($(footloose),)
footloose := $(shell go env GOPATH)/bin/footloose
bootloose := $(shell which bootloose)
ifeq ($(bootloose),)
bootloose := $(shell go env GOPATH)/bin/bootloose
endif

envsubst := $(shell which envsubst)
Expand All @@ -13,32 +13,32 @@ endif
k0sctl:
$(MAKE) -C .. k0sctl

$(footloose):
go install github.com/weaveworks/footloose/...@0.6.3
$(bootloose):
go install github.com/k0sproject/bootloose@latest

id_rsa_k0s:
ssh-keygen -t rsa -f ./id_rsa_k0s -N ""

smoke-basic: $(footloose) id_rsa_k0s k0sctl
smoke-basic: $(bootloose) id_rsa_k0s k0sctl
./smoke-basic.sh

smoke-dynamic: $(footloose) id_rsa_k0s k0sctl
smoke-dynamic: $(bootloose) id_rsa_k0s k0sctl
./smoke-dynamic.sh

smoke-files: $(footloose) id_rsa_k0s k0sctl
smoke-files: $(bootloose) id_rsa_k0s k0sctl
./smoke-files.sh

smoke-init: $(footloose) id_rsa_k0s k0sctl
smoke-init: $(bootloose) id_rsa_k0s k0sctl
./smoke-init.sh

smoke-upgrade: $(footloose) id_rsa_k0s k0sctl
smoke-upgrade: $(bootloose) id_rsa_k0s k0sctl
./smoke-upgrade.sh

smoke-reset: $(footloose) id_rsa_k0s k0sctl
smoke-reset: $(bootloose) id_rsa_k0s k0sctl
./smoke-reset.sh

smoke-os-override: $(footloose) id_rsa_k0s k0sctl
FOOTLOOSE_TEMPLATE=footloose.yaml.osoverride.tpl K0SCTL_CONFIG=k0sctl-single.yaml OS_RELEASE_PATH=$(realpath os-release) OS_OVERRIDE="ubuntu" ./smoke-basic.sh
smoke-os-override: $(bootloose) id_rsa_k0s k0sctl
BOOTLOOSE_TEMPLATE=bootloose.yaml.osoverride.tpl K0SCTL_CONFIG=k0sctl-single.yaml OS_RELEASE_PATH=$(realpath os-release) OS_OVERRIDE="ubuntu" ./smoke-basic.sh

smoke-backup-restore: $(footloose) id_rsa_k0s k0sctl
./smoke-backup-restore.sh
smoke-backup-restore: $(bootloose) id_rsa_k0s k0sctl
./smoke-backup-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ machines:
- count: 1
backend: docker
spec:
image: quay.io/footloose/ubuntu18.04
image: quay.io/k0sproject/bootloose-ubuntu20.04
name: manager%d
privileged: true
volumes:
Expand All @@ -23,4 +23,4 @@ machines:
- containerPort: 443
hostPort: 443
- containerPort: 6443
hostPort: 6443
hostPort: 6443
File renamed without changes.
12 changes: 6 additions & 6 deletions smoke-test/smoke-backup-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ createCluster
../k0sctl apply --config "${K0SCTL_CONFIG}" --debug

# Collect some facts so we can validate restore actually did full restore
system_ns_uid=$(footloose ssh root@manager0 -- k0s kubectl --kubeconfig "/var/lib/k0s/pki/admin.conf" get -n kube-system namespace kube-system -o template='{{.metadata.uid}}')
node_uid=$(footloose ssh root@manager0 -- k0s kubectl --kubeconfig "/var/lib/k0s/pki/admin.conf" get node worker0 -o template='{{.metadata.uid}}')
system_ns_uid=$(bootloose ssh root@manager0 -- k0s kubectl --kubeconfig "/var/lib/k0s/pki/admin.conf" get -n kube-system namespace kube-system -o template='{{.metadata.uid}}')
node_uid=$(bootloose ssh root@manager0 -- k0s kubectl --kubeconfig "/var/lib/k0s/pki/admin.conf" get node worker0 -o template='{{.metadata.uid}}')

../k0sctl backup --config "${K0SCTL_CONFIG}" --debug

# Reset the controller
footloose ssh root@manager0 -- k0s stop
footloose ssh root@manager0 -- k0s reset
bootloose ssh root@manager0 -- k0s stop
bootloose ssh root@manager0 -- k0s reset

../k0sctl apply --config "${K0SCTL_CONFIG}" --debug --restore-from "$(ls k0s_backup*.tar.gz)"

# Verify kube object UIDs match so we know we did full restore of the API objects
new_system_ns_uid=$(footloose ssh root@manager0 -- k0s kubectl --kubeconfig "/var/lib/k0s/pki/admin.conf" get -n kube-system namespace kube-system -o template='{{.metadata.uid}}')
new_system_ns_uid=$(bootloose ssh root@manager0 -- k0s kubectl --kubeconfig "/var/lib/k0s/pki/admin.conf" get -n kube-system namespace kube-system -o template='{{.metadata.uid}}')
if [ "$system_ns_uid" != "$new_system_ns_uid" ]; then
echo "kube-system UIDs do not match after restore!!!"
exit 1
fi
new_node_uid=$(footloose ssh root@manager0 -- k0s kubectl --kubeconfig "/var/lib/k0s/pki/admin.conf" get node worker0 -o template='{{.metadata.uid}}')
new_node_uid=$(bootloose ssh root@manager0 -- k0s kubectl --kubeconfig "/var/lib/k0s/pki/admin.conf" get node worker0 -o template='{{.metadata.uid}}')
if [ "$node_uid" != "$new_node_uid" ]; then
echo "worker0 UIDs do not match after restore!!!"
exit 1
Expand Down
4 changes: 2 additions & 2 deletions smoke-test/smoke-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ echo "* Starting apply"
echo "* Apply OK"

echo "* Verify hooks were executed on the host"
footloose ssh root@manager0 -- grep -q hello apply.hook
bootloose ssh root@manager0 -- grep -q hello apply.hook

echo "* Verify 'k0sctl kubeconfig' output includes 'data' block"
../k0sctl kubeconfig --config k0sctl.yaml | grep -v -- "-data"

echo "* Run kubectl on controller"
footloose ssh root@manager0 -- k0s kubectl get nodes
bootloose ssh root@manager0 -- k0s kubectl get nodes

echo "* Downloading kubectl for local test"
downloadKubectl
Expand Down
2 changes: 1 addition & 1 deletion smoke-test/smoke-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ createCluster
remoteCommand() {
local userhost="$1"
shift
footloose ssh "${userhost}" -- "$@"
bootloose ssh "${userhost}" -- "$@"
}

remoteFileExist() {
Expand Down
20 changes: 7 additions & 13 deletions smoke-test/smoke.common.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
FOOTLOOSE_TEMPLATE=${FOOTLOOSE_TEMPLATE:-"footloose.yaml.tpl"}
BOOTLOOSE_TEMPLATE=${BOOTLOOSE_TEMPLATE:-"bootloose.yaml.tpl"}

export LINUX_IMAGE="${LINUX_IMAGE:-"quay.io/footloose/ubuntu18.04"}"
export LINUX_IMAGE="${LINUX_IMAGE:-"quay.io/k0sproject/bootloose-ubuntu20.04"}"
export PRESERVE_CLUSTER="${PRESERVE_CLUSTER:-""}"
export DISABLE_TELEMETRY=true
export K0S_VERSION

createCluster() {
envsubst < "${FOOTLOOSE_TEMPLATE}" > footloose.yaml
footloose create
if [ "${LINUX_IMAGE}" = "quay.io/footloose/debian10" ]; then
for host in $(footloose status -o json|grep hostname|cut -d"\"" -f4); do
footloose ssh root@"${host}" -- rm -f /etc/machine-id /var/lib/dbus/machine-id
footloose ssh root@"${host}" -- systemd-machine-id-setup
done
fi
envsubst < "${BOOTLOOSE_TEMPLATE}" > bootloose.yaml
bootloose create
}

deleteCluster() {
# cleanup any existing cluster
envsubst < "${FOOTLOOSE_TEMPLATE}" > footloose.yaml
footloose delete && docker volume prune -f
envsubst < "${BOOTLOOSE_TEMPLATE}" > bootloose.yaml
bootloose delete && docker volume prune -f
}


Expand All @@ -37,6 +31,6 @@ downloadKubectl() {
case $(uname -m) in
arm,arm64) ARCH="arm64" ;;
esac
[ -f kubectl ] || (curl -L https://storage.googleapis.com/kubernetes-release/release/v1.21.3/bin/"${OS}"/${ARCH}/kubectl > ./kubectl && chmod +x ./kubectl)
[ -f kubectl ] || (curl -L https://storage.googleapis.com/kubernetes-release/release/v1.28.2/bin/"${OS}"/${ARCH}/kubectl > ./kubectl && chmod +x ./kubectl)
./kubectl version --client
}