Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions hack/all-in-one/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
24 changes: 24 additions & 0 deletions hack/all-in-one/microshift-aio-run
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted a file with the location of the KUBECONFIG like so:

cat <<EOF > /etc/microshift-aio/microshift-aio.conf
export KUBECONFIG=$(/usr/bin/podman volume inspect microshift-vol --format "{{.Mountpoint}}")/microshift/resources/kubeadmin/kubeconfig
EOF

I could not see a better way of getting that path from the service, but that is definitely extra and does not need to be included in the service. I figured it saves users from having to look up the path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also could not figure out how to run ExecStartPost=source /etc/microshift-aio/microshift-aio.conf
I tried ExecStartPost=source, ExecStartPost=/bin/bash source etc, nothing worked but there is def something that does, I gave up and pushed the commit but will keep looking

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@husky-parul if you find something that works or if we decide it's not necessary, you can remove it, feel free to squash/amend, too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see, that makes sense


/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 <<EOF > /etc/microshift-aio/microshift-aio.conf
export KUBECONFIG=$(/usr/bin/podman volume inspect microshift-vol --format "{{.Mountpoint}}")/microshift/resources/kubeadmin/kubeconfig
EOF
15 changes: 15 additions & 0 deletions hack/all-in-one/microshift-aio.service
Original file line number Diff line number Diff line change
@@ -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