Skip to content

Lab reference

This page collects what you look up again and again while running your lab. The examples use the code mmuster. Replace it everywhere with your own values from /etc/cc-lab.env. The chapters in the last column explain the reasons behind each entry.

All three VMs have the same file /etc/cc-lab.env. Scripts and checks read it with source /etc/cc-lab.env, which makes the values available as variables.

VariableMeaningChapter
CC_CODEyour personal code0.3
CC_LANGlanguage of the reports, de or en0.3
CC_FE_HOST, CC_NODE1_HOST, CC_NODE2_HOSTnames of the three VMs, such as mmuster-fe0.3
CC_FE_IP, CC_NODE1_IP, CC_NODE2_IPaddresses of the three VMs in the lab network0.3
CC_GUEST_NETthe internal network cc-net for the VMs of your cloud, a /24 in 172.16.0.0/122.3
CC_GUEST_GATEWAYthe front-end's address in cc-net, ending in .12.3
CC_GUEST_FIRST, CC_GUEST_SIZEfirst address and number of addresses for VMs, from .10 with 200 addresses2.3
CC_VNI, CC_VXLAN_GROUPidentifier and multicast group of the VXLAN2.3
CC_K3S_SERVER_IP, CC_K3S_AGENT_IPfixed addresses of k3s-server and k3s-agent, ending in .110 and .1114.2
MachineAddressRole
Front-end mmuster-feCC_FE_IP, plus CC_GUEST_GATEWAY in cc-netOpenNebula, gateway with NAT for cc-net, Gitea, OpenTofu, kubectl, backups
Nodes mmuster-node1 and mmuster-node2CC_NODE1_IP, CC_NODE2_IPKVM and libvirt for the VMs of the cloud
k3s-serverCC_K3S_SERVER_IPcontrol plane with etcd, also runs pods
k3s-agentCC_K3S_AGENT_IPnode for pods, with the advanced tasks of part 5 also for Ollama
Member VMsfrom CC_GUEST_FIRSTleases from cc-net, shown by onevnet show cc-net
Client192.168.210.10 on smartlearnKali Linux with a browser and a terminal, where you work, with your own hypervisor your PC takes this role

From the client you log in to the front-end with ssh mmuster-fe, as set up in chapter 0.5. On smartlearn the client is the Kali VM, with your own hypervisor it is your PC. You reach the VMs in cc-net only from the front-end, for example with ssh root@$CC_K3S_SERVER_IP. The fixed addresses of the three servers are in /etc/netplan/60-cc-lab.yaml, which you created with the generator's block in chapter 0.3.

ServicePortRuns onHow to reach itChapter
SSH22all VMsssh mmuster-fe, with keys only after hardening0.5, 6.1
Sunstone2616front-endhttp://<CC_FE_IP>:2616/ in the client's browser2.2
OpenNebula API2633front-endCLI and OpenTofu on the front-end4.2
Gitea3000front-endhttp://<CC_FE_IP>:3000/ before hardening, through a tunnel to the front-end afterwards4.4
OpenNebula exporter9925front-endPrometheus in the cluster5.1
node_exporter9100front-end and nodesPrometheus in the cluster5.1
Libvirt exporter9926nodesPrometheus in the cluster5.1
Kubernetes API6443k3s-serverkubectl with ~/.kube/config4.3
Web shop through Traefik80both nodestunnel -L 8081:<CC_K3S_SERVER_IP>:804.4
Argo CD30080k3s-servertunnel -L 8080:<CC_K3S_SERVER_IP>:300804.4
Prometheus30090k3s-servertunnel -L 9090:<CC_K3S_SERVER_IP>:300905.1
Alertmanager30093k3s-servertunnel -L 9093:<CC_K3S_SERVER_IP>:300935.3
Grafana30300k3s-servertunnel -L 3000:<CC_K3S_SERVER_IP>:303005.1
Language model and triage serviceas in your solutionk3sas in your solution, for example through a tunnel5.5

You open a tunnel in the client's terminal, and one connection can carry several -L options. While it stays open, the service answers at http://localhost:<local-port>/ in the client's browser.

Terminal window
ssh -L 8080:<CC_K3S_SERVER_IP>:30080 -L 3000:<CC_K3S_SERVER_IP>:30300 mmuster-fe

To reach Gitea after hardening, forward a free local port to port 3000 of the front-end, for example with -L 3001:localhost:3000. Grafana already takes local port 3000.

These files live in your user's home directory on the front-end, and only you may read them. Their content never goes into Git, a screencast or a chat with an AI assistant.

FileContentChapter
~/cc-lab/oneadmin.passpassword of oneadmin for Sunstone2.2
~/.one/one_authuser and password the OpenNebula CLI logs in with2.2
~/cc-lab/tenants/passwords and login files of the group admins3.1
~/platform/tofu/terraform.tfstateOpenTofu state with secret values, kept out of Git4.1
~/.kube/configaddress and certificate for kubectl, full rights on the cluster4.3
~/cc-lab/gitea/password of the user platform and the tokens for Git and Argo CD4.4
~/.git-credentialsthe token Git uses to push to the platform repo4.4
~/cc-lab/grafana.passpassword of admin in Grafana5.1
~/backup/k3s/etcd snapshots, the k3s token and the Sealed Secrets key6.2

The bootstrap script stores the password of admin in Argo CD in a file.

Terminal window
cat ~/cc-lab/argocd-admin.pass

The front-end also has ~/cc with the course repo, ~/platform with your platform repo and ~/cc-reports with the reports of the checks.

CommandPurpose
onehost list, onehost show <node>state, capacity and monitoring of the nodes
onehost flush <node>, onehost enable <node>empty a node and bring it back into service
onehost forceupdateread the monitoring of the nodes again right away
onevm list, onevm show <vm>VMs with state, node and address
onetemplate instantiate ubuntu --name <name>start a VM from the template
onevm terminate <vm>, onevm terminate --hard <vm>shut down and delete a VM
onevm migrate --live <vm> <node>move a running VM to another node
onevm backup -d backups <vm>back up a VM to the backup datastore
onebackupjob list, onebackupjob backup <job>list the backup jobs, start an extra backup
oneimage list, oneimage restore -d default <backup-image>list images and backups, restore a backup
onevnet show cc-netaddress range and leases of the internal network
onegroup list, onegroup show <group>member groups with quota and usage
oneuser listusers and their groups
oneshowback calculate, oneshowback listcalculate and show costs
oneflow list, oneflow show <service>OneFlow services with roles and cardinality

Run these in ~/platform/tofu after setting OPENNEBULA_USERNAME and OPENNEBULA_PASSWORD as in chapter 4.2.

CommandPurpose
tofu initdownload the providers, needed in every new copy of the repo
tofu planshow changes and drift without doing anything
tofu applyapply the code
tofu apply -replace='opennebula_virtual_machine.k3s["k3s-agent"]'rebuild one VM
tofu state list, tofu outputlist the objects in the state and the outputs
CommandPurpose
kubectl get nodes -o widenodes with state and address
kubectl get pods -A -o wideall pods with their node
kubectl -n <ns> describe pod <pod>events of a pod, such as a failed image pull
kubectl -n <ns> get events --sort-by=.lastTimestampevents of a namespace, such as FailedCreate
kubectl -n <ns> logs <pod>logs of a pod while it exists
kubectl -n <ns> rollout restart deployment <name>restart the pods of a deployment
kubectl top nodes, kubectl top pods -Acurrent CPU and memory use
kubectl -n <ns> get resourcequota,limitrange,networkpolicythe limits of a member
kubectl -n <ns> get hpastate of the autoscaler
ssh root@<CC_K3S_SERVER_IP> k3s etcd-snapshot lsetcd snapshots on the server
CommandPurpose
kubectl -n argocd get applicationsall Applications with sync and health status
kubectl -n argocd describe application <name>messages of an Application, such as a sync error
git status, git log --onelinestate of the platform repo in ~/platform
git add, git commit, git pushsend a change to Gitea, Argo CD picks it up within a minute
git revert <commit>undo a commit with a new commit
CommandPurpose
systemctl status <service>state of a service such as opennebula, gitea or cc-gateway
sudo systemctl restart <service>restart a service
journalctl -u <service> -n 50latest messages of a service
systemctl list-timerstimers such as cc-backup-k3s.timer with their next run
sudo nft list rulesetall nftables tables, including cc_gateway and cc_firewall
CommandPurpose
python3 ~/cc/checks/check.py <name>run the check of a part, such as iaas, platform or operations
python3 ~/cc/checks/check.py m1 to m4the check of a milestone with your personal values and two questions for the showing, whose report proves the base together with the screenshots, for milestone 1 with the reports of start, install and iaas as well
ls ~/cc-reportssaved reports with their hash

Text and figures are licensed under CC BY-SA 4.0 and the code under the MIT License. The sources are on GitHub.