Last active
August 15, 2024 20:05
-
-
Save vbatts/705c2542df39495319c8601c01b658e8 to your computer and use it in GitHub Desktop.
flatcar+k3s cloud-init
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
coreos: | |
units: | |
- name: install-opt-dir.service | |
content: | | |
[Unit] | |
Description=Install /opt directories | |
ConditionPathIsDirectory=!/opt/libexec | |
ConditionPathIsDirectory=!/opt/libexec.wd | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/bin/mkdir -p /opt/libexec /opt/libexec.wd | |
[Install] | |
WantedBy=multi-user.target | |
- name: usr-libexec.mount | |
content: | | |
[Unit] | |
Description=Allow k8s CNI plugins to be installed | |
Before=local-fs.target | |
Requires=install-opt-dir.service | |
ConditionPathExists=/opt/libexec | |
ConditionPathExists=/opt/libexec.wd | |
[Mount] | |
Type=overlay | |
What=overlay | |
Where=/usr/libexec | |
Options=lowerdir=/usr/libexec,upperdir=/opt/libexec,workdir=/opt/libexec.wd | |
[Install] | |
WantedBy=local-fs.target | |
- name: install-k3s.service | |
command: start | |
content: | | |
[Unit] | |
Description=Install k3s | |
Requires=usr-libexec.mount | |
ConditionPathExists=!/etc/.k3s-installed | |
[Service] | |
Type=oneshot | |
Environment=INSTALL_K3S_BIN_DIR=/opt/bin INSTALL_K3S_SELINUX_WARN=true INSTALL_K3S_CHANNEL=latest | |
ExecStart=/usr/bin/mkdir -p /opt/bin | |
ExecStart=/usr/bin/curl -sfSL -o /tmp/k3s.sh https://get.k3s.io | |
ExecStart=/usr/bin/chmod +x /tmp/k3s.sh | |
ExecStart=/tmp/k3s.sh | |
ExecStart=/usr/bin/touch /etc/.k3s-installed | |
[Install] | |
WantedBy=multi-user.target | |
ssh_authorized_keys: | |
- <SSH_KEY> | |
hostname: flatcar-k3s-00 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@vbatts I was using the ignition config and it failed to create the unit. If you want I can spin a vm and show the logs with
[Install]
section missing. This was with FlatCar Linux on DigitalOcean.IgnitionConfig: