diff --git a/hack/all-in-one/README.md b/hack/all-in-one/README.md index d4d6c70d37..a8b9d36cfe 100644 --- a/hack/all-in-one/README.md +++ b/hack/all-in-one/README.md @@ -1,5 +1,35 @@ # Containerized Microshift +## Run microshift all-in-one as a systemd service + +Copy microshift-aio unit file to /etc/systemd and the aio-run to /usr/bin + +```bash +cp microshift-aio.service /etc/systemd/system/microshift-aio.service +cp microshift-aio-run /usr/bin/ +``` +Now enable and start the service. The KUBECONFIG location will be written to /etc/microshift-aio/microshift-aio.conf +If the `microshift-vol` podman volume does not exist, the systemd service will create one. + +```bash +systemctl enable microshift-aio --now +source /etc/microshift-aio/microshift-aio.conf +``` + +Verify that microshift is running. +``` +kubectl get pods -A +``` + +Stop microshift-aio service + +```bash +systemctl stop microshift-aio +``` + +**NOTE** Stopping microshift-aio service _does not_ remove the podman volume `microshift-vol`. +A restart will use the same volume. + ## Build Container Image First copy microshift binary to this directory, then build the container image: ```bash diff --git a/hack/all-in-one/microshift-aio-run b/hack/all-in-one/microshift-aio-run new file mode 100755 index 0000000000..f99ac97b7b --- /dev/null +++ b/hack/all-in-one/microshift-aio-run @@ -0,0 +1,24 @@ +#!/bin/bash + +set -euxo pipefail + +setsebool -P container_manage_cgroup true + +if ! /usr/bin/podman volume exists microshift-vol +then + /usr/bin/podman volume create microshift-vol +fi + +[[ -d /etc/microshift-aio ]] || mkdir /etc/microshift-aio + +/usr/bin/podman run -d --rm \ + --name microshift --privileged \ + -v /lib/modules:/lib/modules \ + -v microshift-vol:/var/lib \ + --hostname microshift \ + --label "io.containers.autoupdate=registry" \ + -p 6443:6443 quay.io/microshift/microshift:4.7.0-0.microshift-2021-08-31-224727-aio + +cat < /etc/microshift-aio/microshift-aio.conf +export KUBECONFIG=$(/usr/bin/podman volume inspect microshift-vol --format "{{.Mountpoint}}")/microshift/resources/kubeadmin/kubeconfig +EOF diff --git a/hack/all-in-one/microshift-aio.service b/hack/all-in-one/microshift-aio.service new file mode 100644 index 0000000000..835cf7339a --- /dev/null +++ b/hack/all-in-one/microshift-aio.service @@ -0,0 +1,15 @@ +[Unit] +Description=microshift all-in-one +Wants=network-online.target +After=network-online.target +RequiresMountsFor=/run/containers/storage + +[Service] +Restart=on-failure +TimeoutStopSec=70 +ExecStart=/bin/bash /usr/bin/microshift-aio-run +ExecStop=/usr/bin/podman stop -t 20 microshift +Type=forking + +[Install] +WantedBy=multi-user.target default.target