### Start VM Source: https://www.flatcar.org/docs/latest/installing/vms/hyper-v Starts the newly configured virtual machine on Hyper-V. ```powershell Start-VM -Name $vmName ``` -------------------------------- ### Start QEMU VM and SSH Source: https://www.flatcar.org/docs/latest/reference/developer-guides/sdk-modifying-flatcar Starts the QEMU VM and connects to it via SSH for validation. ```bash scripts $ ../build/images/amd64-usr/latest/flatcar_production_qemu.sh scripts $ ssh core@localhost -p 2222 core@localhost ~ $ ... ``` -------------------------------- ### Start and SSH into QEMU Instance Source: https://www.flatcar.org/docs/latest/reference/developer-guides/sdk-modifying-flatcar Start the QEMU instance on the host and then SSH into it from a different terminal to test modifications. ```bash scripts $ ../build/images/amd64-usr/latest/flatcar_production_qemu.sh # switch terminals scripts $ ssh core@localhost -p 2222 core@localhost ~ $ ... ``` -------------------------------- ### Install QEMU on Gentoo Source: https://www.flatcar.org/docs/latest/installing/vms/qemu Configures QEMU USE flags and installs the QEMU package on Gentoo. ```shell echo app-emulation/qemu qemu_softmmu_targets_x86_64 virtfs xattr >> /etc/portage/package.use emerge -av app-emulation/qemu ``` -------------------------------- ### Clone Flatcar Terraform Azure Setup Source: https://www.flatcar.org/docs/latest/installing/cloud/azure Clone the Flatcar Terraform examples repository to get started with deploying Flatcar on Azure. This sets up the necessary files for Terraform. ```bash git clone https://github.com/flatcar/flatcar-terraform.git cd azure ``` -------------------------------- ### Initialize Flatcar Terraform Setup Source: https://www.flatcar.org/docs/latest/installing/cloud/aws-ec2 Clone the Flatcar Terraform examples repository and initialize the Terraform environment for AWS deployments. Ensure your AWS credentials are set as environment variables. ```bash git clone https://github.com/flatcar/flatcar-terraform.git # From here on you could directly run it, TLDR: cd aws export AWS_ACCESS_KEY_ID=... export AWS_SECRET_ACCESS_KEY=... terraform init ``` -------------------------------- ### Create Virtual Machine Node Source: https://www.flatcar.org/docs/latest/container-runtimes/high-availability-kubernetes Installs a virtual machine node using `virt-install`. It imports a pre-created disk image, configures resources, and attaches an Ignition config for initial setup. ```makefile virt-node%: flatcar_production_qemu_image-%.qcow2 $(IGN) cp -fv ign/*.ign /var/lib/libvirt/images/flatcar virt-install --connect qemu:///system --import --name $@ --ram 4096 --vcpus 4 --os-variant=generic --network network=default,model=virtio --disk path=/var/lib/libvirt/images/flatcar/flatcar_production_qemu_image-$*.qcow2,format=qcow2,bus=virtio --vnc --qemu-commandline="-fw_cfg name=opt/org.flatcar-linux/config,file=/var/lib/libvirt/images/flatcar/node$*.ign" --noautoconsole ``` -------------------------------- ### iPXE Boot Progress Example Source: https://www.flatcar.org/docs/latest/installing/bare-metal/booting-with-ipxe Example output showing the iPXE boot process downloading the Flatcar Container Linux kernel and initrd images from the specified boot URL. ```text ${YOUR_BOOT_URL}... ok http://alpha.release.flatcar-linux.net/amd64-usr/current/flatcar_production_pxe.vmlinuz... 98% ``` -------------------------------- ### Docker Configuration File Example Source: https://www.flatcar.org/docs/latest/container-runtimes/registry-authentication An example of the `$HOME/.docker/config.json` file, which stores registry authentication credentials. ```json { "auths": { "https://index.docker.io/v1/": { "auth": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=" }, "quay.io": { "xxxx": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, "https://registry.example.io/v0/": { "auth": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=" } } } ``` -------------------------------- ### Enable and Start a systemd Unit Source: https://www.flatcar.org/docs/latest/setup/systemd/getting-started Enable a systemd unit to start on boot and then start the service immediately. This involves creating necessary symlinks and initiating the service. ```bash sudo systemctl enable /etc/systemd/system/hello.service sudo systemctl start hello.service ``` -------------------------------- ### Install QEMU on Debian or Ubuntu Source: https://www.flatcar.org/docs/latest/installing/vms/qemu Installs QEMU system emulator and utilities on Debian-based systems. ```shell sudo apt-get install qemu-system-x86 qemu-utils ``` -------------------------------- ### Install QEMU on Arch Linux Source: https://www.flatcar.org/docs/latest/installing/vms/qemu Installs the QEMU package on Arch Linux. ```shell sudo pacman -S qemu ``` -------------------------------- ### Start Flatcar VM with Vagrant Source: https://www.flatcar.org/docs/latest/installing/vms/vagrant Start the Flatcar virtual machine defined in the `Vagrantfile`. Vagrant will import the base box, configure networking, and boot the VM. ```bash $ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'flatcar-alpha'... ==> default: Matching MAC address for NAT networking... ==> default: Setting the name of the VM: vagrant_default_1520510346048_14823 ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat ==> default: Forwarding ports... default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Running 'pre-boot' VM customizations... ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: core default: SSH auth method: private key ==> default: Machine booted and ready! $ vagrant ssh Last login: Thu Mar 15 17:02:25 UTC 2018 from 10.0.2.2 on ssh Flatcar Container Linux by Kinvolk alpha (1702.1.0) core@localhost ~ $ ``` -------------------------------- ### Install QEMU on Fedora or RedHat Source: https://www.flatcar.org/docs/latest/installing/vms/qemu Installs QEMU system emulator and image management tools on Fedora/RedHat-based systems. ```shell sudo yum install qemu-system-x86 qemu-img ``` -------------------------------- ### Build Ignition and start QEMU Source: https://www.flatcar.org/docs/latest/setup/customization/acpi Convert the butane definition to an Ignition JSON file and start a QEMU instance with the generated Ignition configuration. ```bash butane < config.yml > ignition.json ./flatcar_production_qemu.sh -i ./ignition.json -- -qmp tcp:localhost:4444,server,wait=off ``` -------------------------------- ### Start an Existing Systemd Unit with Cloud-Config Source: https://www.flatcar.org/docs/latest/provisioning/cl-config/from-cloud-config Start an existing systemd unit without additional configuration using the `coreos.units` section in cloud-config. ```yaml #cloud-config coreos: units: - name: "etcd2.service" command: "start" ``` -------------------------------- ### Start Nebraska Backend (Noop Authentication) Source: https://www.flatcar.org/docs/latest/nebraska/authorization Starts the Nebraska backend server using noop authentication. Requires the database to be running and the frontend static directory to be specified. ```bash nebraska -auth-mode noop -http-static-dir $PWD/frontend/dist -http-log ``` -------------------------------- ### Nginx Hello Message Example Source: https://www.flatcar.org/docs/latest/installing/cloud/stackit Example output from the curl command, showing a 'Hello' message from the container including the server's hostname. ```text Hello from ``` -------------------------------- ### SSH and Install Software in Toolbox Source: https://www.flatcar.org/docs/latest/setup/debug/install-debugging-tools Logs in as the 'bob' user via SSH, which automatically spawns a toolbox container. Inside the toolbox, installs 'emacs-nox' and opens a service file for editing. ```bash ssh bob@hostname.example.com Flatcar Container Linux by Kinvolk alpha (2671.0.0) Downloading sha256:ee7e8933710 [=============================] 63.4 MB / 63.4 MB Spawning container bob-fedora-latest on /var/lib/toolbox/bob-fedora-latest. Press ^] three times within 1s to kill container. [root@srv-3qy0p ~]# dnf -y install emacs-nox [root@srv-3qy0p ~]# emacs /media/root/etc/systemd/system/newapp.service ``` -------------------------------- ### Start Nebraska to Host Flatcar Packages Source: https://www.flatcar.org/docs/latest/nebraska/managing-updates Use this command to start Nebraska and serve Flatcar packages directly from a specified local directory. Ensure the directory contains the downloaded Flatcar update packages. ```bash nebraska -host-flatcar-packages=true -flatcar-packages-path=/PATH/TO/STORE/PACKAGES -nebraska-url=http://your.Nebraska.host:port ``` -------------------------------- ### Install Flatcar with Local Image Source: https://www.flatcar.org/docs/latest/installing/bare-metal/raspberry-pi This command allows installation using a pre-downloaded Flatcar image file. Use the `-f` flag to specify the path to your local image. ```bash sudo flatcar-install -d /dev/sda -C stable -B arm64-usr -o '' -i config.json -f flatcar_production_image.bin.bz2 ``` -------------------------------- ### Butane Configuration for Systemd Timers Source: https://www.flatcar.org/docs/latest/setup/systemd/timers An example Butane configuration that installs both a systemd service unit and its corresponding timer unit. The timer is set to run every 10 minutes and is enabled to start on boot. ```yaml variant: flatcar version: 1.0.0 systemd: units: - name: date.service contents: | [Unit] Description=Prints date into /tmp/date file [Service] Type=oneshot ExecStart=/usr/bin/sh -c '/usr/bin/date >> /tmp/date' - name: date.timer enabled: true contents: | [Unit] Description=Run date.service every 10 minutes [Timer] OnCalendar=*:0/10 [Install] WantedBy=multi-user.target ``` -------------------------------- ### Install NVIDIA GPU Operator for Kubernetes Source: https://www.flatcar.org/docs/latest/setup/customization/using-nvidia Install the NVIDIA GPU Operator on Kubernetes, disabling the driver and toolkit components. This is required for specific Kubernetes setups. ```bash helm repo add nvidia https://helm.ngc.nvidia.com/nvidia helm install --wait --generate-name \ -n gpu-operator --create-namespace \ nvidia/gpu-operator \ --set driver.enabled=false \ --set toolkit.enabled=false ``` -------------------------------- ### Start a Service Source: https://www.flatcar.org/docs/latest/setup/systemd/systemctl Initiate the startup of a specified service. ```bash sudo systemctl start apache.service ``` -------------------------------- ### Container Linux Config Template Source: https://www.flatcar.org/docs/latest/installing/cloud/azure Example configuration for a Flatcar node, including user setup and an inline script. ```yaml passwd: users: - name: core ssh_authorized_keys: - ${ssh_keys} storage: files: - path: /home/core/works filesystem: root mode: 0755 contents: inline: | #!/bin/bash set -euo pipefail # This script demonstrates templating and variable substitution. hostname="$(hostname)" echo My name is ${name} and the hostname is $${hostname} ``` -------------------------------- ### Ignition File Provisioning Example Source: https://www.flatcar.org/docs/latest/learning-series/advanced-service-config Instructs Ignition to download a file at provisioning time on early first boot. Useful for fetching larger files. ```yaml - path: /srv/www/html/video.mp4 mode: 0644 contents: source: https://github.com/flatcar/flatcar-website/raw/refs/heads/main/static/videos/hero-video.mp4 ``` -------------------------------- ### Start Flatcar VM with Snapshot Source: https://www.flatcar.org/docs/latest/learning-series/basics-and-testing Starts a Flatcar VM in no-graphics mode with snapshot enabled, ensuring the disk image remains unmodified. This is useful for experimenting as Flatcar configuration is applied on first boot. ```bash ./flatcar_production_qemu_uefi.sh -nographic -snapshot ``` -------------------------------- ### Start Flatcar Development Container with Writable Modules Bind Mount Source: https://www.flatcar.org/docs/latest/reference/developer-guides/kernel-modules Starts a systemd-nspawn container for development, binding the host's writable modules directory into the container. This allows modules built inside the container to be installed on the host. ```bash sudo systemd-nspawn \ --bind=/usr/lib/modules \ --capability=CAP_NET_ADMIN \ --image=flatcar_developer_container.bin ``` -------------------------------- ### Boot Flatcar VM with QEMU Source: https://www.flatcar.org/docs/latest/reference/developer-guides/sdk-modifying-flatcar Launches a Flatcar VM using a generated wrapper script. Ensure you are in the SDK environment. ```bash $ src/build/images/arm64-usr/developer-latest/flatcar_production_qemu.sh ``` -------------------------------- ### Custom Metadata Fetcher Output Example Source: https://www.flatcar.org/docs/latest/provisioning/ignition/dynamic-data This example shows the expected format of an environment file generated by a custom metadata fetching script. It defines custom hostname and IP address variables. ```bash COREOS_CUSTOM_HOSTNAME=foobar COREOS_CUSTOM_PRIVATE_IPV4= COREOS_CUSTOM_PUBLIC_IPV4= ``` -------------------------------- ### Common Rackspace Cloud-Config for etcd2 and fleet Source: https://www.flatcar.org/docs/latest/installing/community-platforms/rackspace This cloud-config example sets up etcd2 discovery and starts etcd2 and fleet services. It utilizes Rackspace-specific variables for IP addresses. ```yaml #cloud-config flatcar: etcd2: # generate a new token for each unique cluster from https://discovery.etcd.io/new?size=3 # specify the initial size of your cluster with ?size=X discovery: https://discovery.etcd.io/ # multi-region and multi-cloud deployments need to use $public_ipv4 advertise-client-urls: http://$private_ipv4:2379,http://$private_ipv4:4001 initial-advertise-peer-urls: http://$private_ipv4:2380 # listen on both the official ports and the legacy ports # legacy ports can be omitted if your application doesn't depend on them listen-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001 listen-peer-urls: http://$private_ipv4:2380 units: - name: etcd2.service command: start - name: fleet.service command: start ``` -------------------------------- ### Butane YAML Example for NGINX Docker Container Source: https://www.flatcar.org/docs/latest/installing/bare-metal/booting-with-pxe A Butane YAML configuration that defines a systemd unit to start an NGINX Docker container. This should be transpiled to Ignition JSON. ```yaml variant: flatcar version: 1.0.0 systemd: units: - name: nginx.service enabled: true contents: | [Unit] Description=NGINX example After=docker.service Requires=docker.service [Service] TimeoutStartSec=0 ExecStartPre=-/usr/bin/docker rm --force nginx1 ExecStart=/usr/bin/docker run --name nginx1 --pull always --log-driver=journald --net host docker.io/nginx:1 ExecStop=/usr/bin/docker stop nginx1 Restart=always RestartSec=5s [Install] WantedBy=multi-user.target passwd: users: - name: core ssh_authorized_keys: - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGdByTgSVHq... ``` -------------------------------- ### Testing LUKS Encryption Setup with QEMU Source: https://www.flatcar.org/docs/latest/setup/security/luks Test the LUKS encryption setup using QEMU with UEFI boot. This command requires an ignition file and a swtpm directory. Ensure UEFI is enabled for this test. ```bash ./flatcar_production_qemu_uefi.sh -i IGNITIONFILE -T swtpm-dir/ ``` -------------------------------- ### Download and Boot iPXE ISO with QEMU Source: https://www.flatcar.org/docs/latest/installing/bare-metal/booting-with-ipxe Downloads the iPXE ISO image and boots it using QEMU with curses display. This is the initial step to start the iPXE boot process. ```bash wget http://boot.ipxe.org/ipxe.iso qemu-kvm -m 1024 ipxe.iso -display curses ``` -------------------------------- ### Ignition Configuration for Raspberry Pi Source: https://www.flatcar.org/docs/latest/installing/bare-metal/raspberry-pi This is an example Ignition configuration file used for provisioning a Raspberry Pi during boot. It includes kernel arguments and user setup with SSH keys. ```json { "ignition": { "version": "3.4.0" }, "kernelArguments": { "shouldExist": [ "console=ttyAMA0,115200n8", "console=tty1", "flatcar.autologin", "usbcore.autosuspend=-1" ] }, "passwd": { "users": [ { "name": "core", "sshAuthorizedKeys": [ ] } ] } } ``` -------------------------------- ### Start Flatcar QEMU Instance Source: https://www.flatcar.org/docs/latest/container-runtimes/getting-started-with-kubernetes Launches a Flatcar QEMU instance using the generated Ignition config. ```bash ./flatcar_production_qemu.sh -i config.json -- -display curses ``` -------------------------------- ### Boot Flatcar VM with Graphical Interface Source: https://www.flatcar.org/docs/latest/reference/developer-guides/sdk-modifying-flatcar Launches a Flatcar VM with a graphical display using QEMU. This allows for direct interaction with the VM's desktop environment. ```bash ./flatcar_production_qemu.sh -- -display curses ``` -------------------------------- ### Check Status of a Custom Service Source: https://www.flatcar.org/docs/latest/setup/systemd/systemctl Use systemctl status to diagnose failing services. This example shows a custom registry service that failed to start due to an inability to download the container image. ```bash sudo systemctl status custom-registry.service ``` -------------------------------- ### Start Flatcar Instance with 9p Filesystem Forwarding Source: https://www.flatcar.org/docs/latest/reference/developer-guides/kernel-modules Starts a Flatcar QEmu instance with a local directory forwarded via 9p for additional storage. This is useful for local testing environments where the default rootfs may be insufficient. ```bash ./flatcar_production_qemu_uefi.sh [...other options...] -virtfs local,path="$(pwd)",mount_tag="data",security_model=none,id=data ``` -------------------------------- ### Enable a Systemd Service Unit with Container Linux Config Source: https://www.flatcar.org/docs/latest/provisioning/cl-config/from-cloud-config Enable a systemd unit to start on boot using the `systemd.units` section in Container Linux Config. Requires an `[Install]` section in the unit content. ```yaml systemd: units: - name: "docker-redis.service" enable: true contents: | [Unit] Description=Redis container Author=Me After=docker.service [Service] Restart=always ExecStart=/usr/bin/docker start -a redis_server ExecStop=/usr/bin/docker stop -t 2 redis_server [Install] WantedBy=multi-user.target ``` -------------------------------- ### Download and Verify Beta Channel PXE Boot Files Source: https://www.flatcar.org/docs/latest/installing/bare-metal/booting-with-pxe Use these commands to download the kernel and initramfs images for the Beta channel and verify their signatures. Ensure your TFTP root is set to /var/lib/tftpboot. ```bash cd /var/lib/tftpboot wget https://beta.release.flatcar-linux.net/amd64-usr/current/flatcar_production_pxe.vmlinuz wget https://beta.release.flatcar-linux.net/amd64-usr/current/flatcar_production_pxe.vmlinuz.sig wget https://beta.release.flatcar-linux.net/amd64-usr/current/flatcar_production_pxe_image.cpio.gz wget https://beta.release.flatcar-linux.net/amd64-usr/current/flatcar_production_pxe_image.cpio.gz.sig gpg --verify flatcar_production_pxe.vmlinuz.sig gpg --verify flatcar_production_pxe_image.cpio.gz.sig ``` -------------------------------- ### KubeVirt VirtualMachine Definition with Cloud-init Source: https://www.flatcar.org/docs/latest/installing/vms/kubevirt Define a KubeVirt VirtualMachine using a YAML manifest. This example configures the VM to use a cloud-init config drive for initial setup, including setting the root password. ```yaml apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: generation: 1 labels: kubevirt.io/os: linux name: vm-flatcar-cfgdrive spec: running: true template: metadata: creationTimestamp: null labels: kubevirt.io/domain: vm-flatcar-cfgdrive spec: domain: cpu: cores: 1 devices: disks: - disk: bus: virtio name: disk0 - disk: bus: sata name: cloudinitdisk resources: requests: memory: 1024M volumes: - name: disk0 persistentVolumeClaim: claimName: flatcar-amd64-3975 - cloudInitConfigDrive: userData: | #!/bin/bash echo "core:foo" | chpasswd name: cloudinitdisk ``` -------------------------------- ### Spawn Persistent Toolbox with tmux using systemd-run Source: https://www.flatcar.org/docs/latest/setup/debug/install-debugging-tools Starts a Toolbox container in the background using systemd-run, installs tmux, strace, and procps-ng, and creates a detached tmux session. It uses strace to keep the process alive. ```bash systemd-run --user toolbox sh -c 'dnf install -y tmux strace procps-ng; TERM=tmux tmux new-session -d -s sharedsession; strace -p "$(pidof tmux)"' ``` -------------------------------- ### Start Flatcar VM with NGINX Configuration Source: https://www.flatcar.org/docs/latest/learning-series/immutability-updates-rollbacks Launches a Flatcar VM using QEMU with a specified configuration file and NGINX port forwarding. Requires a production QEMU UEFI image and a JSON configuration. ```bash ./flatcar_production_qemu_uefi.sh -i nginx.json -f 12345:80 -- -nographic -snapshot ``` -------------------------------- ### Create Instance Configuration Profile Source: https://www.flatcar.org/docs/latest/installing/cloud/akamai Creates an instance configuration profile named 'default' that disables Linode helpers and boots directly from the Flatcar disk. Requires the DISK_ID environment variable. ```bash linode-cli linodes config-create \ --kernel linode/direct-disk \ --helpers.updatedb_disabled true \ --helpers.distro false \ --helpers.modules_dep false \ --helpers.network false \ --helpers.devtmpfs_automount false \ --label default \ --devices.sda.disk_id "${DISK_ID}" \ --root_device /dev/sda \ "${LINODE_ID}" ``` -------------------------------- ### Setup Kubernetes Control Plane with Plain Binaries Source: https://www.flatcar.org/docs/latest/container-runtimes/getting-started-with-kubernetes This Butane configuration installs Kubernetes binaries (kubectl, kubeadm, kubelet) directly from specified URLs. It configures the kubelet service and uses kubeadm to initialize the cluster. This approach does not include an in-place update mechanism for the binaries. ```yaml --- version: 1.0.0 variant: flatcar storage: files: - path: /opt/bin/kubectl mode: 0755 contents: source: https://dl.k8s.io/v1.33.2/bin/linux/amd64/kubectl - path: /opt/bin/kubeadm mode: 0755 contents: source: https://dl.k8s.io/v1.33.2/bin/linux/amd64/kubeadm - path: /opt/bin/kubelet mode: 0755 contents: source: https://dl.k8s.io/v1.33.2/bin/linux/amd64/kubelet - path: /etc/systemd/system/kubelet.service contents: source: https://raw.githubusercontent.com/kubernetes/release/refs/tags/v0.18.0/cmd/krel/templates/latest/kubelet/kubelet.service - path: /etc/systemd/system/kubelet.service.d/10-kubeadm.conf contents: source: https://raw.githubusercontent.com/kubernetes/release/refs/tags/v0.18.0/cmd/krel/templates/latest/kubeadm/10-kubeadm.conf - path: /etc/kubeadm.yml contents: inline: | apiVersion: kubeadm.k8s.io/v1beta3 kind: InitConfiguration nodeRegistration: kubeletExtraArgs: volume-plugin-dir: "/opt/libexec/kubernetes/kubelet-plugins/volume/exec/" --- apiVersion: kubeadm.k8s.io/v1beta3 kind: ClusterConfiguration controllerManager: extraArgs: flex-volume-plugin-dir: "/opt/libexec/kubernetes/kubelet-plugins/volume/exec/" - path: /etc/hostname contents: inline: "flatcar-node1" systemd: units: - name: kubelet.service enabled: true dropins: - name: 20-kubelet.conf contents: | [Service] ExecStart= ExecStart=/opt/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS - name: kubeadm.service enabled: true contents: | [Unit] Description=Kubeadm service Requires=containerd.service ``` -------------------------------- ### VMware Raw Image Installation Source: https://www.flatcar.org/docs/latest/installing/bare-metal/installing-to-disk Installs a VMware-specific image of Flatcar Container Linux to the specified device. This is used when installing on VMware environments. ```bash flatcar-install -d /dev/sda -i ignition.json -o vmware_raw ``` -------------------------------- ### Create and Enable a Simple systemd Service Source: https://www.flatcar.org/docs/latest/provisioning/config-transpiler/examples Creates a new systemd service named 'hello.service', enables it to run on boot, and configures it to execute '/usr/bin/echo "Hello, World!"'. ```yaml variant: flatcar version: 1.0.0 systemd: units: - name: hello.service enabled: true contents: | [Unit] Description=A hello world unit! [Service] Type=oneshot ExecStart=/usr/bin/echo "Hello, World!" [Install] WantedBy=multi-user.target ``` -------------------------------- ### Flatcar VM Boot Output Source: https://www.flatcar.org/docs/latest/learning-series/basics-and-testing Example output showing a Flatcar VM booting up and logging in automatically as the 'core' user. ```text [ 17.396816] mousedev: PS/2 mouse device common for all mice [ 17.405146] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input4 [ 17.449715] ACPI: button: Power Button [PWRF] [ 17.659038] zram_generator::config[1580]: No configuration found. [...] localhost login: core (automatic login) Flatcar Container Linux by Kinvolk alpha 4372.0.0 for QEMU core@localhost ~ $ ``` -------------------------------- ### Create Basic Config Drive ISO Source: https://www.flatcar.org/docs/latest/installing/vms/virtualbox Download and make executable the script to create a basic config-drive ISO. This is necessary to configure SSH keys and set the VM name. ```bash wget https://raw.githubusercontent.com/flatcar/scripts/main/contrib/create-basic-configdrive chmod +x create-basic-configdrive ./create-basic-configdrive -H my_vm01 -S ~/.ssh/id_rsa.pub ``` -------------------------------- ### Butane YAML for LVM and Docker Setup Source: https://www.flatcar.org/docs/latest/setup/storage/lvm A Butane YAML configuration defining systemd services for LVM setup and mounting a volume for Docker, along with the LVM setup script itself. ```yaml variant: flatcar version: 1.0.0 systemd: units: - name: lvm-setup.service enabled: true contents: | [Unit] Description=LVM Setup ConditionFirstBoot=yes DefaultDependencies=no Before=local-fs-pre.target [Service] Type=oneshot Restart=on-failure RemainAfterExit=yes ExecStart=/opt/lvm.sh [Install] WantedBy=multi-user.target - name: var-lib-docker.mount enabled: true contents: | [Unit] Description=Mount LVM to docker dir After=lvm-setup.service [Mount] What=/dev/vg-docker/vol_docker Where=/var/lib/docker Type=ext4 Options=defaults [Install] WantedBy=local-fs.target - name: docker.service dropins: - name: 10-wait-docker.conf contents: | [Unit] After=var-lib-docker.mount Requires=var-lib-docker.mount storage: files: - path: /opt/lvm.sh mode: 0744 contents: inline: | #!/bin/bash set -euo pipefail # Function to find all disks find_volumes(){ lsblk -d -o NAME,TYPE | awk '$2 == "disk" {print "/dev/" $1}' } disks=$(find_volumes) # Create Physical Volumes pvcreate "${disks}" # Create Volume Group vgcreate vg-root "${disks}" # Create Logical Volume for data lvcreate -n vol_root -l 100%FREE vg-root # Format the data volume with ext4 filesystem mkfs.ext4 /dev/vg-root/vol_root ``` -------------------------------- ### Start the iSCSI daemon Source: https://www.flatcar.org/docs/latest/setup/storage/iscsi Use this command to start the iSCSI daemon service. ```bash systemctl start iscsid ``` -------------------------------- ### Create a File Source: https://www.flatcar.org/docs/latest/learning-series/basics-and-testing Creates a file named 'test.txt' in the '/home/core/' directory with the content 'hello'. ```bash echo "hello" > /home/core/test.txt ``` -------------------------------- ### Create a swapfile Source: https://www.flatcar.org/docs/latest/setup/storage/adding-swap This command creates a 1GiB swapfile at `/var/vm/swapfile1`. Ensure you have sufficient space on the target partition. ```bash mkdir -p /var/vm mkswap --size 1024m --file /var/vm/swapfile1 ``` -------------------------------- ### Start SSSD Service Source: https://www.flatcar.org/docs/latest/setup/security/sssd Command to start the SSSD service on Flatcar Container Linux. ```bash sudo systemctl start sssd ``` -------------------------------- ### Ensure Update Engine Starts Conditionally Source: https://www.flatcar.org/docs/latest/learning-series/immutability-updates-rollbacks This drop-in configuration for `update-engine.service` enforces that the service will only start if the `/run/first-boot-healthy` file exists. This prevents the update engine from starting prematurely and ensures it respects the health check status. ```yaml - name: update-engine.service dropins: - name: first-boot-healthy-must-exist.conf contents: | [Unit] ConditionPathExists=/run/first-boot-healthy ``` -------------------------------- ### Boot the Linode Instance Source: https://www.flatcar.org/docs/latest/installing/cloud/akamai Boots the Linode instance using the previously created disk and configuration profile. Requires the LINODE_ID environment variable. ```bash linode-cli linodes boot "${LINODE_ID}" ``` -------------------------------- ### Install flatcar-install script Source: https://www.flatcar.org/docs/latest/installing/bare-metal/raspberry-pi Download and make the `flatcar-install` script executable. It is recommended to add `~/.local/bin` to your PATH. ```bash mkdir -p ~/.local/bin # You may also add `PATH` export to your shell profile, i.e bashrc, zshrc etc. export PATH=$PATH:$HOME/.local/bin curl -LO https://raw.githubusercontent.com/flatcar/init/flatcar-master/bin/flatcar-install chmod +x flatcar-install mv flatcar-install ~/.local/bin ``` -------------------------------- ### Start Flatcar VM with NGINX Configuration Source: https://www.flatcar.org/docs/latest/learning-series/basics-and-testing Launches a Flatcar VM with a specified NGINX configuration file and forwards a local port to the VM's NGINX port. Use '--' to separate script options from QEMU options. ```bash ./flatcar_production_qemu_uefi.sh -i nginx.json -f 12345:80 -- -nographic -snapshot ``` -------------------------------- ### Create a disk image file Source: https://www.flatcar.org/docs/latest/learning-series/managing-storage Use qemu-img to create a file-backed disk image for testing. The qcow2 format is used for efficient storage. ```bash qemu-img create -f qcow2 mydisk 1G ``` -------------------------------- ### Build and Prepare QEMU UEFI Image Source: https://www.flatcar.org/docs/latest/reference/developer-guides/sdk-modifying-flatcar Build Flatcar packages, the image, and convert it to a QEMU UEFI format. This is a prerequisite for running local tests. ```bash ./build_packages ./build_image ./image_to_vm.sh --from=../build/images/amd64-usr/latest/ --format=qemu_uefi --image_compression_formats none ``` -------------------------------- ### Monitor NVIDIA Driver Installation Status Source: https://www.flatcar.org/docs/latest/setup/customization/using-nvidia Use this command to follow the logs of the `nvidia.service` during driver installation. ```bash # journalctl -u nvidia -f ``` -------------------------------- ### Starting Flatcar with Merged Configuration Source: https://www.flatcar.org/docs/latest/learning-series/advanced-service-config Command to start a Flatcar QEMU instance using the transpiled main.json configuration file. It also maps host port 12345 to guest port 80 for accessing the web server. ```bash ./flatcar_production_qemu_uefi.sh -i main.json -f 12345:80 -- -snapshot -nographic ``` -------------------------------- ### Install rpi-eeprom package Source: https://www.flatcar.org/docs/latest/installing/bare-metal/raspberry-pi Update and install the `rpi-eeprom` package on Raspberry Pi OS to manage the bootloader. ```bash sudo apt update sudo apt full-upgrade sudo apt install rpi-eeprom ``` -------------------------------- ### Custom Metadata Provider Example Source: https://www.flatcar.org/docs/latest/provisioning/cl-config/dynamic-data This example demonstrates how to configure a custom metadata provider. It involves a script to fetch metadata and a Container Linux Config that uses this script to set etcd configuration with dynamic host and IP information. Use `--platform=custom` when transpiling. ```yaml storage: files: - filesystem: "root" path: "/opt/get-metadata.sh" mode: 0755 contents: remote: url: "https://example.com/metadata-script.sh" systemd: units: - name: "coreos-metadata.service" contents: | [Unit] Description=Metadata agent After=nss-lookup.target After=network-online.target Wants=network-online.target [Service] Type=oneshot Restart=on-failure RemainAfterExit=yes ExecStart=/opt/get-metadata.sh etcd: version: "3.0.15" name: "{HOSTNAME}" advertise_client_urls: "http://{PRIVATE_IPV4}:2379" initial_advertise_peer_urls: "http://{PRIVATE_IPV4}:2380" listen_client_urls: "http://0.0.0.0:2379" listen_peer_urls: "http://{PRIVATE_IPV4}:2380" initial_cluster: "{HOSTNAME}=http://{PRIVATE_IPV4}:2380" ``` -------------------------------- ### Start Nebraska with Dex OIDC Source: https://www.flatcar.org/docs/latest/nebraska/authorization Command to start Nebraska in debug mode with Dex as the OIDC provider. ```bash backend/bin/nebraska --debug --auth-mode oidc \ --oidc-roles-path groups \ --oidc-admin-roles admin \ --oidc-viewer-roles viewer \ --oidc-client-id nebraska \ --oidc-issuer-url http://localhost:5556/dex \ --oidc-scopes groups,openid,profile \ --http-static-dir frontend/dist ``` -------------------------------- ### Create Workspace Directories Source: https://www.flatcar.org/docs/latest/container-runtimes/high-availability-kubernetes Sets up the necessary directories for butane configurations, certificates, Ignition files, and scripts. ```bash mkdir -p butane certs ign scripts ``` -------------------------------- ### Example Crontab Job Source: https://www.flatcar.org/docs/latest/setup/systemd/timers This is an example of a crontab job that writes the current date to a file every 10 minutes. ```shell */10 * * * * /usr/bin/date >> /tmp/date ``` -------------------------------- ### Kubernetes Get Secret Source: https://www.flatcar.org/docs/latest/container-runtimes/registry-authentication Verify that a Kubernetes secret has been successfully created and loaded using the `kubectl get` command. ```bash $ kubectl get my-favorite-registry-secret NAME TYPE DATA AGE my-favorite-registry-secret kubernetes.io/dockercfg 1 30m ``` -------------------------------- ### Example machine-mynode.yaml.tmpl Configuration Source: https://www.flatcar.org/docs/latest/installing/cloud/aws-ec2 This configuration file defines user settings, SSH keys, and a script for a Flatcar node. It demonstrates templating and variable substitution. ```yaml --- passwd: users: - name: core ssh_authorized_keys: - ${ssh_keys} storage: files: - path: /home/core/works filesystem: root mode: 0755 contents: inline: | #!/bin/bash set -euo pipefail # This script demonstrates how templating and variable substitution works when using Terraform templates for Container Linux Configs. hostname="$(hostname)" echo My name is ${name} and the hostname is $${hostname} ``` -------------------------------- ### Start Flatcar Container Linux on QEMU Source: https://www.flatcar.org/docs/latest/installing/vms/qemu Launches the downloaded Flatcar Container Linux QEMU instance without a graphical interface. ```shell ./flatcar_production_qemu.sh -nographic ``` -------------------------------- ### Start Nebraska with Okta OIDC Source: https://www.flatcar.org/docs/latest/nebraska/authorization Command to start Nebraska with Okta as the OIDC provider. Replace placeholders with your Okta details. ```bash backend/bin/nebraska --debug --auth-mode oidc \ --oidc-client-id \ --oidc-issuer-url https://.okta.com/oauth2/default \ --oidc-admin-roles nebraska_admin \ --oidc-viewer-roles nebraska_viewer \ --http-static-dir frontend/dist ``` -------------------------------- ### Download and Install cfssl Source: https://www.flatcar.org/docs/latest/setup/security/generate-self-signed-certificates Downloads and installs the cfssl and cfssljson binaries for Linux amd64. It also sets up the PATH environment variable. ```bash mkdir ~/bin curl -s -L -o ~/bin/cfssl https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 curl -s -L -o ~/bin/cfssljson https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64 chmod +x ~/bin/{cfssl,cfssljson} export PATH=$PATH:~/bin ``` -------------------------------- ### Start SDK Container Source: https://www.flatcar.org/docs/latest/reference/developer-guides/sdk-modifying-flatcar Initiate the Flatcar SDK container, downloading the image if necessary and mounting the local directory. The -t flag allocates a TTY. ```bash $ ./run_sdk_container -t ``` -------------------------------- ### Install Nebraska Helm Chart (Default Configuration) Source: https://www.flatcar.org/docs/latest/nebraska/authorization Installs the Nebraska Helm chart with default settings, including noop authentication. ```bash helm install my-nebraska nebraska/nebraska ``` -------------------------------- ### Example Ignition Configuration Output Source: https://www.flatcar.org/docs/latest/setup/storage/lvm An example of the generated Ignition JSON configuration. This output is typically used as user-data for cloud instances. ```json {"ignition":{"version":"3.3.0"},"storage":{"files":[{"path":"/etc/systemd/system/multi-user.target.wants/lvm.sh","contents":{"compression":"gzip","source":"data:;base64,H4sIAAAAAAAC/3ySQY/TPhTE7+9TzN/Nn20lQrYrbqsiIdTdC6AVQkicKjd5bqy4doidLFW33x05rtosB47Om/mN38Sz/4qttsVW+po8B+TcO7S6ZSW1IaIZHnpbBu0sgoPStoI0BpX2jad43AzO9Hv288WRAOO3pkFeIXf4+vHL+u33n09rvEA+N7jJ7rBaQUSvwLHttA0QRcVDIZAtTzegE1HZsQy8aQc/XyAix6hVNp+GLQjovdwa3qSxEESAct0oh7bIxsE9KkcAoBXaIbGRH9IUdx/eLPGCXcct8l8Qvi9L9l71xhyQxJW4R6jZjpC/Q7PpMTHFKFQ6XtxZjrfisnZ4JY17zvDIIaJhtA9w6sw+V/sqKJtfW1lE66e0yFN98LqUBj9SLXRZMTtOAaeJJ0nx2Lm+pWF31g+7vHJlw90/nJ/dbhKWypZBkrn0ajE4szmDcoPl7e3/D9/W6yt+fFCu28u0evQj/VM861CDf4f3UNqwP/jAe9o3yr8bP47v5MIprkH0JwAA//+D2TD6wwIAAA=="},"mode":484}]},"systemd":{"units":[{"contents":"[Unit]\nDescription=LVM Setup\nConditionFirstBoot=yes\nBefore=local-fs-pre.target\n[Service]\nType=oneshot\nRestart=on-failure\nRemainAfterExit=yes\nExecStart=/etc/systemd/system/multi-user.target.wants/lvm.sh\n[Install]\nWantedBy=multi-user.target\n","enabled":true,"name":"lvm-setup.service"},{"contents":"[Unit]\nDescription=Mount LVM to docker dir\n[Mount]\nWhat=/dev/vg-docker/vol_docker\nWhere=/var/lib/docker\nType=ext4\nOptions=defaults\n[Install]\nAfter=lvm-setup.service\nWantedBy=local-fs.target\n","enabled":true,"name":"var-lib-docker.mount"},{"dropins":[{"contents":"[Unit]\nAfter=var-lib-docker.mount\nRequires=var-lib-docker.mount\n","name":"10-wait-docker.conf"}],"name":"docker.service"}]}} ``` -------------------------------- ### Launch and List Incus Containers Source: https://www.flatcar.org/docs/latest/container-runtimes/incus Demonstrates launching an Ubuntu container and listing all running containers. Also shows how to execute a command inside a container to view its OS release information. ```bash core@localhost ~ $ incus launch images:ubuntu/22.04 ubuntu-01 Launching ubuntu-01 core@localhost ~ $ incus list +-----------+---------+----------------------+------+-----------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +-----------+---------+----------------------+------+-----------+-----------+ | ubuntu-01 | RUNNING | 10.126.29.162 (eth0) | | CONTAINER | 0 | +-----------+---------+----------------------+------+-----------+-----------+ core@localhost ~ $ incus exec ubuntu-01 cat /etc/os-release PRETTY_NAME="Ubuntu 22.04.5 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.5 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy ``` -------------------------------- ### Install Nebraska Helm Chart with Custom Values Source: https://www.flatcar.org/docs/latest/nebraska/authorization Installs the Nebraska Helm chart using a specified values file for custom configuration. ```bash helm install my-nebraska nebraska/nebraska --values nebraska-values.yaml ``` -------------------------------- ### Boot a Cloud Server with Keypair and Cloud-Config Source: https://www.flatcar.org/docs/latest/installing/community-platforms/rackspace Launch a new Flatcar Container Linux Cloud Server using a specified image, flavor, and your added keypair. Optionally provide cloud-config data for initial server setup. ```bash supernova production boot --image --flavor performance1-2 --key-name flatcar-key --user-data ~/cloud_config.yml --config-drive true My_Flatcar_Server ```