OpenShift Installation
Following are the installation steps:
casp1031
OpenShift Docker Installation for a Distributed SpectroSERVER
: Ensure you have atleast 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 master, ssh-copyid should be done from master to master also, otherwise the playbook will fail for 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 with <master node host name>and replace the 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
Post Installation
- 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 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 master node:vi /etc/docker/daemon.json{"insecure-registries" : ["master.com:5000"]}Replace 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 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
- 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
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