Merge "OpenShift Enterprise diskimage-builder elements and heat template"

This commit is contained in:
Jenkins 2013-10-01 14:43:35 +00:00 committed by Gerrit Code Review
commit 50fb71f598
10 changed files with 638 additions and 0 deletions

View File

@ -0,0 +1,28 @@
#!/bin/bash
set -uex
cat > /etc/yum.repos.d/havana-epel.repo <<YUM
[havana-epel]
name=RHEL 6 Havana OpenStack
baseurl=http://repos.fedorapeople.org/repos/openstack/openstack-havana/epel-6/
enabled=1
gpgcheck=0
priority=2
sslverify=false
YUM
cat > /etc/yum.repos.d/cloudinit.repo <<YUM
[cloudinit]
name=Cloud Init Packages
baseurl=http://file.rdu.redhat.com/~calfonso/cloud-init/
failovermethod=priority
enabled=1
gpgcheck=0
YUM
install-packages cloud-init heat-cfntools
rm -f /etc/yum.repos.d/havana-epel.repo
rm -f /etc/yum.repos.d/cloudinit.repo

View File

@ -0,0 +1,409 @@
HeatTemplateFormatVersion: '2012-12-12'
Description: Template for setting up an OpenShift Origin environment
Parameters:
KeyName: {Description: Name of an existing EC2 KeyPair
to enable SSH access to the instances, Type: String, MinLength: '1',
MaxLength: '64', AllowedPattern: '[-_ a-zA-Z0-9]*'}
Prefix: {Description: Your DNS Prefix, Type: String,
Default: novalocal}
UpstreamDNS: {Description: Upstream DNS server,
Type: String, Default: 8.8.8.8}
ConfInstallMethod: {Description: Installation method (yum rhsm rhn), Type: String, MinLength: '1',
MaxLength: '255', Default: yum, Allowed_Values: [yum, rhsm, rhn]}
ConfSMRegName: {Description: Subscription Manager registration username, Type: String, MinLength: '1',
MaxLength: '255', Default: username}
ConfSMRegPass: {Description: Subscription Manager registration password, Type: String, MinLength: '1',
MaxLength: '255', Default: password}
ConfSMRegPool: {Description: Pool ID for OpenShift subscription, Type: String, MinLength: '1',
MaxLength: '255', Default: none}
ConfRHNRegName: {Description: RHN registration username, Type: String, MinLength: '1',
MaxLength: '255', Default: username}
ConfRHNRegPass: {Description: RHN registration password, Type: String, MinLength: '1',
MaxLength: '255', Default: password}
ConfRHNRegAK: {Description: RHN activation key for OpenShift subscription, Type: String, MinLength: '1',
MaxLength: '255', Default: activationkey}
ConfRHELRepoBase: {Description: RHEL Repo Base, Type: String, MinLength: '1',
MaxLength: '255', Default: example.com}
ConfRepoBase: {Description: OSE Repo Base, Type: String, MinLength: '1',
MaxLength: '255', Default: example.com}
ConfJBossRepoBase: {Description: JBoss Repo Base, Type: String, MinLength: '1',
MaxLength: '255', Default: example.com}
BrokerHostname: {Description: Broker hostname, Type: String, MinLenth: '1', Default: openshift.brokerinstance.novalocal}
NodeHostname: {Description: Broker hostname, Type: String, MinLenth: '1', Default: openshift.nodeinstance.novalocal}
Mappings:
JeosImages:
Broker: {Image: RHEL64-x86_64-broker}
Node: {Image: RHEL64-x86_64-node}
Resources:
OpenShiftOriginSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Standard firewall rules
SecurityGroupIngress:
- {IpProtocol: udp, FromPort: '53', ToPort: '53',
CidrIp: 0.0.0.0/0}
- {IpProtocol: tcp, FromPort: '53', ToPort: '53',
CidrIp: 0.0.0.0/0}
- {IpProtocol: tcp, FromPort: '22', ToPort: '22',
CidrIp: 0.0.0.0/0}
- {IpProtocol: tcp, FromPort: '80', ToPort: '80',
CidrIp: 0.0.0.0/0}
- {IpProtocol: tcp, FromPort: '443', ToPort: '443',
CidrIp: 0.0.0.0/0}
- {IpProtocol: tcp, FromPort: '8000', ToPort: '8000',
CidrIp: 0.0.0.0/0}
- {IpProtocol: tcp, FromPort: '23', ToPort: '65535',
CidrIp: 0.0.0.0/0}
- {IpProtocol: icmp, FromPort: '-1', ToPort: '-1',
CidrIp: 0.0.0.0/0}
brokerWaitHandle: {Type: 'AWS::CloudFormation::WaitConditionHandle'}
brokerWaitCondition:
Type: AWS::CloudFormation::WaitCondition
DependsOn: BrokerInstance
Properties:
Handle: {Ref: brokerWaitHandle}
Timeout: '6000'
BrokerIPAddress: {Type: 'AWS::EC2::EIP'}
BrokerIPAssoc:
Type: AWS::EC2::EIPAssociation
Properties:
InstanceId: {Ref: BrokerInstance}
EIP: {Ref: BrokerIPAddress}
BrokerInstance:
Type: AWS::EC2::Instance
Properties:
ImageId:
Fn::FindInMap: [JeosImages, Broker, Image]
InstanceType: m1.small
KeyName: {Ref: KeyName}
SecurityGroups:
- {Ref: OpenShiftOriginSecurityGroup}
Tags:
- Key: Name
Value:
Fn::Join:
- '-'
- - openshift
- {Ref: Prefix}
- broker
UserData:
Fn::Base64:
Fn::Join:
- ''
- - '#!/bin/bash -x'
- '
'
- export CONF_BROKER_IP_ADDR=
- {Ref: BrokerIPAddress}
- '
'
- export CONF_NODE_IP_ADDR=
- {Ref: NodeIPAddress}
- '
'
- export CONF_NAMED_IP_ADDR=
- {Ref: BrokerIPAddress}
- '
'
- export CONF_DOMAIN=
- {Ref: Prefix}
- '
'
- export CONF_BROKER_HOSTNAME=
- {Ref: BrokerHostname}
- '
'
- export CONF_NODE_HOSTNAME=
- {Ref: NodeHostname}
- '
'
- export CONF_NAMED_HOSTNAME=
- {Ref: BrokerHostname}
- '
'
- export CONF_ACTIVEMQ_HOSTNAME=
- {Ref: BrokerHostname}
- '
'
- export CONF_DATASTORE_HOSTNAME=
- {Ref: BrokerHostname}
- '
'
- export PREFIX=
- {Ref: Prefix}
- '
'
- export DNS_SEC_KEY=`cat /var/named/K${PREFIX}.*.key | awk '{print $8}'`
- '
'
- export BROKER_WAIT_HANDLE="
- {Ref: brokerWaitHandle}
- '"'
- '
'
- export CONF_INSTALL_METHOD=
- {Ref: ConfInstallMethod}
- '
'
- export CONF_SM_REG_NAME=
- {Ref: ConfSMRegName}
- '
'
- export CONF_SM_REG_PASS=
- {Ref: ConfSMRegPass}
- '
'
- export CONF_SM_REG_POOL=
- {Ref: ConfSMRegPool}
- '
'
- export CONF_RHN_REG_NAME=
- {Ref: ConfRHNRegName}
- '
'
- export CONF_RHN_REG_PASS=
- {Ref: ConfRHNRegPass}
- '
'
- export CONF_RHN_REG_ACTKEY=
- {Ref: ConfRHNRegAK}
- '
'
- export CONF_REPOS_BASE=
- {Ref: ConfRepoBase}
- '
'
- export CONF_JBOSS_REPO_BASE=
- {Ref: ConfJBossRepoBase}
- '
'
- export CONF_RHEL_REPO=
- {Ref: ConfRHELRepoBase}
- '
'
- export CONF_INSTALL_COMPONENTS=broker,named,datastore,activemq
- '
'
- yum clean all
- '
'
- wget https://raw.github.com/openshift/openshift-extras/enterprise-1.2.z/enterprise/install-scripts/generic/openshift.sh
- '
'
- chmod +x openshift.sh
- '
'
- ./openshift.sh 2>&1 | tee /tmp/openshift.out
- '
'
- echo "${CONF_NODE_HOSTNAME%.${PREFIX}} A ${CONF_NODE_IP_ADDR}" >> /var/named/dynamic/${PREFIX}.db
- '
'
- '# All is well so signal success
'
- '/usr/bin/cfn-signal -e 0 --data "${DNS_SEC_KEY}" -r "Broker setup
complete" "${BROKER_WAIT_HANDLE}"
'
- reboot
- '
'
NodeIPAddress: {Type: 'AWS::EC2::EIP'}
NodeIPAssoc:
Type: AWS::EC2::EIPAssociation
Properties:
InstanceId: {Ref: NodeInstance}
EIP: {Ref: NodeIPAddress}
NodeInstance:
Type: AWS::EC2::Instance
DependsOn: brokerWaitCondition
Properties:
ImageId:
Fn::FindInMap: [JeosImages, Node, Image]
InstanceType: m1.small
KeyName: {Ref: KeyName}
SecurityGroups:
- {Ref: OpenShiftOriginSecurityGroup}
Tags:
- Key: Name
Value:
Fn::Join:
- '-'
- - openshift
- {Ref: Prefix}
- node
UserData:
Fn::Base64:
Fn::Join:
- ''
- - '#!/bin/bash -x'
- '
'
- export CONF_BROKER_IP_ADDR=
- {Ref: BrokerIPAddress}
- '
'
- export CONF_NODE_IP_ADDR=
- {Ref: NodeIPAddress}
- '
'
- export CONF_NAMED_IP_ADDR=
- {Ref: BrokerIPAddress}
- '
'
- export CONF_DOMAIN=novalocal
- '
'
- export CONF_BROKER_HOSTNAME=
- {Ref: BrokerHostname}
- '
'
- export CONF_NODE_HOSTNAME=
- {Ref: NodeHostname}
- '
'
- export CONF_NAMED_HOSTNAME=
- {Ref: BrokerHostname}
- '
'
- export CONF_ACTIVEMQ_HOSTNAME=
- {Ref: BrokerHostname}
- '
'
- export CONF_DATASTORE_HOSTNAME=
- {Ref: BrokerHostname}
- '
'
- export CONF_INSTALL_METHOD=
- {Ref: ConfInstallMethod}
- '
'
- export CONF_SM_REG_NAME=
- {Ref: ConfSMRegName}
- '
'
- export CONF_SM_REG_PASS=
- {Ref: ConfSMRegPass}
- '
'
- export CONF_SM_REG_POOL=
- {Ref: ConfSMRegPool}
- '
'
- export CONF_RHN_REG_NAME=
- {Ref: ConfRHNRegName}
- '
'
- export CONF_RHN_REG_PASS=
- {Ref: ConfRHNRegPass}
- '
'
- export CONF_RHN_REG_ACTKEY=
- {Ref: ConfRHNRegAK}
- '
'
- export CONF_REPOS_BASE=
- {Ref: ConfRepoBase}
- '
'
- export CONF_JBOSS_REPO_BASE=
- {Ref: ConfJBossRepoBase}
- '
'
- export CONF_RHEL_REPO=
- {Ref: ConfRHELRepoBase}
- '
'
- export CONF_INSTALL_COMPONENTS=node
- '
'
- yum clean all
- '
'
- wget https://raw.github.com/openshift/openshift-extras/enterprise-1.2.z/enterprise/install-scripts/generic/openshift.sh
- '
'
- chmod +x openshift.sh
- '
'
- ./openshift.sh 2>&1 | tee /tmp/openshift.out
- '
'
- reboot
- '
'
Outputs:
OpenShiftConsole:
Value:
Fn::Join:
- ''
- - https://
- Fn::GetAtt: [BrokerInstance, PublicIp]
- /console
Description: URL for OpenShift Origins console
NameServerEntry:
Value:
Fn::Join:
- ''
- - 'nameserver '
- Fn::GetAtt: [BrokerInstance, PublicIp]
Description: Entry to insert into /etc/resolv.conf for application
host names to resolve

View File

@ -0,0 +1,60 @@
==========================
OpenShift Enterprise templates
==========================
This directory contains files for deploying OpenShift Enterprise to an OpenStack environment via heat.
It includes the following files:
* `OpenShift.yaml` - heat template for launching OpenShift Enterprise with a single broker server and a single node server
* `openshift-enterprise` - diskimage-builder elements to build images
To build with diskimage-builder, do the following in the parent directory of heat-templates::
git clone https://github.com/openstack/diskimage-builder.git
mkdir $HOME/tmp
export ELEMENTS_PATH=heat-templates/elements:heat-templates/openshift-enterprise/elements
export DIB_CLOUD_IMAGES=url rhel-server-x86_64-kvm-6.4_20130130.0-4.qcow2 image can be found (download this from rhn)
# Either set the following variables if you have the packages in a yum repo or specify an OpenShift Enterprise subscription pool id.
export DIB_CONF_JBOSS_REPO_BASE=<location of JBoss repo>
export DIB_CONF_REPO_BASE=<location of OpenShift Enteprise repo>
export DIB_RHSM_OSE_POOL=<OpenShift Enterprise subscription pool id>
export DIB_RHSM_USER=your_rhel_subscription_username
export DIB_RHSM_PASSWORD=your_rhel_subscription_password
TMP_DIR=$HOME/tmp DIB_IMAGE_SIZE=5 diskimage-builder/bin/disk-image-create --no-tmpfs -a amd64 vm rhel openshift-enterprise-broker -o RHEL64-x86_64-broker
TMP_DIR=$HOME/tmp DIB_IMAGE_SIZE=20 diskimage-builder/bin/disk-image-create --no-tmpfs -a amd64 vm rhel openshift-enterprise-node -o RHEL64-x86_64-node
Register the RHEL64-x86_64-broker and RHEL64-x86_64-node with OpenStack Glance::
glance add name=RHEL64-x86_64-broker is_public=true disk_format=qcow2 container_format=bare < RHEL64-x86_64-broker.qcow2
glance add name=RHEL64-x86_64-node is_public=true disk_format=qcow2 container_format=bare < RHEL64-x86_64-node.qcow2
Invoke Heat
-----------
Once you have the required disk images registered with glance, you can use OpenStack Heat to provision instances of your images and configure them to work together as an OpenShift infrastructure::
heat create openshift --template-file=./heat-templates/openshift-enterprise/OpenShift.yaml --parameters="InstanceType=m1.xlarge;KeyName=${USER}_key;Prefix=novalocal;BrokerHostname=openshift.brokerinstance.novalocal;NodeHostname=openshift.nodeinstance.novalocal;ConfRHELRepoBase=example.com/rhel/server/6/6Server/x86_64/os;ConfJBossRepoBase=http://example.com/rhel/server/6/6Server/x86_64;ConfRepoBase=http://example.com/OpenShiftEnterprise/1.2/latest"
Using Custom Yum repos (default)
-------------------------------
By default, the Heat Orchestration Template assumes you're using the Yum installation method, which means it also expects you to pass parameters to heat for yum repositories. As an example, you can add the following to your list of parameters::
ConfRHELRepoBase=http://example.com/rhel/server/6/6Server/x86_64/os;ConfJBossRepoBase=http://example.com/rhel/server/6/6Server/x86_64;ConfRepoBase=http://example.com/OpenShiftEnterprise/1.2/latest
Using Subscription Manager
--------------------------
You can switch from the default installation method by passing in the parameter ConfInstallMethod. The allowed values, other than yum are rhsm and rhn. If you set the installation method to rhsm, you'll want to also pass in the following parameters ConfSMRegName and ConfSMRegPass for the username and password respectively. Additionally, you'll need to set the ConfSMRegPool parameter with the value of the subscription pool id that corresponds to your OpenShift Enterprise subscription. When setting the ConfInstallMethod to something other than yum it is not necessary to pass the Conf*RepoBase parameters::
ConfInstallMethod=rhsm;ConfSMRegName=myuser;ConfSMRegPass=mypass;ConfSMRegPool=XYZ01234567
Using RHN
---------
You can switch from the default installation method by passing in the parameter ConfInstallMethod. The allowed values, other than yum are rhsm and rhn. If you set the installation method to rhn, you'll want to also pass in the following parameters ConfRHNRegName and ConfRHNRegPass for the username and password respectively. Additionally, you'll need to set the ConfRHNRegAK parameter with the value of the subscription activation key that corresponds to your OpenShift Enterprise subscription. When setting the ConfInstallMethod to something other than yum it is not necessary to pass the Conf*RepoBase parameters::
ConfInstallMethod=rhn;ConfRHNRegName=myuser;ConfRHNRegPass=mypass;ConfRHNRegAK=7202f3b7d218cf59b764f9f6e9fa281b

View File

@ -0,0 +1,3 @@
This element installs packages required by a typical OpenShift Enterprise broker.
The objective of including these packages on the instance is to speed the boot time of a broker.

View File

@ -0,0 +1,2 @@
epel-heat-cfntools
openshift-enterprise-repos

View File

@ -0,0 +1,44 @@
#!/bin/bash
set -e
if [ -z "${DIB_RHSM_OSE_POOL:-}" ]; then
cat > /etc/yum.repos.d/openshift-client.repo <<YUM
[openshift_client]
name=OpenShift Client
baseurl=${DIB_CONF_REPO_BASE}/Client/x86_64/os/
enabled=1
gpgcheck=0
priority=1
sslverify=false
YUM
cat > /etc/yum.repos.d/openshift-infrastructure.repo <<YUM
[openshift_infrastructure]
name=OpenShift Infrastructure
baseurl=${DIB_CONF_REPO_BASE}/Infrastructure/x86_64/os/
enabled=1
gpgcheck=0
priority=1
sslverify=false
YUM
fi
install-packages \
yum-plugin-priorities \
openshift-origin-broker \
openshift-origin-broker-util \
rubygem-openshift-origin-msg-broker-mcollective \
rubygem-openshift-origin-auth-remote-user \
rubygem-openshift-origin-dns-nsupdate \
openshift-origin-console \
rhc \
mcollective-client \
activemq \
mongodb-server \
bind \
bind-utils \
mod_auth_kerb \
--skip-broken

View File

@ -0,0 +1,3 @@
This element installs packages required by a typical OpenShift Enterprise node.
The objective of including these packages on the instance is to speed the boot time of a node.

View File

@ -0,0 +1,2 @@
epel-heat-cfntools
openshift-enterprise-repos

View File

@ -0,0 +1,74 @@
#!/bin/bash
set -e
if [ -z ${DIB_RHSM_OSE_POOL:-} ]; then
cat > /etc/yum.repos.d/openshift-node.repo <<YUM
[openshift_node]
name=OpenShift Node
baseurl=${DIB_CONF_REPO_BASE}/Node/x86_64/os/
enabled=1
gpgcheck=0
priority=1
sslverify=false
YUM
cat > /etc/yum.repos.d/openshift-jboss.repo <<YUM
[openshift_jbosseap]
name=OpenShift JBossEAP
baseurl=${DIB_CONF_REPO_BASE}/JBoss_EAP6_Cartridge/x86_64/os/
enabled=1
gpgcheck=0
priority=1
sslverify=false
YUM
cat <<YUM > /etc/yum.repos.d/jbosseap.repo
[jbosseap]
name=jbosseap
baseurl=${DIB_CONF_JBOSS_REPO_BASE}/jbeap/6/os
enabled=1
priority=3
gpgcheck=0
YUM
cat <<YUM > /etc/yum.repos.d/jbossews.repo
[jbossews]
name=jbossews
baseurl=${DIB_CONF_JBOSS_REPO_BASE}/jbews/2/os
enabled=1
priority=3
gpgcheck=0
YUM
fi
install-packages \
yum-plugin-priorities \
rubygem-openshift-origin-node \
ruby193-rubygem-passenger-native \
openshift-origin-port-proxy \
openshift-origin-node-util \
policycoreutils-python \
openshift-origin-cartridge-cron \
openshift-origin-cartridge-diy \
openshift-origin-cartridge-haproxy \
openshift-origin-cartridge-jbossews \
openshift-origin-cartridge-jbosseap \
openshift-origin-cartridge-jenkins \
openshift-origin-cartridge-jenkins-client \
openshift-origin-cartridge-mysql \
openshift-origin-cartridge-perl \
openshift-origin-cartridge-php \
openshift-origin-cartridge-postgresql \
openshift-origin-cartridge-python \
openshift-origin-cartridge-ruby \
mcollective \
openshift-origin-msg-node-mcollective \
--skip-broken
# make sure not services were started that might hold on to mounts
service crond stop

View File

@ -0,0 +1,13 @@
#!/bin/bash
set -e
if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ]
then
# assume since the DIB_RHSM_USER and DIB_RHSM_PASSWORD are defined the system has already been registered
if [ -z "${DIB_RHSM_OSE_POOL:-}" ]; then
echo "DIB_RHSM_OSE_POOL environment variable is not set, OpenShift Enterprise subscription will not be applied"
else
subscription-manager attach --pool $DIB_RHSM_OSE_POOL
fi
fi