Skip to content

Instantly share code, notes, and snippets.

@fabianoflorentino
Forked from orcunuso/occlusterup.sh
Last active March 6, 2021 15:16
Show Gist options
  • Save fabianoflorentino/20eb6bc18f485dd97a3af083eb709f9d to your computer and use it in GitHub Desktop.
Save fabianoflorentino/20eb6bc18f485dd97a3af083eb709f9d to your computer and use it in GitHub Desktop.
Minimal OpenShift cluster
#!/bin/bash
IP_ADDR=$(ip addr |grep 172.16.252 |head -n1 |awk '{ print $2 }' |cut -d"/" -f1)
echo "${IP_ADDR} $HOSTNAME" >> /etc/hosts
# 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
# 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 \
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://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
mv ./kubectl /usr/local/bin/
chmod +x /usr/local/bin/kubectl
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/
rm -rf ./openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit
# 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 /opt/ocp
oc cluster up --base-dir='/opt/ocp' --public-hostname='ocp.lab.local' --routing-suffix='ocp.lab.local'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment