Support 8GB Macs

pull/634/head
fireflycons 2024-03-19 06:08:42 +00:00
parent 65b5a11784
commit fef56c1942
5 changed files with 21 additions and 14 deletions

View File

@ -17,11 +17,8 @@ echo -e "${BLUE}Checking system compatibility${NC}"
MEM_GB=$(( $(sysctl hw.memsize | cut -d ' ' -f 2) / 1073741824 )) MEM_GB=$(( $(sysctl hw.memsize | cut -d ' ' -f 2) / 1073741824 ))
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/scripts SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/scripts
if [ $MEM_GB -lt 12 ] CPMEM="2048M"
then WNMEM="2048M"
echo -e "${RED}System RAM is ${MEM_GB}GB. This is insufficient to deploy a working cluster.${NC}"
exit 1
fi
if ! command -v multipass > /dev/null if ! command -v multipass > /dev/null
then then
@ -35,13 +32,21 @@ then
exit 1 exit 1
fi fi
if [ $MEM_GB -lt 15 ]
then
CPMEM="768M"
WNMEM="512M"
echo -e "${YELLOW}System RAM is ${MEM_GB}GB. VM size is reduced."
echo -e "It will not be possible for you to run E2E tests (final step).${NC}"
fi
specs=/tmp/vm-specs specs=/tmp/vm-specs
cat <<EOF > $specs cat <<EOF > $specs
controlplane01,2,2048M,10G controlplane01,2,${CPMEM},10G
controlplane02,2,2048M,5G controlplane02,2,${CPMEM},5G
loadbalancer,1,512M,5G loadbalancer,1,512M,5G
node01,2,2048M,5G node01,2,${WNMEM},5G
node02,2,2048M,5G node02,2,${WNMEM},5G
EOF EOF
echo -e "${GREEN}System OK!${NC}" echo -e "${GREEN}System OK!${NC}"
@ -74,7 +79,7 @@ do
multipass purge multipass purge
fi fi
echo -e "${BLUE}Launching ${node}${NC}" echo -e "${BLUE}Launching ${node}. CPU: ${cpus}, MEM: ${ram}${NC}"
multipass launch --disk $disk --memory $ram --cpus $cpus --name $node jammy multipass launch --disk $disk --memory $ram --cpus $cpus --name $node jammy
echo -e "${GREEN}$node booted!${NC}" echo -e "${GREEN}$node booted!${NC}"
done done

View File

@ -5,7 +5,7 @@
This lab provisions 5 VMs on your workstation. That's a lot of compute resource! This lab provisions 5 VMs on your workstation. That's a lot of compute resource!
* Apple Silicon System (M1/M2/M3 etc) * Apple Silicon System (M1/M2/M3 etc)
* Minimum 16GB RAM.<br/>Bear in mind that the unified memory architecture of Apple Silicon Macs means that the whole of the quoted memory is not available for software - some of it is used for the display, more if you have external displays.<br/>This rules out 8GB models - sorry. * 8GB RAM (16GB recommended).<br/>Bear in mind that the unified memory architecture of Apple Silicon Macs means that the whole of the quoted memory is not available for software - some of it is used for the display, more if you have external displays. With less than 16GB, significantly smaller VMs will be deployed, which will not be sufficient to run the final step E2E tests.
* Pro or Max CPU recommended for running the e2e-tests at the end of this lab. * Pro or Max CPU recommended for running the e2e-tests at the end of this lab.
## Required Software ## Required Software

View File

@ -49,7 +49,7 @@ Run the following steps on `controlplane01`
For the workers(kubelet) to access the Certificates API, they need to authenticate to the kubernetes api-server first. For this we create a [Bootstrap Token](https://kubernetes.io/docs/reference/access-authn-authz/bootstrap-tokens/) to be used by the kubelet For the workers(kubelet) to access the Certificates API, they need to authenticate to the kubernetes api-server first. For this we create a [Bootstrap Token](https://kubernetes.io/docs/reference/access-authn-authz/bootstrap-tokens/) to be used by the kubelet
Bootstrap Tokens take the form of a 6 character token id followed by 16 character token secret separated by a dot. Eg: abcdef.0123456789abcdef. More formally, they must match the regular expression [a-z0-9]{6}\.[a-z0-9]{16} Bootstrap Tokens take the form of a 6 character token id followed by 16 character token secret separated by a dot. Eg: abcdef.0123456789abcdef. More formally, they must match the regular expression `[a-z0-9]{6}\.[a-z0-9]{16}`
Set an expiration date for the bootstrap token of 7 days from now (you can adjust this) Set an expiration date for the bootstrap token of 7 days from now (you can adjust this)
@ -460,7 +460,9 @@ At `node02` node, run the following, selecting option 5
Now, go back to `controlplane01` and approve the pending kubelet-serving certificate Now, go back to `controlplane01` and approve the pending kubelet-serving certificate
[//]: # (host:controlplane01) [//]: # (host:controlplane01)
[//]: # (command:sudo apt install -y jq) [//]: # (command:sudo apt install -y jq)
[//]: # (command:kubectl certificate approve --kubeconfig admin.kubeconfig $(kubectl get csr --kubeconfig admin.kubeconfig -o json | jq -r '.items | .[] | select(.spec.username == "system:node:node02") | .metadata.name')) [//]: # (command:kubectl certificate approve --kubeconfig admin.kubeconfig $(kubectl get csr --kubeconfig admin.kubeconfig -o json | jq -r '.items | .[] | select(.spec.username == "system:node:node02") | .metadata.name'))
```bash ```bash

View File

@ -48,7 +48,7 @@ Reference: https://kubernetes.io/docs/tasks/administer-cluster/coredns/#installi
Create a `busybox` pod: Create a `busybox` pod:
```bash ```bash
kubectl run busybox -n default --image=busybox:1.28 --restart Never --command -- sleep 15 kubectl run busybox -n default --image=busybox:1.28 --restart Never --command -- sleep 180
``` ```
[//]: # (command:kubectl wait pods -n default -l run=busybox --for condition=Ready --timeout=90s) [//]: # (command:kubectl wait pods -n default -l run=busybox --for condition=Ready --timeout=90s)

View File

@ -1,6 +1,6 @@
# Run End-to-End Tests # Run End-to-End Tests
Optional Lab. Optional Lab. If you are running this on a system with less than 16GB RAM, this step will almost certainly fail spectacularly.
Observations by Alistair (KodeKloud): Observations by Alistair (KodeKloud):