/ Tech

OpenShift oc cluster up as Systemd Service

Running a single node OpenShift cluster is very easy with oc cluster up.

It's also very easy to run it as system service with persistent configuration, so that on system boot the simple single-node OpenShift cluster starts using the configuration saved. Just put the following Systemd unit under /etc/systemd/system/openshift.service and enable / start it.

[Unit]
Description=OpenShift oc cluster up Service
After=docker.service
Requires=docker.service

[Service]
ExecStart=/usr/local/bin/oc cluster up --host-config-dir=/var/lib/openshift/config --host-data-dir=/var/lib/openshift/data --host-pv-dir=/var/lib/openshift/pv --host-volumes-dir=/var/lib/openshift/volumes --use-existing-config=true --public-hostname=openshift.example.ch --routing-suffix=app.example.com --loglevel=1 --metrics=true
ExecStop=/usr/local/bin/oc cluster down
WorkingDirectory=/var/lib/openshift
Restart=no
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=occlusterup
User=root
Type=oneshot
RemainAfterExit=yes
TimeoutSec=300

[Install]
WantedBy=multi-user.target

More information about the single node OpenShift cluster can be found on Github.