Skip to content

Instantly share code, notes, and snippets.

@kuchibs
Last active September 11, 2019 09:11
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kuchibs/5de2acfe7a5323b2c16bf312c06f764c to your computer and use it in GitHub Desktop.
Save kuchibs/5de2acfe7a5323b2c16bf312c06f764c to your computer and use it in GitHub Desktop.
Use Ansible to install Openshift Origin (oc) single node cluster on number of machines!

Install OpenShift Origin on one node (CENTOS) - commands:

1) Install docker

yum install docker -y 
systemctl start docker

Note:

echo "INSECURE_REGISTRY='--insecure-registry 172.30.0.0/16'" >> /etc/sysconfig/docker
systemctl enable docker
systemctl start  docker

2) Get Openshift and put it in class path

mkdir ~/1sarvani && cd 1sarvani
wget https://github.com/openshift/origin/releases/download/v1.5.0/openshift-origin-client-tools-v1.5.0-031cbe4-linux-64bit.tar.gz
tar -xvzf openshift-origin-client-tools-v1.5.0-031cbe4-linux-64bit.tar.gz
mv openshift-origin-client-tools-v1.5.0-031cbe4-linux-64bit/* /usr/local/bin/

3) start OC cluster oc cluster up OR

oc cluster up \
                --image-streams=rhel7 \
                --host-pv-dir='/root/host-pv' \
                --host-volumes-dir='/root/host-volumes' \
                --host-data-dir='/root/host-etcd-data' \
                --host-config-dir='/root/host-config' \
                --use-existing-config

Now, to do the same using Ansible:

https://github.com/kuchibs/osetraintsk.git

Troubleshooting:

  • When OSE installation throws error: config.yml --> {"failed": true, "msg": "Failed to query Docker API. Is docker running on this host?"} However, you have docker installed and is running!
  • Solution : we need docker-ce and not docker or docker-ee
    sudo systemctl stop docker
    sudo yum -y remove docker
    sudo yum remove container-selinux-2.33-1.git86f33cd.el7.noarch
    sudo yum-config-manager -y --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    sudo yum install -y --setopt=obsoletes=0   docker-ce-17.03.1.ce-1.el7.centos   docker-ce-selinux-17.03.1.ce-1.el7.centos
    sudo mv  /var/lib/docker/devicemapper/ /tmp
    systemctl status docker
    sudo systemctl start docker
    systemctl status docker
  • More simpler solution In your hosts file, in the play, [OSEv3:vars] , add the line openshift_disable_check=disk_availability,docker_storage,memory_availability to disable the checks! OR Goto /openshift-ansible/playbooks/common/openshift-cluster/config.yml and inside - - action: openshift_health_check
 action: openshift_health_check
     args:
      checks:
      - disk_availability
      #- memory_availability
      - package_availability
      - package_version
      #- docker_image_availability
      #- docker_storage

Install OpenShift Origin on multiple nodes (CENTOS7.4)

Pre-reqs https://docs.openshift.org/latest/install_config/install/prerequisites.html#install-config-install-prerequisites Installting using ansible https://github.com/openshift/openshift-ansible

I am using the following: https://www.youtube.com/watch?v=wWSRpaosc-M https://docs.openshift.org/latest/install_config/install/host_preparation.html https://docs.openshift.org/latest/install_config/install/advanced_install.html#advanced-verifying-the-installation

  • Step1) Create 3 vms. 1 master(m1), 2 nodes(n1,n2)
  • Step2) Prepare the vms: - set hostname with fqdn m1.abc.com hostnamectl set-hostname m1.abc.com, cat /etc/sysconfig/network file should also have the same. - have '/etc/hosts' entry for m1, n1, n2 Example 10.131.173.146 m1 10.131.172.189 n1 10.131.173.147 n2
  • Step3) Have 40Gb at /var partition. Assuming you have space and /var needs to be extended, follow the following:
--to extend file system
 df -Th
 lsblk
 lvextend -L +40G /dev/mapper/vg_root-var
 df -TH
 resize2fs /dev/mapper/vg_root-var
 df -TH
--

Else, add new disk, create partition, and then extend


  • Step4) Now, time to prepare the host with prereq installs:
yum install -y epel-release docker ansible git
yum install -y wget git net-tools bind-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct
echo "INSECURE_REGISTRY='--insecure-registry 172.30.0.0/16'" >> /etc/sysconfig/docker    #172.30.0.0/16 is the default value of the servicesSubnet variable in the master-config.yaml file
cat /etc/sysconfig/docker  #verify insecure reg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment