Skip to content

Commit

Permalink
Strict patch
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsakalozos authored and berkayoz committed Dec 5, 2024
1 parent bd1ef3b commit dd31718
Show file tree
Hide file tree
Showing 14 changed files with 558 additions and 24 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/build-snap.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Build and test MicroK8s snap

on:
pull_request:
branches:
- master
- push

jobs:
build:
Expand Down Expand Up @@ -58,7 +56,7 @@ jobs:
path: build
- name: Running upgrade path test
run: |
sudo -E UPGRADE_MICROK8S_FROM=latest/edge UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap pytest -s ./tests/test-upgrade-path.py
sudo -E STRICT=yes UPGRADE_MICROK8S_FROM=latest/edge/strict UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap pytest -s ./tests/test-upgrade-path.py
test-addons-core:
name: Test core addons
Expand All @@ -81,13 +79,15 @@ jobs:
with:
name: microk8s.snap
path: build
- name: Running addons tests
- name: Running addons tests in strict mode
run: |
set -x
sudo snap install build/microk8s.snap --classic --dangerous
sudo snap install build/microk8s.snap --dangerous
sudo /snap/microk8s/current/connect-all-interfaces.sh
sudo microk8s status --wait-ready --timeout 300
./tests/smoke-test.sh
export UNDER_TIME_PRESSURE="True"
export SKIP_PROMETHEUS="False"
export STRICT="yes"
sudo -E bash -c "cd /var/snap/microk8s/common/addons/core/tests; pytest -s -ra test-addons.py"
test-addons-community:
Expand Down Expand Up @@ -117,8 +117,11 @@ jobs:
run: |
set -x
sudo snap install build/microk8s.snap --classic --dangerous
sudo /snap/microk8s/current/connect-all-interfaces.sh
sudo microk8s status --wait-ready --timeout 300
sudo microk8s enable community
export UNDER_TIME_PRESSURE="True"
export STRICT="yes"
sudo -E bash -c "cd /var/snap/microk8s/common/addons/community/; pytest -s -ra ./tests/"
test-addons-core-upgrade:
Expand Down Expand Up @@ -148,7 +151,8 @@ jobs:
run: |
set -x
export UNDER_TIME_PRESSURE="True"
sudo -E bash -c "UPGRADE_MICROK8S_FROM=latest/edge UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap pytest -s ./tests/test-upgrade.py"
export STRICT="yes"
sudo -E bash -c "UPGRADE_MICROK8S_FROM=latest/edge/strict UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap pytest -s ./tests/test-upgrade.py"
test-cluster-agent:
name: Cluster agent health check
Expand All @@ -173,6 +177,7 @@ jobs:
run: |
set -x
sudo snap install build/microk8s.snap --classic --dangerous
sudo /snap/microk8s/current/connect-all-interfaces.sh
sudo -E bash -c "pytest -s ./tests/test-cluster-agent.py"
test-airgap:
Expand Down
9 changes: 8 additions & 1 deletion docs/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,16 @@ lxc file pull test-build/root/microk8s/microk8s_v1.9.6_amd64.snap .
After copying it, you can install it with:

```shell
snap install microk8s_*_amd64.snap --classic --dangerous
snap install microk8s_*_amd64.snap --dangerous
```

Finally, you need to connect the interfaces. To this end you can use the `connect-all-interfaces.sh`:

```shell
sudo /snap/microk8s/current/connect-all-interfaces.sh
```


## Assembling the Calico CNI manifest

The calico CNI manifest can be found under `upgrade-scripts/000-switch-to-calico/resources/calico.yaml`.
Expand Down
35 changes: 35 additions & 0 deletions microk8s-resources/connect-all-interfaces.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

set -u

if [ "$EUID" -ne 0 ]
then echo "Please run this script as root."
exit 1
fi

for i in account-control \
docker-privileged \
kubernetes-support \
k8s-journald \
k8s-kubelet \
k8s-kubeproxy \
dot-kube \
network \
network-bind \
network-control \
network-observe \
firewall-control \
process-control \
kernel-module-observe \
mount-observe \
hardware-observe \
system-observe \
home \
opengl \
home-read-all \
login-session-observe \
log-observe \
dot-config-helm
do
snap connect microk8s:$i
done
6 changes: 6 additions & 0 deletions snap/hooks/connect-plug-configuration
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -eux

cp "$SNAP/content-interface/launcher/configuration/"*.yaml "$SNAP_COMMON/etc/launcher/" || true
cp "$SNAP/content-interface/launcher/sideload/"*.tar "$SNAP_COMMON/etc/sideload/" || true
3 changes: 3 additions & 0 deletions snap/hooks/disconnect-plug-configuration
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

set -eux
3 changes: 2 additions & 1 deletion snap/hooks/install
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ if ! is_strict && cat /proc/1/environ | grep "container=lxc" &> /dev/null
fi
fi

cp -r --preserve=mode ${SNAP}/default-args ${SNAP_DATA}/args
mkdir -p ${SNAP_DATA}/args
cp -r --preserve=mode ${SNAP}/default-args/* ${SNAP_DATA}/args
mv ${SNAP_DATA}/args/certs.d/localhost__32000 ${SNAP_DATA}/args/certs.d/localhost:32000

SNAP_DATA_CURRENT=`echo "${SNAP_DATA}" | sed -e "s,${SNAP_REVISION},current,"`
Expand Down
Loading

0 comments on commit dd31718

Please sign in to comment.