Quadlet: Difference between revisions
(→Syntax) |
|||
Line 80: | Line 80: | ||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
# | # systemd unitfile generator files | ||
*.container: | *.container: for a single container # podman run | ||
*.kube: | *.kube: from kubernetes yaml files using # podman kube play | ||
*.pod: for a single pod within kubernetes yaml files # ? is this correct? | |||
*.yml: a kubernetes yaml file | |||
# resources | # resources | ||
*.image: ensures a docker image is pulled | |||
*.network: create podman networks, referenced in '.container' or '.kube' files | *.network: create podman networks, referenced in '.container' or '.kube' files | ||
*.volume: create podman volumes, referenced in '.container' files | *.volume: create podman volumes, referenced in '.container' files | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Overview --> | </blockquote><!-- Overview --> | ||
== Standalone Containers == | |||
<blockquote> | |||
=== *.container === | |||
<blockquote> | |||
<syntaxhighlight lang="dosini"> | |||
# ~/.config/containers/systemd/foo.container | |||
[Install] | |||
WantedBy=default.target | |||
[Container] | |||
Image=docker.io/library/mysql:5.6 | |||
ContainerName=foo | |||
Volume=foo.volume:/var/lib/mysql | |||
Network=foo.network | |||
</syntaxhighlight> | |||
</blockquote><!-- *.container --> | |||
</blockquote><!-- Standalone Containers --> | |||
== Kubernetes == | |||
<blockquote> | |||
=== *.yml === | |||
<blockquote> | |||
A kubernetes yaml file. | |||
{{ WARN | | |||
this is the official example, haven't had to use this yet | |||
}} | |||
<syntaxhighlight lang="yaml"> | |||
# ~/.config/containers/systemd/foo.yml | |||
--- | |||
apiVersion: v1 | |||
kind: PersistentVolumeClaim | |||
metadata: | |||
name: wp-pv-claim | |||
labels: | |||
app: wordpress | |||
spec: | |||
accessModes: | |||
- ReadWriteOnce | |||
resources: | |||
requests: | |||
storage: 20Gi | |||
--- | |||
apiVersion: v1 | |||
kind: Pod | |||
metadata: | |||
name: quadlet-demo | |||
spec: | |||
containers: | |||
- name: wordpress | |||
image: docker.io/library/wordpress:4.8-apache | |||
env: | |||
- name: WORDPRESS_DB_HOST | |||
value: quadlet-demo-mysql | |||
- name: WORDPRESS_DB_PASSWORD | |||
valueFrom: | |||
secretKeyRef: | |||
name: mysql-root-password-kube | |||
key: password | |||
volumeMounts: | |||
- name: wordpress-persistent-storage | |||
mountPath: /var/www/html | |||
# ... etc ... | |||
</syntaxhighlight> | |||
</blockquote><!-- *.yml --> | |||
=== *.pod === | |||
<blockquote> | |||
Abstraction of a systemd unit file for running specific kubernetes pods only. | |||
{{ TODO | | |||
is this understanding correct? | |||
}} | |||
</blockquote><!-- *.pod --> | |||
=== *.kube === | |||
<blockquote> | |||
Abstraction of a systemd unit file for running an entire kubernetes project | |||
</blockquote><!-- *.kube --> | |||
</blockquote><!-- Kubernetes --> | |||
== Resources == | |||
<blockquote> | |||
=== *.network === | |||
<blockquote> | |||
Define a network to share between multiple containers. | |||
<syntaxhighlight lang="dosini"> | |||
# ~/.config/containers/systemd/foo.network | |||
Subnet=192.168.30.0/24 | |||
Gateway=192.168.30.1 | |||
</syntaxhighlight> | |||
would generate | |||
<syntaxhighlight lang="yaml"> | |||
podman-network: systmd-foo # podman network create systemd-foo | |||
systemd-unit: foo-network.service | |||
</syntaxhighlight> | |||
</blockquote><!-- .network --> | |||
=== *.volume === | |||
<blockquote> | |||
Describe a volume to share between multiple containers. | |||
</blockquote><!-- *.volume --> | |||
=== *.image === | |||
<blockquote> | |||
Ensure a docker image is pulled.<br> | |||
Generates a service that can be used as a dependency. | |||
</blockquote><!-- *.image --> | |||
</blockquote><!-- Resources --> | |||
</blockquote><!-- Syntax --> | </blockquote><!-- Syntax --> |
Revision as of 19:30, 5 May 2024
Quadlet is a tool for generating systemd services from podman containers.
You can also describe a project as a podman-compose project, and generate systemd services for it as well.
The goal for the project is to be concise and change tolerant with sane defaults.
Documentation
man quadlet / podman-systemd.unit
(incl. filetypes/opts)https://man.archlinux.org/man/quadlet.5.en official multi-container tutorial https://www.redhat.com/sysadmin/multi-container-application-podman-quadlet src https://github.com/containers/podman/tree/main/pkg/systemd/quadlet
Tutorials
https://mo8it.com/blog/quadlet/ intro
Locations
~/.config/containers/systemd/*.{kube,container,volume,network,yml}
build systemd services from these /usr/libexec/podman/quadlet
quadlet executable (not on path)
Usage
Overview
While quadlet is technically an executable, it's designed to work with systemd commands directly.
After adding your files to
~/.config/containers/systemd/*.{kube,container,volume,network,yml}
,
you can run daemon-reload and your generated systemd services will be made available.Here's the TL;DR from the official tutorial:
mkdir -p $HOME/.config/containers/systemd/ cp envoy-proxy-configmap.yml \ quadlet-demo.kube \ quadlet-demo-mysql.container \ quadlet-demo-mysql.volume \ quadlet-demo.network \ quadlet-demo.yml \ $HOME/.config/containers/systemd/ systemctl --user daemon-reload systemctl --user start quadlet-demo.serviceYou can debug the generated files using
/usr/libexec/podman/quadlet --dryrun
Secrets
It looks like these are primarily managed using kubernetes own utils from
kubectl create secret ${secret}
.TODO:
more research is needed here.
Syntax
Overview
# systemd unitfile generator files *.container: for a single container # podman run *.kube: from kubernetes yaml files using # podman kube play *.pod: for a single pod within kubernetes yaml files # ? is this correct? *.yml: a kubernetes yaml file # resources *.image: ensures a docker image is pulled *.network: create podman networks, referenced in '.container' or '.kube' files *.volume: create podman volumes, referenced in '.container' filesStandalone Containers
*.container
# ~/.config/containers/systemd/foo.container [Install] WantedBy=default.target [Container] Image=docker.io/library/mysql:5.6 ContainerName=foo Volume=foo.volume:/var/lib/mysql Network=foo.networkKubernetes
*.yml
A kubernetes yaml file.
# ~/.config/containers/systemd/foo.yml --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: wp-pv-claim labels: app: wordpress spec: accessModes: - ReadWriteOnce resources: requests: storage: 20Gi --- apiVersion: v1 kind: Pod metadata: name: quadlet-demo spec: containers: - name: wordpress image: docker.io/library/wordpress:4.8-apache env: - name: WORDPRESS_DB_HOST value: quadlet-demo-mysql - name: WORDPRESS_DB_PASSWORD valueFrom: secretKeyRef: name: mysql-root-password-kube key: password volumeMounts: - name: wordpress-persistent-storage mountPath: /var/www/html # ... etc ...*.pod
Abstraction of a systemd unit file for running specific kubernetes pods only.
TODO:
is this understanding correct?
*.kube
Abstraction of a systemd unit file for running an entire kubernetes project
Resources
*.network
Define a network to share between multiple containers.
# ~/.config/containers/systemd/foo.network Subnet=192.168.30.0/24 Gateway=192.168.30.1would generate
podman-network: systmd-foo # podman network create systemd-foo systemd-unit: foo-network.service*.volume
Describe a volume to share between multiple containers.
*.image
Ensure a docker image is pulled.
Generates a service that can be used as a dependency.