mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
initial dockerization commit. 1. update injectkeys.sh to work into restricted container 2. move previous dockerfiles into tools/docker 3. dockerfiles for management-server on centos and marvin
CLOUDSTACK-8249 Signed-off-by: Pierre-Luc Dion <pdion891@apache.org>
This commit is contained in:
parent
e640e0cf6e
commit
3381154faf
37
Dockerfile
37
Dockerfile
@ -1,37 +0,0 @@
|
||||
FROM ubuntu:14.04
|
||||
|
||||
RUN apt-get -y update && apt-get install -y \
|
||||
genisoimage \
|
||||
git \
|
||||
maven \
|
||||
openjdk-7-jdk \
|
||||
python-dev \
|
||||
python-setuptools \
|
||||
python-pip \
|
||||
supervisor
|
||||
|
||||
RUN echo 'mysql-server mysql-server/root_password password root' | debconf-set-selections; \
|
||||
echo 'mysql-server mysql-server/root_password_again password root' | debconf-set-selections;
|
||||
|
||||
RUN apt-get install -qqy mysql-server && \
|
||||
apt-get clean all
|
||||
|
||||
RUN (/usr/bin/mysqld_safe &); sleep 5; mysqladmin -u root -proot password ''
|
||||
|
||||
RUN pip install --allow-external mysql-connector-python mysql-connector-python
|
||||
|
||||
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
COPY . ./root
|
||||
WORKDIR /root
|
||||
|
||||
RUN mvn -Pdeveloper -Dsimulator -DskipTests clean install
|
||||
|
||||
RUN (/usr/bin/mysqld_safe &); \
|
||||
sleep 3; \
|
||||
mvn -Pdeveloper -pl developer -Ddeploydb; \
|
||||
mvn -Pdeveloper -pl developer -Ddeploydb-simulator; \
|
||||
pip install tools/marvin/dist/Marvin-4.6.0-SNAPSHOT.tar.gz
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["/usr/bin/supervisord"]
|
||||
@ -85,10 +85,14 @@ systemvmpath=$3
|
||||
|
||||
command -v mkisofs > /dev/null || (echo "$(basename $0): mkisofs not found, please install or ensure PATH is accurate" ; exit 4)
|
||||
|
||||
inject_into_iso systemvm.iso $newpubkey
|
||||
|
||||
[ $? -ne 0 ] && exit 5
|
||||
|
||||
copy_priv_key $newprivkey
|
||||
# if running into Docker as unprivileges, skip ssh verification as iso cannot be mounted.
|
||||
if [ -e /dev/loop0 ]; then
|
||||
inject_into_iso systemvm.iso $newpubkey
|
||||
[ $? -ne 0 ] && exit 5
|
||||
copy_priv_key $newprivkey
|
||||
else
|
||||
# this mean it's a docker instance, ssh key cannot be verify.
|
||||
echo "No loop device found, skipping ssh key insertion in systemvm.iso"
|
||||
fi
|
||||
|
||||
exit $?
|
||||
|
||||
59
tools/docker/Dockerfile
Normal file
59
tools/docker/Dockerfile
Normal file
@ -0,0 +1,59 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# CloudStack-simulator build
|
||||
|
||||
FROM ubuntu:14.04
|
||||
|
||||
MAINTAINER "Apache CloudStack" <dev@cloudstack.apache.org>
|
||||
LABEL Vendor="Apache.org" License="ApacheV2" Version="4.6.0"
|
||||
|
||||
RUN apt-get -y update && apt-get install -y \
|
||||
genisoimage \
|
||||
git \
|
||||
maven \
|
||||
openjdk-7-jdk \
|
||||
python-dev \
|
||||
python-setuptools \
|
||||
python-pip \
|
||||
supervisor
|
||||
|
||||
RUN echo 'mysql-server mysql-server/root_password password root' | debconf-set-selections; \
|
||||
echo 'mysql-server mysql-server/root_password_again password root' | debconf-set-selections;
|
||||
|
||||
RUN apt-get install -qqy mysql-server && \
|
||||
apt-get clean all
|
||||
|
||||
RUN (/usr/bin/mysqld_safe &); sleep 5; mysqladmin -u root -proot password ''
|
||||
|
||||
RUN pip install --allow-external mysql-connector-python mysql-connector-python
|
||||
|
||||
COPY tools/docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
COPY . ./root
|
||||
WORKDIR /root
|
||||
|
||||
RUN mvn -Pdeveloper -Dsimulator -DskipTests clean install
|
||||
|
||||
RUN (/usr/bin/mysqld_safe &); \
|
||||
sleep 3; \
|
||||
mvn -Pdeveloper -pl developer -Ddeploydb; \
|
||||
mvn -Pdeveloper -pl developer -Ddeploydb-simulator; \
|
||||
pip install tools/marvin/dist/Marvin-4.6.0-SNAPSHOT.tar.gz
|
||||
|
||||
EXPOSE 8080 8096
|
||||
|
||||
CMD ["/usr/bin/supervisord"]
|
||||
50
tools/docker/Dockerfile.centos6
Normal file
50
tools/docker/Dockerfile.centos6
Normal file
@ -0,0 +1,50 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
FROM centos:6
|
||||
|
||||
MAINTAINER "Apache CloudStack" <dev@cloudstack.apache.org>
|
||||
LABEL Vendor="Apache.org" License="ApacheV2" Version="4.6.0"
|
||||
|
||||
ENV PKG_URL=http://jenkins.buildacloud.org/job/package-rhel63-master/lastSuccessfulBuild/artifact/dist/rpmbuild/RPMS/x86_64
|
||||
|
||||
# install CloudStack
|
||||
RUN yum install -y \
|
||||
${PKG_URL}/cloudstack-common-4.6.0-SNAPSHOT.el6.x86_64.rpm \
|
||||
${PKG_URL}/cloudstack-management-4.6.0-SNAPSHOT.el6.x86_64.rpm
|
||||
|
||||
RUN cd /etc/cloudstack/management; \
|
||||
ln -s tomcat6-nonssl.conf tomcat6.conf; \
|
||||
ln -s server-nonssl.xml server.xml; \
|
||||
ln -s log4j-cloud.xml log4j.xml
|
||||
COPY init.sh_centos6 /root/init.sh
|
||||
|
||||
RUN yum clean all
|
||||
|
||||
RUN sed -i "s/cluster.node.IP=.*/cluster.node.IP=localhost/" /etc/cloudstack/management/db.properties
|
||||
|
||||
EXPOSE 8080 8250 8096 45219 9090 8787
|
||||
# Ports:
|
||||
# 8080: webui, api
|
||||
# 8250: systemvm communication
|
||||
# 8096: api port without authentication(default=off)
|
||||
# Troubleshooting ports:
|
||||
# 8787: CloudStack (Tomcat) debug socket
|
||||
# 9090: Cloudstack Management Cluster Interface
|
||||
# 45219: JMX console
|
||||
|
||||
CMD ["/root/init.sh"]
|
||||
40
tools/docker/Dockerfile.marvin
Normal file
40
tools/docker/Dockerfile.marvin
Normal file
@ -0,0 +1,40 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
#
|
||||
# build for cloudstack_home_dir not this folder
|
||||
FROM python:2
|
||||
|
||||
MAINTAINER "Apache CloudStack" <dev@cloudstack.apache.org>
|
||||
LABEL Vendor="Apache.org" License="ApacheV2" Version="4.6.0"
|
||||
|
||||
ENV WORK_DIR=/marvin
|
||||
|
||||
ENV PKG_URL=http://jenkins.buildacloud.org/job/cloudstack-marvin-master/lastSuccessfulBuild/artifact/tools/marvin/dist/Marvin-4.6.0-SNAPSHOT.tar.gz
|
||||
|
||||
RUN pip install --upgrade paramiko nose requests
|
||||
RUN pip install --allow-external mysql-connector-python mysql-connector-python
|
||||
RUN pip install ${PKG_URL}
|
||||
|
||||
RUN mkdir -p ${WORK_DIR}
|
||||
COPY setup/dev ${WORK_DIR}/dev
|
||||
COPY tools/marvin/marvin ${WORK_DIR}/marvin
|
||||
COPY test/integration ${WORK_DIR}/integration
|
||||
|
||||
WORKDIR ${WORK_DIR}
|
||||
|
||||
CMD /bin/bash
|
||||
100
tools/docker/README.md
Normal file
100
tools/docker/README.md
Normal file
@ -0,0 +1,100 @@
|
||||
# Docker Files for Apache CloudStack
|
||||
|
||||
Dockerfiles used to build CloudStack images available on Docker hub.
|
||||
|
||||
|
||||
## Using images from docker-hub
|
||||
|
||||
|
||||
### CloudStack Simulator
|
||||
|
||||
CloudStack Simulator if a all on one CloudStack Build including the simulator that mimic Hypervisor. This is usefull to test CloudStack API behavior without having to deploy real hypervisor nodes. CloudStack Simulator is used for tests and CI.
|
||||
|
||||
```
|
||||
docker pull cloudstack/simulator
|
||||
docker run --name simulator -p 8080:8080 -d cloudstack/simulator
|
||||
```
|
||||
|
||||
### CloudStack Management-server
|
||||
|
||||
```
|
||||
docker pull mysql:5.5
|
||||
docker pull cloudstack/management_centos6
|
||||
docker run --name cloudstack-mysql -e MYSQL_ROOT_PASSWORD=password -d mysql:5.5
|
||||
docker run -ti --name cloudstack --link cloudstack-mysql:mysql -d -p 8080:8080 -p 8250:8250 cloudstack/management_centos6
|
||||
```
|
||||
|
||||
### Marvin
|
||||
|
||||
Use marvin to deploy or test your CloudStack environment.
|
||||
Use Marvin with cloudstack connection thru the API port (8096)
|
||||
|
||||
```
|
||||
docker pull cloudstack/marvin
|
||||
docker run -ti --rm --name marvin --link simulator:8096 cloudstack/marvin
|
||||
```
|
||||
|
||||
Deploy Cloud using marvin:
|
||||
|
||||
```
|
||||
docker run -ti --rm --link simulator:8096 cloudstack/marvin python /root/tools/marvin/marvin/deployDataCenter.py -i /root/setup/dev/advanced.cfg
|
||||
```
|
||||
|
||||
Perform Smoke tests against CloudStack Simulator containter:
|
||||
```
|
||||
docker run -ti --rm --link simulator:8096 \
|
||||
nosetests-2.7 -v --with-marvin \
|
||||
--marvin-config=dev/advanced.cfg \
|
||||
--with-xunit \
|
||||
--xunit-file=xunit.xml \
|
||||
-a tags=advanced,required_hardware=false \
|
||||
--zone=Sandbox-simulator \
|
||||
--hypervisor=simulator \
|
||||
-w integration/smoke
|
||||
```
|
||||
|
||||
# How to build images
|
||||
|
||||
Image provide by CloudStack are automatically build by Jenkins performing following tasks:
|
||||
|
||||
|
||||
### CentOS 6
|
||||
|
||||
CentOS 6 image use RPM's from jenkins.buildacloud.org
|
||||
tag:latest = master branch
|
||||
|
||||
1. build the base image
|
||||
|
||||
```
|
||||
docker build -f Dockerfile.centos6 -t cloudstack/management_centos6 .
|
||||
```
|
||||
|
||||
2. on jenkins, database and systemvm.iso are pre-deployed. the inital start require privileged container to
|
||||
mount systemvm.iso and copy ssh_rsa.pub into it.
|
||||
|
||||
```
|
||||
docker run --name cloudstack-mysql -e MYSQL_ROOT_PASSWORD=password -d mysql:5.5
|
||||
docker run --privileged --link cloudstack-mysql:mysql -d --name cloudstack cloudstack/management_centos6
|
||||
sleep 300
|
||||
docker exec cloudstack /etc/init.d/cloudstack-management stop
|
||||
docker stop cloudstack
|
||||
docker commit -m "init system.iso" -a "Apache CloudStack" cloudstack cloudstack/management_centos6
|
||||
```
|
||||
|
||||
### Marvin
|
||||
|
||||
Build Marvin container usable to deploy cloud in the CloudStack management server container.
|
||||
|
||||
1. to build the image
|
||||
|
||||
```
|
||||
docker build -f Dockerfile.marvin -t cloudstack/marvin ../..
|
||||
```
|
||||
|
||||
### Simulator
|
||||
|
||||
Build CloudStack with Simulator. this image is an all on one, including the database. Build from source using maven.
|
||||
|
||||
```
|
||||
docker build -f Dockerfile -t cloudstack/simulator ../..
|
||||
```
|
||||
50
tools/docker/init.sh_centos6
Executable file
50
tools/docker/init.sh_centos6
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# update database connection
|
||||
# start cloudstack-management server
|
||||
#/usr/bin/cloudstack-setup-databases cloud:password@$MYSQL_PORT_3306_TCP_ADDR
|
||||
|
||||
# initial startup of the container to generage ssh_key
|
||||
# performed as privileged
|
||||
if [ ! -d /var/cloudstack/management/.ssh ]; then
|
||||
mknod /dev/loop6 -m0660 b 7 6
|
||||
fi
|
||||
sleep 5
|
||||
|
||||
mysql -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" -h"$MYSQL_PORT_3306_TCP_ADDR" \
|
||||
-e "show databases;"|grep -q cloud
|
||||
|
||||
case $? in
|
||||
1)
|
||||
echo "deploying new cloud databases"
|
||||
cloudstack-setup-databases cloud:password@${MYSQL_PORT_3306_TCP_ADDR} \
|
||||
--deploy-as=root:${MYSQL_ENV_MYSQL_ROOT_PASSWORD} -i localhost
|
||||
;;
|
||||
0)
|
||||
echo "using existing databases"
|
||||
cloudstack-setup-databases cloud:password@${MYSQL_PORT_3306_TCP_ADDR}
|
||||
;;
|
||||
*)
|
||||
echo "cannot access database"
|
||||
exit 12
|
||||
;;
|
||||
esac
|
||||
|
||||
service cloudstack-management start
|
||||
tail -f /var/log/cloudstack/management/catalina.out
|
||||
@ -10,6 +10,6 @@ user=root
|
||||
[program:cloudstack]
|
||||
command=/bin/bash -c "mvn -pl client jetty:run -Dsimulator"
|
||||
directory=/root
|
||||
stderr_logfile=/var/log/acs.err.log
|
||||
stdout_logfile=/var/log/acs.out.log
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
user=root
|
||||
Loading…
x
Reference in New Issue
Block a user