Sunday, January 26, 2014

OpenShift Origin 3.0 with JBossews CentOS Installation


One can download the CentOS Minimal Image at
http://wiki.centos.org/Download

One of link is
http://mirror.trouble-free.net/centos/6.5/isos/x86_64/

Install the VM Image by using VirtualBox
https://www.virtualbox.org/

It is recommended to use
4GB Memory
40GB Dynamic Disk Space




Following needed to be set
Bridge Adapter


After the installation complete, run following bash script

(Host at github https://github.com/danilko/openshift-origin-3-jbossews-cartridge-installation)

#!/bin/bash

BROKER_OPENSHIFT_HOSTNAME=`hostname`
APP_OPENSHIFT_HOSTNAME=`echo ${BROKER_OPENSHIFT_HOSTNAME} | cut -d '.' -f2-`

# Make eth0 adapater enable during system start up
sed -i 's^ONBOOT=no^ONBOOT=yes^g' /etc/sysconfig/network-scripts/ifcfg-eth0

# Restart network service
service network restart

# Make current hostname to be resolvable
echo  -e "\n127.0.0.1 broker.platform.local" >> /etc/hosts

yum -y install java-1.7.0-openjdk-devel wget unzip

cd /tmp
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6*.rpm;
cat > /etc/yum.repos.d/openshift-origin-deps.repo <<"EOF"
[openshift-origin-deps]
name=OpenShift Origin Dependencies - EL6
baseurl=http://mirror.openshift.com/pub/origin-server/release/3/rhel-6/dependencies/$basearch/
gpgcheck=0
EOF

yum install -y ruby193-ruby unzip curl bind httpd-tools puppet augeas

# Install default config file
cat > ~/.openshift/oo-install-cfg.yml <<"EOF"
---
Version: 0.0.1
Description: This is the configuration file for the OpenShift Installer.
Deployment:
  DNS:
    component_domain: broker.platform.local
    register_components: Y
    app_domain: platform.local
  Hosts:
  - ip_addr: 127.0.0.1
    named_ip_addr: 127.0.0.1
    user: root
    host: broker.platform.local
    state: new
    ip_interface: eth0
    roles:
    - msgserver
    - dbserver
    - broker
    - node
    ssh_host: localhost
Vendor: OpenShift Origin Community
Subscription:
  type: yum
  jenkins_repo_base: http://pkg.jenkins-ci.org/redhat
  repos_base: https://mirror.openshift.com/pub/origin-server/release/3/rhel-6
Name: OpenShift Installer Configuration
EOF

sh <(curl -s https://install.openshift.com/) -w origin_deploy

# Update the DNS of current host
nsupdate -k /var/named/Kplatform.local*.key
server ${BROKER_OPENSHIFT_HOSTNAME}
update delete ${BROKER_OPENSHIFT_HOSTNAME} A
update add  180 A 127.0.0.1
send
quit

######################################
## SSL Cert Generation
######################################

mkdir -p /tmp/pki
cd /tmp/pki

cat >  platform.crt.config <<"EOF"
 RANDFILE               = $ENV::HOME/.rnd

 [ req ]
 default_bits           = 1024
 default_keyfile        = keyfile.pem
 distinguished_name     = req_distinguished_name
 attributes             = req_attributes
 prompt                 = no
 output_password        = changeme

 [ req_distinguished_name ]
 C                      = US
 ST                     = CA
 L                      = SAN JOSE
 O                      = PLATFORM
 OU                     = PLATFORM
 CN                     = *.platform.local
 emailAddress           = changeme

 [ req_attributes ]
 challengePassword              = changeme
EOF

# Generate a new key that lasts 365 days
openssl req -batch -x509 -nodes -days 365 -newkey rsa:2048 -keyout platform.key -out platform.crt -config platform.crt.config

# Backup old certificate and key
\cp -rf  /etc/pki/tls/certs/localhost.crt /etc/pki/tls/certs/localhost.crt.bak
\cp -rf  /etc/pki/tls/private/localhost.key /etc/pki/tls/private/localhost.key.bak

# Copy certificate and key
\cp -rf platform.crt /etc/pki/tls/certs/localhost.crt
\cp -rf platform.key /etc/pki/tls/private/localhost.key

# Setup so the serveralias also contain *platform.local
sed -i 's^ServerAlias localhost^ServerAlias localhost *.platform.local^g' /etc/httpd/conf.d/000001_openshift_origin_node.conf
sed -i 's^ServerAlias localhost^ServerAlias localhost *.platform.local^g' /etc/httpd/conf.d/000002_openshift_origin_broker_proxy.conf

# Get certificate through opnenssl
# Do not need since the cert is auto generated
#echo -n | openssl s_client -connect broker.platform.local:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > platform.crt

# Import to java keystore to prevent ssl problem
keytool -import -trustcacerts -keystore /usr/lib/jvm/java-1.7.0-openjdk-1.7.*.x86_64/jre/lib/security/cacerts -storepass changeit -noprompt -alias platform_cert -file /tmp/pki/platform.crt

cd  /tmp
rm -rf /tmp/pki

# Restart httpd
service httpd restart

# Ensure cgconfig and cgred is on to make sure gear config
/sbin/chkconfig cgconfig on
/sbin/chkconfig cgred on

reboot now

After the reboot, run the following bash script
#!/bin/bash

cd /tmp

TOMCAT7_VER=7.0.50
TOMCAT6_VER=6.0.37
MAVEN_VER=3.1.1

# Download binary
wget http://supergsego.com/apache/tomcat/tomcat-7/v${TOMCAT7_VER}/bin/apache-tomcat-${TOMCAT7_VER}.tar.gz
wget http://apache.mirrors.hoobly.com/tomcat/tomcat-6/v${TOMCAT6_VER}/bin/apache-tomcat-${TOMCAT6_VER}.tar.gz 
wget http://apache.petsads.us/maven/maven-3/3.1.1/binaries/apache-maven-${MAVEN_VER}-bin.tar.gz 
wget https://github.com/openshift/origin-server/archive/openshift-origin-release-3.zip 

# Untar/Unzip binaries
tar -xvf apache-tomcat-${TOMCAT7_VER}.tar.gz
tar -xvf apache-tomcat-${TOMCAT6_VER}.tar.gz
tar -xvf apache-maven-${MAVEN_VER}-bin.tar.gz
unzip openshift-origin-release-3.zip

######################################
## Install Maven
######################################
\cp -rf apache-maven-${MAVEN_VER} /etc/alternatives/maven

# Setup maven path system wide
echo -e 'export M2_HOME=/etc/alternatives/maven\nexport PATH=${M2_HOME}/bin:${PATH}'  > /etc/profile.d/maven.sh

source /etc/profile.d/maven.sh

mvn -v

######################################
## Install JBossews
######################################
# Copy jbossews/tomcat to correct location
\cp -rf apache-tomcat-${TOMCAT6_VER} /etc/alternatives/jbossews-1.0
\cp -rf apache-tomcat-${TOMCAT7_VER} /etc/alternatives/jbossews-2.0

# Copy openshift cartridges
\cp -rf origin-server-openshift-origin-release-3/cartridges/openshift-origin-cartridge-jbossews /usr/libexec/openshift/cartridges/jbossews

chmod a+x /usr/libexec/openshift/cartridges/jbossews/bin/*

# Install the cartridge
oo-admin-cartridge -a install -s /usr/libexec/openshift/cartridges/jbossews

# Clear broker cache
oo-admin-broker-cache -c

# Clean up folder
rm -rf origin-server-openshift-origin-release-3
rm -rf apache-maven-${MAVEN_VER}
rm -rf  apache-tomcat-${TOMCAT7_VER}
rm -rf  apache-tomcat-${TOMCAT6_VER}

######################################
## Change Default User Gear Size all to medium
######################################

# Resource limit file
RESOURCE_LIMIT_CONFIG_FILE=/etc/openshift/resource_limits.conf
sed -i 's^node_profile=small^node_profile=medium^g' ${RESOURCE_LIMIT_CONFIG_FILE}
sed -i 's^quota_blocks=1048576^quota_blocks=2097152^g' ${RESOURCE_LIMIT_CONFIG_FILE}
sed -i 's^quota_files=80000^quota_files=999999^g' ${RESOURCE_LIMIT_CONFIG_FILE}
sed -i 's^memory_limit_in_bytes=536870912       # 512MB^memory_limit_in_bytes=1073741824       # 1024MB^g' ${RESOURCE_LIMIT_CONFIG_FILE}
sed -i 's^memory_memsw_limit_in_bytes=641728512 # 512M + 100M (100M swap)^memory_memsw_limit_in_bytes=1178599424 # 1024M + 100M (100M swap)^g' ${RESOURCE_LIMIT_CONFIG_FILE}

# Set the file connection limit
RESOURCE_LIMIT_CONFIG_FILE=/etc/security/limits.conf
sed -i 's^#End of file^^g' ${RESOURCE_LIMIT_CONFIG_FILE}

echo -e "\n* soft nofile 32000\n* hard nofile 32000" >> ${RESOURCE_LIMIT_CONFIG_FILE}
echo -e "\n#End of file" >> ${RESOURCE_LIMIT_CONFIG_FILE}

# Reboot node services
service mcollective restart
oo-cgroup-enable --with-all-containers
oo-pam-enable --with-all-containers
oo-admin-ctl-tc restart

sed -i 's^"small"^"medium"^g' /etc/openshift/broker.conf

# Change demo user gear size
oo-admin-ctl-user --removegearsize small -l demo
oo-admin-ctl-user --addgearsize medium -l demo

# Clear broker cache
oo-admin-broker-cache -c

######################################
## Setup rhc tool
######################################

# Setup rhc tool
gem install rhc
echo yes | rhc setup --server=broker.platform.local -l demo -p changeme -k –no-create-token

By the end, one should have a working OpenShift configuration with JBossews Cartridges enable


Thanks.

Sincerely,
Danil

6 comments:

  1. Thank you for documenting this.

    ReplyDelete
  2. Hi Danil,

    I followed the first part and had no issues in running the first script went fine.
    After thr reboot when i ran the second part had issues in tomcat versions.
    Solved it with appropriate version.
    Second issue # Copy openshift cartridges
    \cp -rf origin-server-openshift-origin-release-3/cartridges/openshift-origin-cartridge-jbossews /usr/libexec/openshift/cartridges/jbossews

    chmod a+x /usr/libexec/openshift/cartridges/jbossews/bin/*
    I created the Directory manually and files were copied while running the scripts

    After this script is getting failed at
    # Install the cartridge
    oo-admin-cartridge -a install -s /usr/libexec/openshift/cartridges/jbossews

    Please help me on this.
    Awaiting for an reply from your end.

    ReplyDelete
    Replies
    1. Vijay,

      Sorry for the late reply. I normally only check through the weekend.

      I suspect the problem is unzip fails, may you try following:

      yum -y install unzip

      unzip openshift-origin-release-3.zip

      rm -rf /usr/libexec/openshift/cartridges/jbossews

      # Copy openshift cartridges
      cp -rf origin-server-openshift-origin-release-3/cartridges/openshift-origin-cartridge-jbossews /usr/libexec/openshift/cartridges/jbossews

      chmod a+x /usr/libexec/openshift/cartridges/jbossews/bin/*

      # Install the cartridge
      oo-admin-cartridge -a install -s /usr/libexec/openshift/cartridges/jbossews

      I also update the script to ensure the unzip must be installed.

      Thanks.

      Sincerely,
      Danil

      Delete
  3. Hi,

    Thanks for the script :), but facing with below error:
    The OpenShift deployment configuration has the following errors:

    * The implied host domain 'platform.local' does not match the specified host domain of 'broker.platform.local' for DNS
    Rerun the installer to correct these errors.


    could you please help.

    ReplyDelete
    Replies
    1. Hello chatainay.gk,

      Sorry for the late replay. I suspected the error is because the script is no longer compatible with the new OpenShift v4 spec. I will suggest to use their released version VM is a faster path (http://www.openshift.org/documentation/oo_deployment_guide_vm.html) if you are doing the single instance deployment. After the vm is deployed, run following to install tomcat (however, V4 is shipping with a JBossAS already, so you may not need to install tomcat if you perfer jboss):

      #!/bin/bash

      cd /tmp

      TOMCAT7_VER=7.0.50
      TOMCAT6_VER=6.0.37
      MAVEN_VER=3.1.1

      # Download binary
      wget http://supergsego.com/apache/tomcat/tomcat-7/v${TOMCAT7_VER}/bin/apache-tomcat-${TOMCAT7_VER}.tar.gz
      wget http://apache.mirrors.hoobly.com/tomcat/tomcat-6/v${TOMCAT6_VER}/bin/apache-tomcat-${TOMCAT6_VER}.tar.gz
      wget http://apache.petsads.us/maven/maven-3/3.1.1/binaries/apache-maven-${MAVEN_VER}-bin.tar.gz
      wget https://github.com/openshift/origin-server/archive/openshift-origin-release-3.zip

      # Untar/Unzip binaries
      tar -xvf apache-tomcat-${TOMCAT7_VER}.tar.gz
      tar -xvf apache-tomcat-${TOMCAT6_VER}.tar.gz
      tar -xvf apache-maven-${MAVEN_VER}-bin.tar.gz
      unzip openshift-origin-release-4.zip

      ######################################
      ## Install JBossews
      ######################################
      # Copy jbossews/tomcat to correct location
      \cp -rf apache-tomcat-${TOMCAT6_VER} /etc/alternatives/jbossews-1.0
      \cp -rf apache-tomcat-${TOMCAT7_VER} /etc/alternatives/jbossews-2.0

      # Copy openshift cartridges
      \cp -rf origin-server-openshift-origin-release-3/cartridges/openshift-origin-cartridge-jbossews /usr/libexec/openshift/cartridges/jbossews

      chmod a+x /usr/libexec/openshift/cartridges/jbossews/bin/*

      # Install the cartridge
      oo-admin-cartridge -a install -s /usr/libexec/openshift/cartridges/jbossews

      # Clear broker cache
      oo-admin-broker-cache -c

      # Clean up folder
      rm -rf origin-server-openshift-origin-release-4
      rm -rf apache-maven-${MAVEN_VER}
      rm -rf apache-tomcat-${TOMCAT7_VER}
      rm -rf apache-tomcat-${TOMCAT6_VER}

      Delete
  4. Hello chatainay.gk,

    Sorry for the late replay to your question, strange thing it did not show up at here, following is your question:

    chatainay.gk has left a new comment on your post "OpenShift Origin 3.0 with JBossews CentOS Installa...":

    Thanks Dani, I already deployed on VM using http://www.openshift.org/documentation/oo_deployment_guide_vm.html and it is working fine. But I wanted to deploy the Origin from scratch on two fresh minimal VM's from scratch.

    Also could you please help me with another issue, which is related to DNS. After deploying Openshift on VM, it opens fine at https://broker.openshift.local/console/. Is there anyway I could configure the DNS so that It resolves from my network machines too?

    The DNS configuration problem is that your local computer must add the machine as a secondary DNS

    For Windows, it is to manually configure the DNS server (please remember the old settings in case things go wrong), following article explains about it

    http://support.simpledns.com/kb/a72/configuring-windows-7-to-use-local-dns-server.aspx

    The DNS server is your OpenShift broker IP. Your machine must be expose as publicly within your local network

    For Linux, you may modify /etc/resolve.conf (for RHEL, CentOS, Fedora) and add the ip of your OpenShift Broker as the first entry.

    Thanks.

    Sincerely,
    Danil

    ReplyDelete