Skip to content

Instantly share code, notes, and snippets.

@vbatts
Last active August 15, 2024 20:05
Show Gist options
  • Save vbatts/705c2542df39495319c8601c01b658e8 to your computer and use it in GitHub Desktop.
Save vbatts/705c2542df39495319c8601c01b658e8 to your computer and use it in GitHub Desktop.
flatcar+k3s cloud-init
#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
@vbatts
Copy link
Author

vbatts commented Dec 1, 2020

@frezbo 👍 no worries. And thanks for the ignition example!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment