OpenShift Installation
Following are the installation steps:
casp1032
OpenShift Docker Installation for a Distributed SpectroSERVER.
Ensure you have at least two VMs, one as the master node VM and the other as worker node VM. Subsequently, you can scale the VM count.
Prerequisites
- Ensure that all machines have a Red Hat Subscription Manager. Ensure that the following repositories are enabled. Run the following commands to enable the repositories:
- subscription-manager config --rhsm.manage_repos =1
- rhel-7-server-extras-rpms/x86_64subscription-manager repos --enable=rhel-7-server-rpms
- rhel-7-server-rpms/7Server/x86_64subscription-manager repos --enable=rhel-7-server-extras-rpms
- rhel-7-server-rt-rpms/7Server/x86_64subscription-manager repos --enable=rhel-7-server-optional-rpms
Installation Procedure
Mandatory
: The root_pwd on all the VMs included in the Openshift cluster should be the same. Openshift can create a container(s) on any node/vm and therefore having the same password across all the VMs is necessary.Following are the installation steps:
- Add the Domain Name Server (DNS) '<LOCALIP>' in the /etc/resolv.conf folder. TheLocalIPhere refers to the DNS server IP. Skip this step if already configured. The following services on all master and worker nodes, should be enabled and running.
- systemctl statusNetworkManager
- systemctl statusdnsmasq
- If the services are not enabled and running, execute the following commands:yum -y install NetworkManageryum -y install dnsmasqservice NetworkManager startservice dnsmasq start
- Run the following commands on all the master and worker node hosts:yum -y updatesubscription-manager repos --enable rhel-7-server-ansible-2.5-rpmsyum -y install vim wget git net-tools bind-utils iptables-services bridge-utils bash-completion pyOpenSSL dockeryum -y install ansible
- Enable and start the docker on master and worker nodes.
- Set up the SSH keys for access on all nodes. Perform this step on the MASTER NODE. Perform this step manually or use the script that is mentioned:sed "s/#PermitRootLogin yes/PermitRootLogin yes/g" -i /etc/ssh/sshd_config ; systemctl restart sshdssh-keygenfor host in master.example.com \node1.example.com \node2.example.com; \do ssh-copy-id -i ~/.ssh/id_rsa.pub $host; \doneWhen running the ansible playbook from the master, ssh-copyid should be done from master to master also, otherwise, the playbook will fail for the localhost.
- Clone Git repository for OpenShift release, on the master node only.cd ~ ; git clone https://github.com/openshift/openshift-ansiblecd openshift-ansiblegit checkout release-1.5
- Create hosts file in '/etc/ansible/hosts' for the master node only.Replace the<master.com>with <master node host name>and replace the<worker.com>with the <worker node host name>Replace<address>with respectivemaster node / worker node IP[OSEv3:children]mastersnodesetcd[OSEv3:vars]ansible_ssh_user=rootdeployment_type=originopenshift_disable_check=docker_storagecontainerized=trueopenshift_release=v1.5openshift_image_tag=v1.5.0osm_cluster_network_cidr=10.163.0.0/16enable_excluders=falseopenshift_master_identity_providers=[{'name': 'htpasswd_auth','login': 'true', 'challenge': 'true','kind': 'HTPasswdPasswordIdentityProvider','filename': '/etc/origin/master/htpasswd'}][masters]<master.com> openshift_ip=<address> openshift_public_ip=<address> openshift_public_hostname=<master.com> openshift_schedulable=true[nodes]<master.com> openshift_ip=<address> openshift_public_ip=<address> openshift_public_hostname=<master.com> openshift_node_labels="{'region': 'infra', 'zone': 'default'}" openshift_schedulable=true<worker.com> openshift_ip=<address> openshift_public_ip=<address> openshift_public_hostname=<worker.com> openshift_node_labels="{'region': 'primary', 'zone': 'east'}" openshift_schedulable=true[etcd]<master.com>
- Run the following Ansible playbook installation command, for the master node only:ansible-playbook -i /etc/ansible/hosts ~/openshift-ansible/playbooks/byo/config.yml
- Log in to the OpenShift UI using the url 'https://<masterhostname>:8443' (where 8443 is the default port number) and enter the admin/admin or system/admin credentials. If you want to create your own root credentials execute the following command on master and set a new password for root.htpasswd /etc/origin/master/htpasswd root
- To launch Jasper reports, run thejdbc:mysql://<openshiftnode>:<nodeport-ephemeral port>/reportingcommand.For example, jdbc:mysql://<mastername>:45673/reporting
Post Installation Tasks
Perform the following post-installation tasks.
- Create a project in OpenShift using the OpenShift UI or by issuing the following command on the OpenShift master:oc new-project <projectname>
- Create a local docker image repository on the OpenShift cluster so that Spectrum Images can be pushed onto it and can be globally accessible across the cluster. To create a local docker repository on OpenShift execute the following command on the master node:vi /etc/docker/daemon.json{"insecure-registries" : ["master.com:5000"]}Replace'master.com'with the 'master node host name'.To Rollout/Create a local docker repository:oc rollout latest docker-registry
- We would need the serviceip of the docker registry created in the aforementioned step to push Spectrum Images into the same. For getting the service ip of docker local registry created. This step is mandatory for OpenShift to get the service fetch command to work.oc login -u system:adminoc project <project-name>ip = oc get svc -n default | grep docker-registry|awk '{print $2;}'
- Post fetching the docker registry ip, do an OpenShift login using user-defined credentials. Post that we will have to log into the docker registry.oc login -u <username>:<pwd>Log into registry servicedocker login -u openshift -p $(oc whoami -t) <ip>:5000
- Post logging in, tag and push image onto local docker repository:docker tag spectrumspectroserverimage <ip>:5000/<project-name>/ssocsimage docker push <ip>:5000/<project-name>/spectrumspectroserverimage
- The command for configuration changes to allow images to run as ROOT user***:This step is mandatory for the image to run. Here 'admin' is the main admin privileges.oc login -u system:adminoadm policy add-scc-to-group anyuid system:authenticated
- To launch Jasper reports, run thejdbc:mysql://<openshiftnode>:<nodeport-ephemeral port>/reportingcommand.For example, jdbc:mysql://<mastername>:45673/reporting
General Commands
- To get container details for OpenShift, run the following command:oc get podsNAME READY STATUS RESTARTS AGEblog-django-py-1-5bv76 1/1 Running 0 3dcommand-demo 1/1 Running 0 2ht3image-1-4991j 1/1 Running 0 4h
- Command to log in to an OpenShift container:oc exec -it command-demo – sh
Troubleshooting
Q: OneClick WebApp is not supported in Docker.
A: Follow these steps to troubleshoot:
- Copy the package to the docker host>container, using the ‘docker copy <filename> <containerName:/path>’
- After copying the file to the container, install the package using the ‘yum localinstall pkgName’. While creating the container, create a port mapping like it is done for the OneClick port, as shown in the example here:docker run -e ROOT_PASSWORD=???.qaperf184 -e MAIN_LOCATION_SERVER=719de9a39c46 -e MAIN_LOCATION_SERVER_IP=172.17.0.2-e TOMCAT_PORT=8080-p 9090:8080-e MASTER_NODE=docker-rh74vm2 -it 1032ocimageFor OneClick WebApp:docker run -e ROOT_PASSWORD=???.qaperf184 -e MAIN_LOCATION_SERVER=719de9a39c46 -e MAIN_LOCATION_SERVER_IP=172.17.0.2-e TOMCAT_PORT=8080-p 9090:8080 -p 9099:9443-e MASTER_NODE=docker-rh74vm2 -it 1032ocimageHere 9443 is the port number that WebApp uses, once the OC container is created.
- Launch the spectrum WebApp using the following URL:http://dockerHost:9099