Skip to content

Instantly share code, notes, and snippets.

@orcunuso
Last active February 24, 2021 13:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save orcunuso/d6d706815365fe5111477352b4af892f to your computer and use it in GitHub Desktop.
Save orcunuso/d6d706815365fe5111477352b4af892f to your computer and use it in GitHub Desktop.
Minimal OpenShift cluster
#!/bin/bash
# Before start, please check that sysctl net.ipv4.ip_forward is set to 1.
# Install yum packages
yum install -y vim curl net-tools bash-completion yum-utils lsof
# Install Docker latest. yum-utils package is required (which provides the yum-config-manager
# utility) in order to set up the docker stable repository. After install, we need to define
# docker network as insecure registry to prevent failure during cluster creation.
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
systemctl enable docker
systemctl start docker
echo '{"insecure-registries" : ["172.30.0.0/16"]}' >> /etc/docker/daemon.json
systemctl restart docker
# Get the OpenShift cli binary. Check for latest oc version from https://www.okd.io/download.html
curl -LO https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
tar -xvzf openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
mv openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit/oc /usr/local/bin
# Configure Firewalld service. Ensure that your firewall allows containers access to the
# OpenShift master API (8443/tcp) and DNS (53/udp) endpoints.
firewall-cmd --permanent --new-zone dockerc
firewall-cmd --permanent --zone dockerc --add-source 172.17.0.0/16
firewall-cmd --permanent --zone dockerc --add-port={80,443,8443}/tcp
firewall-cmd --permanent --zone dockerc --add-port={53,8053}/udp
firewall-cmd --permanent --zone public --add-port={80,443,8443}/tcp
firewall-cmd --reload
# Create an OpenShift cluster. Normally the routing suffix should point to the VIP of your infra
# nodes where your haproxy instances run but as we have all-in-one setup here, a nip.io domain
# that includes private IP of your server will be fine.
mkdir /root/ocp
oc cluster up --base-dir='/root/ocp' --public-hostname='ocp.orcunuso.io' --routing-suffix='172-16-137-6.nip.io'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment