Skip to content

Commit

Permalink
Make the vm env smaller
Browse files Browse the repository at this point in the history
On github actions we cannot start a vm with more than one cpu, and our
test cluster is very small so it should work with 1g of ram. This makes
the test cluster consume less resources if a developer leave it running
for long time.

Using 1 cpu and 1 GiB memory conflict with kubeadm preflight checks:

    [init] Using Kubernetes version: v1.31.0
    ...
    error execution phase preflight: [preflight] Some fatal errors occurred:
        [ERROR NumCPU]: the number of available CPUs 1 is less than the required 2
        [ERROR Mem]: the system RAM (956 MB) is less than the minimum 1700 MB
    [preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`

Since we know we are doing, we suppress these preflight errors.

Example cpu and memory usage on started cluster:

    $ top -b -n 1 -w 100 | head
    top - 02:45:36 up 11 min,  1 user,  load average: 0.20, 0.29, 0.19
    Tasks: 122 total,   1 running, 121 sleeping,   0 stopped,   0 zombie
    %Cpu(s): 10.0 us,  0.0 sy,  0.0 ni, 90.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    MiB Mem :    956.4 total,     48.2 free,    631.9 used,    356.5 buff/cache
    MiB Swap:      0.0 total,      0.0 free,      0.0 used.    324.5 avail Mem

        PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
          1 root      20   0   22720   9672   5320 S   0.0   1.0   0:01.67 systemd
          2 root      20   0       0      0      0 S   0.0   0.0   0:00.00 kthreadd
          3 root      20   0       0      0      0 S   0.0   0.0   0:00.00 pool_workqueue_release

    $ free -h
                   total        used        free      shared  buff/cache   available
    Mem:           956Mi       630Mi        46Mi       2.6Mi       360Mi       326Mi
    Swap:             0B          0B          0B

If we will have memory issues during tests, we can increase memory to
2g. But it seems that we have plenty of memory for testing drenv on a
basically empty and idle cluster.

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
  • Loading branch information
nirs committed Sep 20, 2024
1 parent d6bdad9 commit 944a2cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion test/drenv/providers/lima/k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,13 @@ provision:
featureGates:
StatefulSetAutoDeletePVC: true
EOF
kubeadm init --config kubeadm-config.yaml
# We ignore NumCPU and Mem preflight errors for running a minimal cluster
# in github actions and for testing drenv.
# [ERROR NumCPU]: the number of available CPUs 1 is less than the required 2
# [ERROR Mem]: the system RAM (956 MB) is less than the minimum 1700 MB
kubeadm init --config kubeadm-config.yaml --ignore-preflight-errors NumCPU,Mem
# Installing a Pod network add-on
kubectl apply -f https://github.com/flannel-io/flannel/releases/download/v0.24.0/kube-flannel.yml
# Control plane node isolation
Expand Down
3 changes: 2 additions & 1 deletion test/envs/vm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ profiles:
- name: cluster
driver: $vm
container_runtime: containerd
memory: "3g"
cpus: 1
memory: "1g"
workers:
- addons:
- name: example

0 comments on commit 944a2cc

Please sign in to comment.