Hands on 2 - Provisioning

    The goal of this hands-on is to:

    • Provision a local Flatcar instance
    • Write Butane configuration
    • Generate the Ignition configuration
    • Boot the instance with the config

    This is what we’ve done in the previous hands-on but now it’s done as code, we want to deploy an Nginx container serving a “hello world” static webpage. As a reminder, Ignition configuration is used to provision a Flatcar instance, it’s a JSON file generated from a Butane YAML configuration.

    Step-by-step

    Clone the tutorial repository and cd into it:

    git clone https://github.com/flatcar/flatcar-tutorial ; cd flatcar-tutorial/hands-on-2
    

    Open ./config.yaml, find the TODO section, and add the following section:

    storage:
      files:
        - path: /var/www/index.html
          contents:
            inline: Hello world
    

    NOTE: More Butane Config Examples and Common Setup, Operations and Customization .

    Transpile the Butane configuration (config.yaml) to Ignition configuration (config.json) - it is possible to use the Butane binary or the Docker image

    docker run --rm -i quay.io/coreos/butane:latest < config.yaml > config.json
    

    Use a fresh Flatcar image from the previous hands-on (or download again). NOTE: Ignition runs at first boot, it won’t work if you reuse the previously booted image, always start from a pristine image.

    cp -i --reflink=auto ../hands-on-1/flatcar_production_qemu_image.img.fresh flatcar_production_qemu_image.img
    chmod +x flatcar_production_qemu.sh
    

    Start the image with Ignition configuration (-i ./config.json)

    ./flatcar_production_qemu.sh -i ./config.json -- -display curses
    

    Once on the instance, assert nginx works correctly:

    curl localhost
    

    or

    systemctl status nginx.service
    

    Resources

    Demo