Skip to content

Commit dd7a362

Browse files
committed
Pod and containers handled by systemd services
1 parent 754fc13 commit dd7a362

7 files changed

+228
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# container-proxy-httpd.service
2+
# autogenerated by Podman 2.1.1
3+
# Tue Mar 1 09:09:51 CET 2022
4+
5+
[Unit]
6+
Description=Podman container-proxy-httpd.service
7+
Documentation=man:podman-generate-systemd(1)
8+
Wants=network.target
9+
After=network-online.target
10+
BindsTo=pod-proxy-pod.service
11+
After=pod-proxy-pod.service
12+
13+
[Service]
14+
Environment=PODMAN_SYSTEMD_UNIT=%n
15+
Restart=on-failure
16+
ExecStartPre=/bin/rm -f %t/container-proxy-httpd.pid %t/container-proxy-httpd.ctr-id
17+
ExecStart=/usr/bin/podman run --conmon-pidfile %t/container-proxy-httpd.pid --cidfile %t/container-proxy-httpd.ctr-id --cgroups=no-conmon --pod-id-file %t/pod-proxy-pod.pod-id -d --replace -dt -v /root/proxy-config:/etc/uyuni -v /root/proxy-rhn-cache:/var/cache/rhn -v /root/proxy-tftpboot:/srv/tftpboot --name proxy-httpd registry.tf.local/proxy-httpd
18+
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-proxy-httpd.ctr-id -t 10
19+
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-proxy-httpd.ctr-id
20+
PIDFile=%t/container-proxy-httpd.pid
21+
TimeoutStopSec=60
22+
Type=forking
23+
24+
[Install]
25+
WantedBy=multi-user.target default.target
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# container-proxy-salt-broker.service
2+
# autogenerated by Podman 2.1.1
3+
# Tue Mar 1 09:09:51 CET 2022
4+
5+
[Unit]
6+
Description=Podman container-proxy-salt-broker.service
7+
Documentation=man:podman-generate-systemd(1)
8+
Wants=network.target
9+
After=network-online.target
10+
BindsTo=pod-proxy-pod.service
11+
After=pod-proxy-pod.service
12+
13+
[Service]
14+
Environment=PODMAN_SYSTEMD_UNIT=%n
15+
Restart=on-failure
16+
ExecStartPre=/bin/rm -f %t/container-proxy-salt-broker.pid %t/container-proxy-salt-broker.ctr-id
17+
ExecStart=/usr/bin/podman run --conmon-pidfile %t/container-proxy-salt-broker.pid --cidfile %t/container-proxy-salt-broker.ctr-id --cgroups=no-conmon --pod-id-file %t/pod-proxy-pod.pod-id -d --replace -dt -v /root/proxy-config:/etc/uyuni --name proxy-salt-broker registry.tf.local/proxy-salt-broker
18+
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-proxy-salt-broker.ctr-id -t 10
19+
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-proxy-salt-broker.ctr-id
20+
PIDFile=%t/container-proxy-salt-broker.pid
21+
TimeoutStopSec=60
22+
Type=forking
23+
24+
[Install]
25+
WantedBy=multi-user.target default.target
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# container-proxy-squid.service
2+
# autogenerated by Podman 2.1.1
3+
# Tue Mar 1 09:09:51 CET 2022
4+
5+
[Unit]
6+
Description=Podman container-proxy-squid.service
7+
Documentation=man:podman-generate-systemd(1)
8+
Wants=network.target
9+
After=network-online.target
10+
BindsTo=pod-proxy-pod.service
11+
After=pod-proxy-pod.service
12+
13+
[Service]
14+
Environment=PODMAN_SYSTEMD_UNIT=%n
15+
Restart=on-failure
16+
ExecStartPre=/bin/rm -f %t/container-proxy-squid.pid %t/container-proxy-squid.ctr-id
17+
ExecStart=/usr/bin/podman run --conmon-pidfile %t/container-proxy-squid.pid --cidfile %t/container-proxy-squid.ctr-id --cgroups=no-conmon --pod-id-file %t/pod-proxy-pod.pod-id --replace -d -v /root/proxy-config:/etc/uyuni -v /root/proxy-squid-cache:/var/cache/squid --name proxy-squid registry.tf.local/proxy-squid
18+
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-proxy-squid.ctr-id -t 10
19+
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-proxy-squid.ctr-id
20+
PIDFile=%t/container-proxy-squid.pid
21+
TimeoutStopSec=60
22+
Type=forking
23+
24+
[Install]
25+
WantedBy=multi-user.target default.target
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# container-proxy-ssh.service
2+
# autogenerated by Podman 2.1.1
3+
# Tue Mar 1 09:09:51 CET 2022
4+
5+
[Unit]
6+
Description=Podman container-proxy-ssh.service
7+
Documentation=man:podman-generate-systemd(1)
8+
Wants=network.target
9+
After=network-online.target
10+
BindsTo=pod-proxy-pod.service
11+
After=pod-proxy-pod.service
12+
13+
[Service]
14+
Environment=PODMAN_SYSTEMD_UNIT=%n
15+
Restart=on-failure
16+
ExecStartPre=/bin/rm -f %t/container-proxy-ssh.pid %t/container-proxy-ssh.ctr-id
17+
ExecStart=/usr/bin/podman run --conmon-pidfile %t/container-proxy-ssh.pid --cidfile %t/container-proxy-ssh.ctr-id --cgroups=no-conmon --pod-id-file %t/pod-proxy-pod.pod-id -d --replace -dt -v /root/proxy-config:/etc/uyuni --name proxy-ssh registry.tf.local/proxy-ssh
18+
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-proxy-ssh.ctr-id -t 10
19+
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-proxy-ssh.ctr-id
20+
PIDFile=%t/container-proxy-ssh.pid
21+
TimeoutStopSec=60
22+
Type=forking
23+
24+
[Install]
25+
WantedBy=multi-user.target default.target
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# container-proxy-tftpd.service
2+
# autogenerated by Podman 2.1.1
3+
# Tue Mar 1 09:09:51 CET 2022
4+
5+
[Unit]
6+
Description=Podman container-proxy-tftpd.service
7+
Documentation=man:podman-generate-systemd(1)
8+
Wants=network.target
9+
After=network-online.target
10+
BindsTo=pod-proxy-pod.service
11+
After=pod-proxy-pod.service
12+
13+
[Service]
14+
Environment=PODMAN_SYSTEMD_UNIT=%n
15+
Restart=on-failure
16+
ExecStartPre=/bin/rm -f %t/container-proxy-tftpd.pid %t/container-proxy-tftpd.ctr-id
17+
ExecStart=/usr/bin/podman run --conmon-pidfile %t/container-proxy-tftpd.pid --cidfile %t/container-proxy-tftpd.ctr-id --cgroups=no-conmon --pod-id-file %t/pod-proxy-pod.pod-id -d --replace -dt -v /root/proxy-config:/etc/uyuni --name proxy-tftpd registry.tf.local/proxy-tftpd
18+
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-proxy-tftpd.ctr-id -t 10
19+
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-proxy-tftpd.ctr-id
20+
PIDFile=%t/container-proxy-tftpd.pid
21+
TimeoutStopSec=60
22+
Type=forking
23+
24+
[Install]
25+
WantedBy=multi-user.target default.target

containers/pod-proxy-pod.service

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# pod-proxy-pod.service
2+
# autogenerated by Podman 2.1.1
3+
# Tue Mar 1 09:09:51 CET 2022
4+
5+
[Unit]
6+
Description=Podman pod-proxy-pod.service
7+
Documentation=man:podman-generate-systemd(1)
8+
Wants=network.target
9+
After=network-online.target
10+
Requires=container-proxy-httpd.service container-proxy-salt-broker.service container-proxy-squid.service container-proxy-ssh.service container-proxy-tftpd.service
11+
Before=container-proxy-httpd.service container-proxy-salt-broker.service container-proxy-squid.service container-proxy-ssh.service container-proxy-tftpd.service
12+
13+
[Service]
14+
Environment=PODMAN_SYSTEMD_UNIT=%n
15+
Restart=on-failure
16+
ExecStartPre=/bin/rm -f %t/pod-proxy-pod.pid %t/pod-proxy-pod.pod-id
17+
ExecStartPre=/usr/bin/podman pod create --infra-conmon-pidfile %t/pod-proxy-pod.pid --pod-id-file %t/pod-proxy-pod.pod-id --name proxy-pod --publish 22:22 --publish 8080:8080 --publish 443:443 --publish 4505:4505 --publish 4506:4506 --add-host server.tf.local:192.168.122.254 --add-host client.tf.local:192.168.122.89 --replace
18+
ExecStart=/usr/bin/podman pod start --pod-id-file %t/pod-proxy-pod.pod-id
19+
ExecStop=/usr/bin/podman pod stop --ignore --pod-id-file %t/pod-proxy-pod.pod-id -t 10
20+
ExecStopPost=/usr/bin/podman pod rm --ignore -f --pod-id-file %t/pod-proxy-pod.pod-id
21+
PIDFile=%t/pod-proxy-pod.pid
22+
TimeoutStopSec=60
23+
Type=forking
24+
25+
[Install]
26+
WantedBy=multi-user.target default.target

containers/run-proxy-with-services.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
3+
set -x
4+
5+
CURDIR=$(dirname $(realpath $0))
6+
CONFIG_DIR="$CURDIR/proxy-config"
7+
SQUID_CACHE_DIR="$CURDIR/proxy-squid-cache"
8+
RHN_CACHE_DIR="$CURDIR/proxy-rhn-cache"
9+
TFTPBOOT_DIR="$CURDIR/proxy-tftpboot"
10+
11+
export REGISTRY=registry.tf.local
12+
13+
# HACK: overcome the inavailability of avahi in containers
14+
export ADD_HOST=server.tf.local:192.168.122.254
15+
export ADD_CLIENT=client.tf.local:192.168.122.89
16+
17+
IMAGES=(proxy-ssh proxy-httpd proxy-salt-broker proxy-squid proxy-tftpd)
18+
19+
for image in "${IMAGES[@]}"
20+
do
21+
podman pull --tls-verify=false $REGISTRY/$image
22+
done
23+
24+
###
25+
# POD
26+
###
27+
podman pod create --name proxy-pod \
28+
--publish 22:22 \
29+
--publish 8080:8080 \
30+
--publish 443:443 \
31+
--publish 4505:4505 \
32+
--publish 4506:4506 \
33+
--add-host $ADD_HOST \
34+
--add-host $ADD_CLIENT
35+
36+
###
37+
# CONTAINERS
38+
###
39+
podman create -dt --pod proxy-pod \
40+
-v $CONFIG_DIR:/etc/uyuni \
41+
--name proxy-ssh \
42+
$REGISTRY/proxy-ssh
43+
44+
podman create -dt --pod proxy-pod \
45+
-v $CONFIG_DIR:/etc/uyuni \
46+
-v $RHN_CACHE_DIR:/var/cache/rhn \
47+
-v $TFTPBOOT_DIR:/srv/tftpboot \
48+
--name proxy-httpd \
49+
$REGISTRY/proxy-httpd
50+
51+
podman create -dt --pod proxy-pod \
52+
-v $CONFIG_DIR:/etc/uyuni \
53+
--name proxy-salt-broker \
54+
$REGISTRY/proxy-salt-broker
55+
56+
podman create -d --pod proxy-pod \
57+
-v $CONFIG_DIR:/etc/uyuni \
58+
-v $SQUID_CACHE_DIR:/var/cache/squid \
59+
--name proxy-squid \
60+
$REGISTRY/proxy-squid
61+
62+
podman create -dt --pod proxy-pod \
63+
-v $CONFIG_DIR:/etc/uyuni \
64+
--name proxy-tftpd \
65+
$REGISTRY/proxy-tftpd
66+
67+
68+
# generate systemd services
69+
podman generate systemd --files --name --new proxy-pod
70+
# replace KillMode=none with TimeoutStopSec=60 as per https://github.com/containers/podman/pull/8889
71+
sed -i 's/KillMode=none/TimeoutStopSec=60/' *-proxy-*.service
72+
73+
mv *-proxy-*.service /etc/systemd/system/.
74+
75+
# start services
76+
systemctl daemon-reload
77+
systemctl start pod-proxy-pod.service

0 commit comments

Comments
 (0)