Introduction

Elemental uses the Rancher System Agent, renamed to Elemental System Agent, to initially bootstrap the node with a simple plan.

The plan will apply the following configurations:

  • Set some labels for the node
  • Set the proper hostname according to the MachineInventory value
  • Install the default Rancher System Agent from Rancher Server, and install the proper Kubernetes components

The bootstrap service also accepts local plans stored under /var/lib/elemental/agent/plans. Any plan written in there will also be applied during the initial node start after the installation is completed.

Elemental plans - 图1tip

The local plans run only during the initial Elemental bootstrap before Kubernetes is installed on the node.

Types of Plans

The type of plans that Elemental can use are:

  • One time instructions: Only run once
  • Periodic instructions: They run periodically
  • Files: Creates files
  • Probes: http probes

Elemental plans - 图2tip

Both one time instructions and periodic instructions can run either a direct command or a docker image.

Adding local plans on Elemental

You can add local plans to Elemental as part of the MachineRegistration CRD, in the cloud-config section as follows:

  1. apiVersion: elemental.cattle.io/v1beta1
  2. kind: MachineRegistration
  3. metadata:
  4. name: my-nodes
  5. namespace: fleet-default
  6. spec:
  7. config:
  8. cloud-config:
  9. users:
  10. - name: root
  11. passwd: root
  12. write_files:
  13. - path: /var/lib/elemental/agent/plans/mycustomplan.plan
  14. permissions: "0600"
  15. content: |
  16. {"instructions":
  17. [
  18. {
  19. "name":"set hostname",
  20. "command":"hostnamectl",
  21. "args": ["set-hostname", "myHostname"]
  22. },
  23. {
  24. "name":"stop sshd service",
  25. "command":"systemctl",
  26. "args": ["stop", "sshd"]
  27. }
  28. ]
  29. }
  30. elemental:
  31. install:
  32. reboot: true
  33. device: /dev/sda
  34. debug: true
  35. machineName: my-machine
  36. machineInventoryLabels:
  37. element: fire

Plan examples

The following plans are provided as a quick reference and are not guaranteed to work in your environment. To learn more about plans please check Rancher System Agent.

  • Example 1: one time instructions
  • Example 2: periodic instructions
  • Example 3: files
  • Example 4: probes
  1. {"instructions":
  2. [
  3. {
  4. "name":"set hostname",
  5. "command":"hostnamectl",
  6. "args": ["set-hostname", "myHostname"]
  7. },
  8. {
  9. "name":"stop sshd service",
  10. "command":"systemctl",
  11. "args": ["stop", "sshd"]
  12. }
  13. ]
  14. }
  1. {"periodicInstructions":
  2. [
  3. {
  4. "name":"set hostname",
  5. "image":"ghcr.io/rancher-sandbox/elemental-example-plan:main"
  6. "command": "run.sh"
  7. }
  8. ]
  9. }
  1. {"files":
  2. [
  3. {
  4. "content":"Welcome to the system",
  5. "path":"/etc/motd",
  6. "permissions": "0644"
  7. }
  8. ]
  9. }
  1. {"probes":
  2. "probe1": {
  3. "name": "Service Up",
  4. "httpGet": {
  5. "url": "http://10.0.0.1/healthz",
  6. "insecure": "false",
  7. "clientCert": "....",
  8. "clientKey": "....",
  9. "caCert": "....."
  10. }
  11. }
  12. }