Pietrangelo Masala

This is my personal blog. Here you will find mainly articles about computer technology.

Snippet-Install Openshift Origin on a centos/rht machine

06 May 2019

This is a snippet that i use when i have to install a test instance of Openshift.

Someone could argues that this is the wrong way to install a test instance of Openshift because of minishift but i hate it!!

The reason is that i usually have a dedicated machine to install to so here is the snippet:

#!/bin/bash

# Install required packages and repos
sudo -i
yum -y update
yum -y install -y yum-utils device-mapper-persistent-data lvm2 wget
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum -y install docker-ce docker-ce-cli containerd.io
systemctl enable docker
systemctl start docker
usermod -aG docker centos
reboot
# Download and install Openshift Origin
wget https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
tar xvfz openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
cd openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit
# make `oc` and `kubectl` available system wide 
sudo cp oc /bin/
sudo cp kubectl /bin/
# Add an entry for the openshift network
sudo -i
touch /etc/docker/daemon.json
echo "
{
   \"insecure-registries\": [
     \"172.30.0.0/16\"
   ]
}
" > /etc/docker/daemon.json
# Reload docker service
systemctl daemon-reload
systemctl restart docker
# Add firewall rules
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 8443/tcp
firewall-cmd --permanent --zone dockerc --add-port 53/udp
firewall-cmd --permanent --zone dockerc --add-port 8053/udp
firewall-cmd --permanent --add-port=8443/tcp
firewall-cmd --permanent --add-port=443/tcp
firewall-cmd --reload
exit
cd
# Start Openshift cluster
# pass --base-dir as argument so i can delete everything when finished
oc cluster up --public-hostname=[your IP] --base-dir=/home/${USER}/oc/config_dir/

- - - - - - - TO EXECUTE ONLY IF YOU ARE ON RHT 7 - - - - - - -
# Enable needed repos

#subscription-manager repos --enable=rhel-7-server-rpms
#subscription-manager repos --enable=rhel-7-server-extras-rpms
#subscription-manager repos --enable=rhel-7-server-optional-rpms

## Install docker
#yum -y install docker device-mapper-libs device-mapper-event-libs

#groupadd docker
#usermod -aG docker [your_user]

#systemctl start docker.service
#systemctl enable docker.service

##Edit /etc/sysconfig/docker file
##Add this line: 
#ADD_REGISTRY='--add-registry registry.access.redhat.com'

## If you have problems with certificates install this package:
#yum -y install python-rhsm-certificates