Skip to content

Commit 4ca7fb6

Browse files
author
Tim Pouyer
committed
Lots of fixes:
-- hostname and domain now setup correctly -- switched out mysql database for postgre in openstack (faster performance less memory overhead) -- add swapfile to box, allows for continued operation (albiet at a cost to performance) at much lower memory levels, can support min memory of 4096 -- add Docker Heat plugin to the heat engine on openstack -- added Docker Engine to box -- added local passthrough mirror docker registry to box -- added web front-end for mirror registry (available at http://192.168.27.100:4080/home) -- added ibm jre 1.7 in /opt/java and set up system wide JAVA_HOME variable
1 parent 92e91ae commit 4ca7fb6

File tree

9 files changed

+151
-66
lines changed

9 files changed

+151
-66
lines changed

scripts/docker/config.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: 0.1
2+
log:
3+
fields:
4+
service: registry
5+
storage:
6+
cache:
7+
blobdescriptor: inmemory
8+
filesystem:
9+
rootdirectory: /var/lib/registry
10+
delete:
11+
enabled: true
12+
http:
13+
addr: :5000
14+
headers:
15+
X-Content-Type-Options: [nosniff]
16+
proxy:
17+
remoteurl: https://registry-1.docker.io
18+
health:
19+
storagedriver:
20+
enabled: true
21+
interval: 60s
22+
threshold: 5

scripts/docker/heat.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
cd /tmp
4+
git clone -b stable/liberty https://github.com/openstack/heat.git
5+
cd heat/contrib/heat_docker/
6+
sudo pip install -r requirements.txt
7+
sudo mkdir -p /var/lib/heat
8+
sudo cp -r heat_docker/ /var/lib/heat
9+
sudo chown -R vagrant:vagrant /var/lib/heat
10+
sudo sed -i 's|rpc_backend = rabbit|rpc_backend = rabbit \
11+
plugin_dirs = /var/lib/heat|g' /etc/heat/heat.conf
12+
sudo chown -R vagrant:vagrant /var/lib/heat
13+
14+
/vagrant/scripts/minimize/clean.sh
15+

scripts/docker/init.sh

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
#!/bin/bash
22

3-
sudo apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
4-
sudo bash -c "echo 'deb https://apt.dockerproject.org/repo ubuntu-trusty main' > /etc/apt/sources.list.d/docker.list"
3+
curl -s 'https://sks-keyservers.net/pks/lookup?op=get&search=0xee6d536cf7dc86e2d7d56f59a178ac6c6238f52e' | sudo apt-key add --import
4+
sudo apt-get update && sudo apt-get install -qqy apt-transport-https
5+
sudo apt-get install -qqy linux-image-extra-virtual
6+
echo "deb https://packages.docker.com/1.11/apt/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
7+
sudo apt-get update && sudo apt-get install -qqy docker-engine
8+
sudo usermod -a -G docker vagrant
59

6-
sudo apt-get -qqy update
7-
sudo apt-get install -qqy docker-engine
10+
sudo mkdir -p /var/lib/registry
11+
sudo mkdir -p /etc/docker/registry
12+
sudo cp /vagrant/scripts/docker/config.yml /etc/docker/registry/config.yml
813

9-
sudo usermod -aG docker vagrant
10-
newgrp docker
14+
sudo chown -R :docker /var/lib/registry/
15+
sudo chown -R :docker /etc/docker/registry/
16+
17+
# sudo apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
18+
# sudo bash -c "echo 'deb https://apt.dockerproject.org/repo ubuntu-trusty main' > /etc/apt/sources.list.d/docker.list"
19+
20+
# sudo apt-get -qqy update
21+
# sudo apt-get install -qqy docker-engine
22+
23+
# sudo usermod -aG docker vagrant
24+
# newgrp docker

scripts/docker/mirror.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
cat >> /etc/default/docker <<EOF
4+
DOCKER_OPTS="-H tcp://192.168.27.100:2375 -H unix:///var/run/docker.sock -D --dns 8.8.8.8 --dns 8.8.4.4 --userland-proxy=false --registry-mirror=http://192.168.27.100:4000 --insecure-registry=192.168.27.100:4000 --disable-legacy-registry"
5+
EOF
6+
service docker restart

scripts/minimize/clean.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ sudo apt-get -qqy autoremove
5454
sudo apt-get -qqy autoclean
5555
sudo apt-get -qqy clean
5656

57+
sudo rm -rf /var/lib/apt/lists/*
58+
5759
# delete python library cache
5860
sudo rm -rf /var/cache/pip/*
5961

scripts/stackinabox/init.sh

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ sudo update-alternatives --install /bin/sh sh /bin/bash 100
4949

5050
# We need swap space to do any sort of scale testing with the Vagrant config.
5151
# Without this, we quickly run out of RAM and the kernel starts whacking things.
52-
sudo rm -f /swapfile1
53-
sudo dd if=/dev/zero of=/swapfile1 bs=1024 count=8388608
54-
sudo chown root:root /swapfile1
55-
sudo chmod 0600 /swapfile1
56-
sudo mkswap /swapfile1
57-
sudo swapon /swapfile1
52+
sudo rm -f /swapfile
53+
sudo fallocate -l 4G /swapfile
54+
sudo chmod 600 /swapfile
55+
sudo mkswap /swapfile
56+
sudo swapon /swapfile
57+
sudo echo "vm.swappiness = 10" | sudo tee --append /etc/sysctl.conf > /dev/null
58+
sudo echo "vm.vfs_cache_pressure = 50" | sudo tee --append /etc/sysctl.conf > /dev/null
59+
sudo echo "/swapfile none swap sw 0 0" | sudo tee --append /etc/fstab > /dev/null
5860

5961
# Disable firewall (this is not production)
6062
sudo ufw disable
@@ -73,14 +75,15 @@ sudo sysctl -p
7375
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
7476

7577
# Update host configuration
76-
sudo bash -c "echo 'openstack.stackinabox.io' > /etc/hostname"
78+
sudo bash -c "echo 'openstack' > /etc/hostname"
7779
#export eth1=`ifconfig eth1 | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'`
7880
sudo bash -c 'cat > /etc/hosts' <<EOF
79-
127.0.0.1 localhost.localdomain localhost openstack.stackinabox.io openstack
80-
192.168.27.100 openstack.stackinabox.io openstack
81-
81+
127.0.0.1 localhost
82+
192.168.27.100 openstack.stackinabox.io openstack
8283
EOF
8384

85+
sudo hostname openstack
86+
8487
# speed up DNS resolution
8588
sudo bash -c 'cat > /etc/dhcp/dhclient.conf' <<EOF
8689
timeout 30;
@@ -92,24 +95,21 @@ backoff-cutoff 2;
9295
link-timeout 10;
9396
interface "eth0"
9497
{
95-
supersede host-name "openstack.stackinabox.io";
96-
supersede domain-name "stackinabox.io";
98+
#supersede host-name "openstack";
99+
#supersede domain-name "stackinabox.io";
97100
prepend domain-name-servers 192.168.27.1, 8.8.8.8, 8.8.4.4;
98-
request subnet-mask,
99-
broadcast-address,
101+
request subnet-mask,
102+
broadcast-address,
103+
time-offset,
100104
routers,
101-
domain-name,
102-
domain-name-servers,
103-
host-name;
104-
require routers,
105-
subnet-mask,
106-
domain-name-servers;
105+
domain-name,
106+
domain-name-servers,
107+
host-name,
108+
netbios-name-servers,
109+
netbios-scope;
107110
}
108111
EOF
109112

110-
# Restart networking
111-
sudo /etc/init.d/networking restart
112-
113113
# enable cgroup memory limits
114114
sudo sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="/GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory swapaccount=1 /g' /etc/default/grub
115115
sudo sed -i 's/GRUB_CMDLINE_LINUX="/GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1 /g' /etc/default/grub
@@ -163,16 +163,8 @@ iface br-ex inet static
163163
EOF
164164

165165
# Install NTP
166-
sudo apt-get install -y ntp
167-
168-
# stop ntp service so we can set the pool to use
169-
sudo service ntp stop
170-
171-
# Set ntp.ubuntu.com as the direct source of time.
172-
sudo ntpdate us.pool.ntp.org
173-
174-
# restart the NTP service
175-
sudo service ntp restart
166+
# disabling b/c slow seed times at system startup are causing problems
167+
#sudo apt-get install -qqy ntp
176168

177169
# Configure MTU on VM interfaces. Also requires manually configuring the same MTU on
178170
# the equivalent 'vboxnet' interfaces on the host. i.e. sudo ip link set dev vboxnet0 mtu $MTU
@@ -230,27 +222,33 @@ sudo chmod +x /etc/init.d/devstack
230222
sudo update-rc.d devstack start 98 2 3 4 5 . stop 02 0 1 6 .
231223

232224
# install 'shellinabox' to make using this image on windows easier
233-
# shellinabox will be available at http://192.168.27.100:4200
234-
# sudo apt-get install -y shellinabox
235-
# sudo sed -i 's/--no-beep/--no-beep --disable-ssl/g' /etc/default/shellinabox
236-
# sudo /etc/init.d/shellinabox restart
237-
238-
# wait for openstack to startup
239-
sleep 60
240-
241-
# clean up after ourselves
242-
/vagrant/scripts/minimize/clean.sh
225+
#shellinabox will be available at http://192.168.27.100:4200
226+
sudo apt-get install -y shellinabox
227+
sudo sed -i 's/--no-beep/--no-beep --disable-ssl/g' /etc/default/shellinabox
228+
sudo /etc/init.d/shellinabox restart
243229

244230
# install java (for use with udclient)
245-
sudo apt-get update
246-
sudo apt-get install -qqy default-jre
231+
wget http://artifacts.stackinabox.io/ibm/java-jre/latest.txt
232+
ARTIFACT_VERSION=$(cat latest.txt)
233+
ARTIFACT_DOWNLOAD_URL=http://artifacts.stackinabox.io/ibm/java-jre/$ARTIFACT_VERSION/ibm-java-jre-$ARTIFACT_VERSION-linux-x86_64.tgz
234+
235+
sudo mkdir -p /opt/java
236+
sudo wget $ARTIFACT_DOWNLOAD_URL
237+
sudo tar -zxf ibm-java-jre-$ARTIFACT_VERSION-linux-x86_64.tgz -C /opt/java/
247238
sudo touch /etc/profile.d/java_home.sh
248239
sudo bash -c 'cat >> /etc/profile.d/java_home.sh' <<'EOF'
249-
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
240+
export JAVA_HOME=/opt/java/ibm-java-x86_64-71/jre
241+
export PATH=$JAVA_HOME/bin:$PATH
250242
EOF
251243
sudo chmod 755 /etc/profile.d/java_home.sh
252244

253245
sudo btrfs quota enable /var/lib/lxd
254246

247+
# wait for openstack to startup
248+
sleep 60
249+
250+
# clean up after ourselves
251+
/vagrant/scripts/minimize/clean.sh
252+
255253
# restart
256254
#sudo shutdown -P now

scripts/stackinabox/local.conf

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ GIT_BASE=https://github.com
4444
DEVSTACK_INSTALL_DIR=/opt/stack/devstack
4545

4646
# Database Type
47-
DATABASE_TYPE=mysql
48-
enable_service mysql
47+
#DATABASE_TYPE=mysql
48+
#enable_service mysql
49+
DATABASE_TYPE=postgres
50+
enable_service postgres
4951

5052
# RPC Backend
5153
enable_service rabbit
@@ -79,6 +81,7 @@ DATABASE_USER=root
7981
DATABASE_PASSWORD=labstack
8082
ADMIN_PASSWORD=labstack
8183
MYSQL_PASSWORD=labstack
84+
POSTGRES_PASSWORD=labstack
8285
RABBIT_PASSWORD=labstack
8386
SERVICE_PASSWORD=labstack
8487
SERVICE_TOKEN=labstack
@@ -89,6 +92,7 @@ SERVICE_TOKEN=labstack
8992
enable_service key
9093
KEYSTONE_TOKEN_FORMAT=UUID
9194
KEYSTONE_CATALOG_BACKEND=sql
95+
#ENABLE_IDENTITY_V2=False
9296

9397
#
9498
# Enable Nova
@@ -175,13 +179,12 @@ enable_service horizon
175179
#
176180
disable_service tempest
177181

178-
#enable_plugin designate https://github.com/openstack/designate
179-
#DESIGNATE_BRANCH=master
182+
#enable_plugin designate https://git.openstack.org/openstack/designate
180183

181-
enable_plugin kuryr http://git.openstack.org/openstack/kuryr
182-
enable_service kuryr
183-
enable_service etcd-server
184-
enable_service docker-engine
184+
#enable_plugin kuryr http://git.openstack.org/openstack/kuryr
185+
#enable_service kuryr
186+
#enable_service etcd-server
187+
#enable_service docker-engine
185188

186189
#
187190
# set current branch

scripts/stackinabox/stack-noscreenrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
#sudo PYTHONPATH=:/opt/stack/kuryr SERVICE_USER=admin SERVICE_PASSWORD=labstack SERVICE_TENANT_NAME=admin SERVICE_TOKEN=labstack IDENTIY_URL=http://127.0.0.1:5000/v2.0 python /opt/stack/kuryr/scripts/run_server.py --config-file /etc/kuryr/kuryr.conf >> /opt/stack/logs/kuryr.log 2>&1 &
88

9-
sudo ./scripts/run_kuryr.sh >> /opt/stack/logs/kuryr.log 2>&1 &
9+
#sudo ./scripts/run_kuryr.sh >> /opt/stack/logs/kuryr.log 2>&1 &
1010

11-
sudo service docker restart >> /opt/stack/logs/docker-restart.log 2>&1 &
11+
#sudo service docker restart >> /opt/stack/logs/docker-restart.log 2>&1 &
1212

1313
/usr/local/bin/glance-registry --config-file=/etc/glance/glance-registry.conf >> /opt/stack/logs/g-reg.log 2>&1 &
1414

vagrant/Vagrantfile

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
3737
end
3838

3939
if Vagrant.has_plugin?("vagrant-vbguest")
40-
config.vbguest.auto_update = false
40+
config.vbguest.auto_update = true
4141
end
4242

4343
#if !Vagrant.has_plugin?("vagrant-reload")
@@ -68,6 +68,33 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
6868
# eth2, this will be OpenStack's "public" network configured on vm by stackinabox.sh script and bridged to OpenvSwitch on VM
6969
stackinabox.vm.network "private_network", ip: "172.24.4.225", adapter_ip: "172.24.4.225", netmask: "255.255.255.0", auto_config: false
7070

71+
# install docker
72+
stackinabox.vm.provision "shell", name: "install-docker", path: File.expand_path(File.join(vagrant_dir, "..", "scripts", "docker", "init.sh"), __FILE__)
73+
74+
# run docker registry mirror
75+
stackinabox.vm.provision "setup_registry", type: "docker" do |d|
76+
77+
d.run "registry",
78+
image: "registry:2.4.1",
79+
daemonize: true,
80+
restart: "always",
81+
args: "-e SEARCH_BACKEND=sqlalchemy -p 4000:5000 -v /var/lib/registry:/var/lib/registry -v /etc/docker/registry/config.yml:/etc/docker/registry/config.yml"
82+
83+
end
84+
85+
# configure docker to use local registry mirror
86+
stackinabox.vm.provision "shell", name: "enable-docker-registry-cache", path: File.expand_path(File.join(vagrant_dir, "..", "scripts", "docker", "mirror.sh"), __FILE__)
87+
88+
stackinabox.vm.provision "setup_registry_ui", type: "docker" do |d|
89+
90+
d.run "registry-frontend",
91+
image: "konradkleine/docker-registry-frontend:v2",
92+
daemonize: true,
93+
restart: "always",
94+
args: "-p 4080:80 -e ENV_DOCKER_REGISTRY_HOST=192.168.27.100 -e ENV_DOCKER_REGISTRY_PORT=4000 -e ENV_MODE_BROWSE_ONLY=true -e ENV_DEFAULT_REPOSITORIES_PER_PAGE=50"
95+
96+
end
97+
7198
# Provider-specific configuration
7299
stackinabox.vm.provider "virtualbox" do |vb|
73100
# Don't boot with headless mode
@@ -120,8 +147,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
120147

121148
stackinabox.vm.provision "file", source: File.expand_path(File.join(vagrant_dir, "..", "scripts", "stackinabox", "openrc"), __FILE__), destination: "/home/vagrant/openrc"
122149

123-
# install docker
124-
#stackinabox.vm.provision "shell", name: "install_docker", privileged: false, keep_color: false, path: File.expand_path(File.join(vagrant_dir, "..", "scripts", "docker", "init.sh"), __FILE__)
125-
150+
stackinabox.vm.provision :shell, name: "add_docker_heat_plugin", privileged: false, keep_color: false, path: File.expand_path(File.join(vagrant_dir, "..", "scripts", "docker", "heat.sh"), __FILE__)
126151
end
127152
end

0 commit comments

Comments
 (0)