Skip to content

Commit

Permalink
feat: use k8s snap in dev preset
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsgruk committed Oct 31, 2024
1 parent d806c08 commit 4a7fdf9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
22 changes: 11 additions & 11 deletions internal/config/presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ var defaultJujuConfig jujuConfig = jujuConfig{
"test-mode": "true",
"automatically-retry-hooks": "false",
},
BootstrapConstraints: map[string]string{
// This seems to only take effect when bootstrapping Kubernetes controllers.
// There it is needed because with the K8s snap, local storage is provisioned
// using pre-allocated files. The default is 20G, which on Github Actions
// runners is more than the available disk space, meaning no pods can be
// scheduled.
"root-disk": "2G",
},
}

// defaultPackages is the set of packages installed for all presets.
Expand Down Expand Up @@ -86,15 +94,7 @@ var machinePreset *Config = &Config{
// k8sPreset is a configuration preset designed to be used when testing
// k8s charms.
var k8sPreset *Config = &Config{
Juju: jujuConfig{
ModelDefaults: map[string]string{
"test-mode": "true",
"automatically-retry-hooks": "false",
},
BootstrapConstraints: map[string]string{
"root-disk": "2G",
},
},
Juju: defaultJujuConfig,
Providers: providerConfig{
// Enable LXD so charms can be built, but don't bootstrap onto it.
LXD: lxdConfig{Enable: true},
Expand Down Expand Up @@ -126,8 +126,8 @@ var microk8sPreset *Config = &Config{
var devPreset *Config = &Config{
Juju: defaultJujuConfig,
Providers: providerConfig{
LXD: defaultLXDConfig,
MicroK8s: defaultMicroK8sConfig,
LXD: defaultLXDConfig,
K8s: defaultK8sConfig,
},
Host: hostConfig{
Packages: defaultPackages,
Expand Down
4 changes: 2 additions & 2 deletions internal/juju/juju_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestJujuHandlerCommandsPresets(t *testing.T) {
expectedCommands: []string{
"snap install juju",
"sudo -u test-user juju show-controller concierge-lxd",
"sudo -u test-user -g lxd juju bootstrap localhost concierge-lxd --verbose --model-default automatically-retry-hooks=false --model-default test-mode=true",
"sudo -u test-user -g lxd juju bootstrap localhost concierge-lxd --verbose --model-default automatically-retry-hooks=false --model-default test-mode=true --bootstrap-constraints root-disk=2G",
"sudo -u test-user juju add-model -c concierge-lxd testing",
},
expectedDirs: []string{".local/share/juju"},
Expand All @@ -99,7 +99,7 @@ func TestJujuHandlerCommandsPresets(t *testing.T) {
expectedCommands: []string{
"snap install juju",
"sudo -u test-user juju show-controller concierge-microk8s",
"sudo -u test-user -g snap_microk8s juju bootstrap microk8s concierge-microk8s --verbose --model-default automatically-retry-hooks=false --model-default test-mode=true",
"sudo -u test-user -g snap_microk8s juju bootstrap microk8s concierge-microk8s --verbose --model-default automatically-retry-hooks=false --model-default test-mode=true --bootstrap-constraints root-disk=2G",
"sudo -u test-user juju add-model -c concierge-microk8s testing",
},
expectedDirs: []string{".local/share/juju"},
Expand Down
6 changes: 3 additions & 3 deletions tests/overrides-env/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ execute: |
export CONCIERGE_ROCKCRAFT_CHANNEL=latest/edge
export CONCIERGE_SNAPCRAFT_CHANNEL=latest/edge
export CONCIERGE_LXD_CHANNEL=latest/candidate
export CONCIERGE_MICROK8S_CHANNEL=1.30-strict/candidate
export CONCIERGE_K8S_CHANNEL=1.31/beta
export CONCIERGE_EXTRA_SNAPS="node/22/stable"
export CONCIERGE_EXTRA_DEBS="make"
Expand All @@ -29,8 +29,8 @@ execute: |
list="$(snap list lxd)"
echo $list | MATCH latest/candidate
list="$(snap list microk8s)"
echo $list | MATCH 1.30-strict/candidate
list="$(snap list k8s)"
echo $list | MATCH 1.31/beta
list="$(snap list node)"
echo $list | MATCH 22/stable
Expand Down
17 changes: 8 additions & 9 deletions tests/preset-dev/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@ execute: |
"$SPREAD_PATH"/concierge --trace prepare -p dev
# Check that relevant snaps are installed
for s in juju microk8s lxd kubectl jq yq charmcraft rockcraft snapcraft; do
for s in juju k8s lxd kubectl jq yq charmcraft rockcraft snapcraft; do
snap list "$s" | MATCH $s
done
# Check the relevant debs are installed
command -v pip | MATCH /usr/bin/pip
python3 -m venv -h | head -n1 | grep -q -e "usage: venv"
# Ensure MicroK8s is configured as expected
sudo microk8s status --format yaml | yq '.addons[] | select(.name=="hostpath-storage") | .status'
sudo microk8s status --format yaml | yq '.addons[] | select(.name=="dns") | .status'
sudo microk8s status --format yaml | yq '.addons[] | select(.name=="metallb") | .status'
sudo k8s status --output-format yaml | yq '.dns.enabled' | MATCH true
sudo k8s status --output-format yaml | yq '.load-balancer.enabled' | MATCH true
sudo k8s status --output-format yaml | yq '.load-balancer.message' | MATCH "enabled, L2 mode"
sudo k8s get | yq '.load-balancer.cidrs' | MATCH "10.43.45.0/28"
# Ensure that kubectl was configured correctly
kubectl config current-context | MATCH "microk8s"
kubectl config current-context | MATCH "k8s"
# Ensure the juju controllers are bootstrapped and have models
for i in concierge-microk8s:admin/testing concierge-lxd:admin/testing; do
# Ensure the juju controllers are bootstrapped and have `m`odels
for i in concierge-k8s:admin/testing concierge-lxd:admin/testing; do
juju switch $i
juju model-defaults | grep test-mode | tr -s " " | MATCH "test-mode false true"
juju model-defaults | grep automatically-retry-hooks | tr -s " " | MATCH "automatically-retry-hooks true false"
Expand Down

0 comments on commit 4a7fdf9

Please sign in to comment.