-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a smoke-test for non-root login user
Signed-off-by: Kimmo Lehto <[email protected]>
- Loading branch information
Showing
5 changed files
with
89 additions
and
2 deletions.
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
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 sh | ||
|
||
K0SCTL_CONFIG=${K0SCTL_CONFIG:-"k0sctl.yaml"} | ||
SSH_USER=${SSH_USER:-"k0sctl-user"} | ||
|
||
set -e | ||
|
||
|
||
. ./smoke.common.sh | ||
trap cleanup EXIT | ||
|
||
deleteCluster | ||
createCluster | ||
|
||
for host in manager0 worker0; do | ||
echo "* Creating ${SSH_USER} on ${host}" | ||
bootloose ssh "root@${host}" -- groupadd --system k0sctl-admin | ||
bootloose ssh "root@${host}" -- useradd -m -G k0sctl-admin -p '*' "${SSH_USER}" | ||
bootloose ssh "root@${host}" -- echo "'%k0sctl-admin ALL=(ALL)NOPASSWD:ALL'" '>/etc/sudoers.d/k0sctl-admin' | ||
bootloose ssh "root@${host}" -- chmod 0440 /etc/sudoers.d/k0sctl-admin | ||
bootloose ssh "root@${host}" -- mkdir -p "/home/${SSH_USER}/.ssh" | ||
bootloose ssh "root@${host}" -- cp '/root/.ssh/*' "/home/${SSH_USER}/.ssh/" | ||
bootloose ssh "root@${host}" -- chown -R "${SSH_USER}:${SSH_USER}" "/home/${SSH_USER}/.ssh" | ||
done | ||
|
||
echo "* Starting apply" | ||
../k0sctl apply --config "${K0SCTL_CONFIG}" --kubeconfig-out applykubeconfig --debug | ||
echo "* Apply OK" | ||
|
||
echo "* Verify hooks were executed on the host" | ||
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" | ||
bootloose ssh root@manager0 -- k0s kubectl get nodes | ||
|
||
echo "* Downloading kubectl for local test" | ||
downloadKubectl | ||
|
||
echo "* Using the kubectl from apply" | ||
./kubectl --kubeconfig applykubeconfig get nodes | ||
|
||
echo "* Using k0sctl kubecofig locally" | ||
../k0sctl kubeconfig --config k0sctl.yaml > kubeconfig | ||
|
||
echo "* Output:" | ||
grep -v -- -data kubeconfig | ||
|
||
echo "* Running kubectl" | ||
./kubectl --kubeconfig kubeconfig get nodes | ||
echo "* Done" |