Last active
August 29, 2015 14:06
-
-
Save scollier/8d56f8f82e4e18aebbb9 to your computer and use it in GitHub Desktop.
multi-container kube config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
multi-container.json file: | |
apiVersion: v1beta1 | |
id: multicontainer | |
desiredState: | |
manifest: | |
version: v1beta1 | |
id: multicontainer | |
containers: | |
- name: mongodb | |
image: localhost:5000/mongodb | |
ports: [{ | |
containerPort: 27017, | |
hostPort: 27017 | |
}] | |
containers: | |
- name: rockmongo | |
image: localhost:5000/rockmongo | |
ports: [{ | |
containerPort: 80, | |
hostPort: 6060 | |
}] | |
Mongo Docker Config: | |
# cat Dockerfile | |
FROM rhel7 | |
MAINTAINER scollier <scollier@redhat.com> | |
# Add repo files | |
ADD ./mongo.repo /etc/yum.repos.d/ | |
# Install MongoDB packages and extras | |
RUN yum --assumeyes update && \ | |
yum --assumeyes install \ | |
mongo-10gen-server \ | |
mongo-10gen \ | |
procps-ng \ | |
iptables && \ | |
yum clean all && \ | |
mkdir -p /var/lib/mongodb && \ | |
touch /var/lib/mongodb/.keep && \ | |
chown -R mongod:mongod /var/lib/mongodb | |
VOLUME ["/var/lib/mongodb"] | |
USER mongod | |
ADD mongodb.conf /etc/mongodb.conf | |
EXPOSE 27017 | |
CMD ["/usr/bin/mongod", "--noauth", "--config", "/etc/mongodb.conf"] | |
# cat mongodb.conf | |
## | |
### Basic Defaults | |
## | |
dbpath = /var/lib/mongo | |
smallfiles = true | |
nohttpinterface = true | |
noprealloc = true | |
# cat mongo.repo | |
[mongodb] | |
name=MongoDB Repository | |
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/ | |
gpgcheck=0 | |
enabled=1 | |
RockMongo Config: | |
# cat Dockerfile | |
FROM rhel7 | |
MAINTAINER Derek Carr <decarr@redhat.com> | |
# update, install required, clean | |
RUN yum -y update && \ | |
yum install -y httpd php php-devel wget php-pear unzip gcc-c++ \ | |
make findutils file && yum clean all | |
# update pecl channels | |
RUN pecl update-channels | |
# install mongo drivers without Cyrus SASL (MongoDB Enterprise Authentication) | |
RUN printf "no\n" | pecl install mongo && cd /etc && echo "extension=mongo.so" >> /etc/php.d/mongo.ini | |
# install RockMongo | |
RUN cd /root && wget -O rockmongo-1.1.5.zip http://rockmongo.com/downloads/go?id=12 && \ | |
unzip rockmongo-1.1.5.zip -d /var/www/ && rm -R /var/www/html && \ | |
mv /var/www/rockmongo/ /var/www/html && \ | |
sed -i 's/auth"] = true/auth"] = false/' /var/www/html/config.php | |
# increase php upload size | |
RUN sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 10M/g' /etc/php.ini && \ | |
sed -i 's/post_max_size = 2M/post_max_size = 10M/g' /etc/php.ini | |
# expose php information | |
RUN echo '<?php phpInfo(); ?>' > /var/www/html/info.php | |
# Add the php mongo driver | |
ADD ./epel.repo /etc/yum.repos.d/epel.repo | |
RUN yum -y install php-pecl-mongo --nogpgcheck && yum clean all | |
# Add the start.sh and mark it executable | |
ADD ./start.sh /start.sh | |
RUN chmod +x /start.sh | |
# Expose ports | |
EXPOSE 80 | |
# CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"] | |
CMD ["/start.sh"] | |
# cat epel.repo | |
[epel] | |
name=Extra Packages for Enterprise Linux 7 - $basearch | |
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch | |
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch | |
failovermethod=priority | |
enabled=1 | |
gpgcheck=1 | |
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 | |
[epel-debuginfo] | |
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug | |
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug | |
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch | |
failovermethod=priority | |
enabled=0 | |
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 | |
gpgcheck=1 | |
[epel-source] | |
name=Extra Packages for Enterprise Linux 7 - $basearch - Source | |
#baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS | |
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch | |
failovermethod=priority | |
enabled=0 | |
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 | |
gpgcheck=1 | |
# cat start.sh | |
#!/bin/bash | |
# Tell the rockmongo service how to get to the MongoDB container | |
# the SERVICE_HOST var is provided by kubernetes | |
sed -i "s/mongo_host\"] = \"127.0.0.1\"/mongo_host\"] = \"$SERVICE_HOST\"/" /var/www/html/config.php | |
# Start the Apache server | |
/usr/sbin/httpd -D FOREGROUND | |
Steps: | |
1. build images | |
2. yum install registry | |
3. retag images | |
docker tag mongodb localhost:5000/mongodb | |
docker tag rockmongo localhost:5000/rockmongo | |
4. push images | |
docker push localhost:5000/mongodb | |
docker push localhost:5000/rockmongo | |
5. launch pod | |
kubecfg -c multi-container.json create pods | |
6. test access. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment