Deploy with CUE¶
In this tutorial, you'll deploy an nginx container with its own config file from the repository you set up in Set up CUE repository. You'll preview the change, apply it, and let the schema catch a mistake before it reaches the host.
Prerequisites¶
- The
infrarepository andweb01.example.comfrom Set up CUE repository.
1. Add the container¶
Everything deployed to web01 goes into one file, web01.cue.
Create it with a container and a config file for it:
The key site becomes the spec name, and unit maps onto the quadlet sections, as in the container spec.
configFiles are written to the host and bind-mounted into the container (see Mount config files and dirs).
Without a Network option, the container runs on podman's default bridge network.
2. Preview it¶
| Bash | |
|---|---|
The plan lists the unit file syslet will write, including the options it adds on its own, such as ContainerName, Restart=always and the bind mount for the config file, followed by the config file itself:
3. Apply it¶
| Bash | |
|---|---|
apply prints the same diff, then asks Continue? (yes/no).
Answer yes, and syslet logs each action as it runs:
Commit the working state:
| Bash | |
|---|---|
Verify it on the server:
| Bash | |
|---|---|
Change the config file and run cue cmd plan again: the plan shows the diff of the file and a restart of site.container, since config files are static bind mounts.
4. Let the schema catch mistakes¶
Set desiredState: "runing" on the container, then run:
| Bash | |
|---|---|
CUE reports the conflict against the syslet schema before anything reaches the server, and you can run the same command in CI on every commit.
The schema doesn't check option names under unit, because the valid options depend on the host's podman version.
A typo like Imag: therefore passes cue vet, and the quadlet validation on the host rejects it during cue cmd plan (see Safety mechanisms).
Revert the mistake before moving on.
The container is now running and described in git. Continue with Protect a container.