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
81 changes: 81 additions & 0 deletions docs/microshift-containerized/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Containerized Microshift

## Pre-requisite

Before runnng microshift-containerized as a systemd service, ensure to update the host `crio-bridge.conf` as

```bash
{
"cniVersion": "0.4.0",
"name": "crio",
"type": "bridge",
"bridge": "cni0",
"isGateway": true,
"ipMasq": true,
"hairpinMode": true,
"ipam": {
"type": "host-local",
"routes": [
{ "dst": "0.0.0.0/0" }
],
"ranges": [
[{ "subnet": "10.42.0.0/24" }]
]
}
}
```
## Run microshift-containerized as a systemd service

Copy microshift-containerized unit file to `/etc/systemd` and the microshift-containerized run script to `/usr/bin`

```bash
sudo cp packaging/systemd/microshift-containerized.service /etc/systemd/system/microshift-containerized.service
sudo cp packaging/systemd/microshift-containerized /usr/bin/
```
Now enable and start the service. The KUBECONFIG location will be written to `/etc/microshift-containerized/microshift-containerized.conf`.


```bash
sudo systemctl enable microshift-containerized --now
source /etc/microshift-containerized/microshift-containerized.conf
```

Verify that microshift is running.
```
kubectl get pods -A
```

Stop microshift-containerized service

```bash
systemctl stop microshift-containerized
```

You can check microshift-containerized via

```bash
sudo podman ps
sudo critcl ps
```

To access the cluster on the host or inside the container

### Access the cluster inside the container
Execute the following command to get into the container:

```bash
sudo podman exec -ti microshift-containerized bash
```
Inside the container, run the following to see the pods:

```bash
export KUBECONFIG=/var/lib/microshift/resources/kubeadmin/kubeconfig
kubectl get pods -A
```

### Access the cluster on the host
#### Linux
```bash
export KUBECONFIG=/var/lib/microshift/resources/kubeadmin/kubeconfig
kubectl get pods -A -w
```
8 changes: 8 additions & 0 deletions packaging/systemd/microshift-containerized
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -euxo pipefail

[[ -d /etc/microshift-containerized ]] || mkdir -p /etc/microshift-containerized
cat <<EOF > /etc/microshift-containerized/microshift-containerized.conf
export KUBECONFIG=/var/lib/microshift/resources/kubeadmin/kubeconfig
EOF
24 changes: 24 additions & 0 deletions packaging/systemd/microshift-containerized.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# container-microshift-containerized.service
# autogenerated by Podman 3.1.2
# Wed Sep 29 13:15:18 EDT 2021

[Unit]
Description=Podman container-microshift-containerized.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
After=network-online.target
RequiresMountsFor=/var/lib/containers/storage /run/containers/storage

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/container-microshift-containerized.pid %t/container-microshift-containerized.ctr-id
ExecStart=/usr/bin/podman run --conmon-pidfile %t/container-microshift-containerized.pid --cidfile %t/container-microshift-containerized.ctr-id --cgroups=no-conmon --replace --privileged -d --rm --name microshift-containerized -v /var/run:/var/run -v /sys:/sys:ro -v /var/lib:/var/lib:rw,rshared -v /lib/modules:/lib/modules -v /etc:/etc -v /run/containers:/run/containers -v /var/log:/var/log -e KUBECONFIG=/var/lib/microshift/resources/kubeadmin/kubeconfig quay.io/microshift/microshift:4.7.0-0.microshift-2021-08-31-224727-linux-amd64
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-microshift-containerized.ctr-id -t 10
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-microshift-containerized.ctr-id
PIDFile=%t/container-microshift-containerized.pid
Type=forking

[Install]
WantedBy=multi-user.target default.target