First commit
(Contains all the master branches of the previous repositories)
This commit is contained in:
1
docker-glance/.gitignore
vendored
Normal file
1
docker-glance/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
build.sh
|
32
docker-glance/Dockerfile
Normal file
32
docker-glance/Dockerfile
Normal file
@ -0,0 +1,32 @@
|
||||
FROM ubuntu:16.04
|
||||
# install packages
|
||||
|
||||
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5EDB1B62EC4926EA
|
||||
|
||||
RUN set -x \
|
||||
&& echo "deb http://ubuntu-cloud.archive.canonical.com/ubuntu xenial-updates/ocata main" > /etc/apt/sources.list.d/ocata.list \
|
||||
&& apt-get -y update \
|
||||
&& apt-get -y install ubuntu-cloud-keyring \
|
||||
&& apt-get -y update \
|
||||
&& apt-get -y install \
|
||||
mysql-client \
|
||||
glance \
|
||||
python-mysqldb \
|
||||
python-openstackclient \
|
||||
python-oslo.cache \
|
||||
&& apt-get -y clean \
|
||||
&& rm -f /var/lib/glance/glance.sqlite
|
||||
|
||||
EXPOSE 9292
|
||||
|
||||
#file that writes configs
|
||||
COPY write_conf.sh /etc/write_conf.sh
|
||||
# add bootstrap script and make it executable
|
||||
COPY bootstrap.sh /etc/bootstrap.sh
|
||||
|
||||
COPY run.sh /etc/run.sh
|
||||
|
||||
RUN chown root.root /etc/bootstrap.sh && chmod a+x /etc/bootstrap.sh
|
||||
RUN chown root.root /etc/run.sh && chmod a+x /etc/run.sh
|
||||
|
||||
CMD ["/etc/run.sh"]
|
33
docker-glance/README.md
Normal file
33
docker-glance/README.md
Normal file
@ -0,0 +1,33 @@
|
||||
# How to build
|
||||
```
|
||||
docker build . -t hpc/openstack-glance
|
||||
```
|
||||
|
||||
# Bootstrap
|
||||
```
|
||||
docker run --rm
|
||||
-e "RABBIT_HOST={{ hostvars[groups['rabbitmq'][0]]['ansible_default_ipv4']['address'] }}"
|
||||
-e "MEMCACHED_HOST={{ hostvars[groups['memcached'][0]]['ansible_default_ipv4']['address'] }}"
|
||||
-e "MYSQL_HOST={{ hostvars[groups['databases'][0]]['ansible_default_ipv4']['address'] }}"
|
||||
-e "MYSQL_ROOT_PASSWORD=geheim"
|
||||
-e "KEYSTONE_HOST={{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }}"
|
||||
-e "GLANCE_HOST={{ hostvars[groups['glance'][0]]['ansible_default_ipv4']['address'] }}"
|
||||
-e "GLANCE_PASSWORD=geheim"
|
||||
hpc/openstack-glance /etc/bootstrap.sh
|
||||
|
||||
```
|
||||
|
||||
# Run an image
|
||||
|
||||
```
|
||||
/usr/bin/docker run --name %n \
|
||||
-e "RABBIT_HOST={{ hostvars[groups['rabbitmq'][0]]['ansible_default_ipv4']['address'] }}" \
|
||||
-e "MEMCACHED_HOST={{ hostvars[groups['memcached'][0]]['ansible_default_ipv4']['address'] }}" \
|
||||
-e "MYSQL_HOST={{ hostvars[groups['databases'][0]]['ansible_default_ipv4']['address'] }}" \
|
||||
-e "MYSQL_ROOT_PASSWORD=geheim" \
|
||||
-e "KEYSTONE_HOST={{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }}" \
|
||||
-e "GLANCE_HOST={{ hostvars[groups['glance'][0]]['ansible_default_ipv4']['address'] }}" \
|
||||
-e "GLANCE_PASSWORD=geheim" \
|
||||
-p 9292:9292 \
|
||||
hpc/openstack-glance
|
||||
```
|
16
docker-glance/admin-openrc.sh
Normal file
16
docker-glance/admin-openrc.sh
Normal file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
# a admin-openrc.sh file
|
||||
|
||||
# To create the Identity service credentials
|
||||
GLANCE_USER_NAME=glance
|
||||
GLANCE_PASSWORD=geheim
|
||||
export OS_IDENTITY_API_VERSION=3
|
||||
export OS_USERNAME=admin
|
||||
export OS_PASSWORD=geheim
|
||||
export OS_TENANT_NAME=admin
|
||||
export OS_AUTH_URL=http://${KEYSTONE_HOST}:35357/v3
|
||||
|
||||
export OS_PROJECT_DOMAIN_NAME=default
|
||||
export OS_USER_DOMAIN_NAME=default
|
||||
export OS_PROJECT_NAME=admin
|
||||
export OS_IMAGE_API_VERSION=2
|
45
docker-glance/bootstrap.sh
Executable file
45
docker-glance/bootstrap.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Create admin-openrc.sh from secrets that are in the environment during bootstrap.
|
||||
cat << EOF > /root/admin-openrc.sh
|
||||
#!/bin/bash
|
||||
export OS_TENANT_NAME=admin
|
||||
export OS_USERNAME=admin
|
||||
export OS_PASSWORD=${OS_PASSWORD}
|
||||
export OS_AUTH_URL=http://${KEYSTONE_HOST}:35357/v3
|
||||
export OS_IDENTITY_API_VERSION=3
|
||||
|
||||
export GLANCE_USER_NAME=glance
|
||||
export GLANCE_PASSWORD=${GLANCE_PASSWORD}
|
||||
export OS_PROJECT_DOMAIN_NAME=default
|
||||
export OS_USER_DOMAIN_NAME=default
|
||||
export OS_PROJECT_NAME=admin
|
||||
export OS_IMAGE_API_VERSION=2
|
||||
EOF
|
||||
|
||||
source /root/admin-openrc.sh
|
||||
|
||||
# Write the config files
|
||||
/etc/write_conf.sh
|
||||
|
||||
# create database for glance
|
||||
mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -h "$MYSQL_HOST" << EOF
|
||||
drop database if exists glance;
|
||||
create database glance;
|
||||
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY "$GLANCE_PASSWORD";
|
||||
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY "$GLANCE_PASSWORD";
|
||||
EOF
|
||||
|
||||
openstack user create "$GLANCE_USER" --domain default --password "$GLANCE_PASSWORD"
|
||||
openstack role add --user glance --project service admin
|
||||
openstack service create --name glance --description "OpenStack Image Service" image
|
||||
openstack endpoint create glance admin http://"${GLANCE_HOST}":9292 --region RegionOne
|
||||
openstack endpoint create glance public http://"${GLANCE_HOST}":9292 --region RegionOne
|
||||
openstack endpoint create glance internal http://"${GLANCE_HOST}":9292 --region RegionOne
|
||||
|
||||
# Workaround, see https://bugs.launchpad.net/glance/+bug/1697835
|
||||
sed -i "/op.drop_index('ix_images_is_public', 'images')/a \ \ \ \ op.execute(\"\"\"ALTER TABLE images DROP CONSTRAINT CONSTRAINT_1\"\"\")" \
|
||||
/usr/lib/python2.7/dist-packages/glance/db/sqlalchemy/alembic_migrations/versions/ocata01_add_visibility_remove_is_public.py
|
||||
|
||||
# sync the database
|
||||
su -s /bin/sh -c "glance-manage db_sync" glance
|
14
docker-glance/run.sh
Executable file
14
docker-glance/run.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Write the config files
|
||||
/etc/write_conf.sh
|
||||
# start glance service
|
||||
glance-registry -v -d &
|
||||
sleep 5
|
||||
glance-api -v -d &
|
||||
|
||||
# If any process fails, kill the rest.
|
||||
# This insures the container stops and systemd will restart it.
|
||||
|
||||
wait -n
|
||||
pkill -P $$
|
78
docker-glance/write_conf.sh
Executable file
78
docker-glance/write_conf.sh
Executable file
@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Generate config files from environments values.
|
||||
# These are to be passed to the docker container using -e
|
||||
|
||||
cat << EOF > /etc/glance/glance-api.conf
|
||||
|
||||
[database]
|
||||
connection = mysql+pymysql://$GLANCE_USER:$GLANCE_PASSWORD@$MYSQL_HOST/glance
|
||||
[image_format]
|
||||
[keystone_authtoken]
|
||||
auth_uri = http://$KEYSTONE_HOST:5000
|
||||
auth_url = http://$KEYSTONE_HOST:35357
|
||||
memcached_servers = $MEMCACHED_HOST:11211
|
||||
auth_type = password
|
||||
project_domain_name = Default
|
||||
user_domain_name = Default
|
||||
project_name = service
|
||||
username = glance
|
||||
password = $GLANCE_PASSWORD
|
||||
|
||||
[oslo_messaging_notifications]
|
||||
driver = messagingv2
|
||||
|
||||
[oslo_messaging_rabbit]
|
||||
rabbit_host = $RABBIT_HOST
|
||||
rabbit_userid = $RABBIT_USER
|
||||
rabbit_password = $RABBIT_PASSWORD
|
||||
|
||||
[paste_deploy]
|
||||
flavor = keystone
|
||||
|
||||
|
||||
[glance_store]
|
||||
stores = file,http
|
||||
default_store = file
|
||||
filesystem_store_datadir = /var/lib/glance/images/
|
||||
|
||||
EOF
|
||||
|
||||
|
||||
cat << EOF > /etc/glance/glance-registry.conf
|
||||
|
||||
[DEFAULT]
|
||||
workers = 4
|
||||
rpc_backend = rabbit
|
||||
|
||||
[database]
|
||||
connection = mysql+pymysql://$GLANCE_USER:$GLANCE_PASSWORD@$MYSQL_HOST/glance
|
||||
|
||||
[glance_store]
|
||||
stores = file,http
|
||||
default_store = file
|
||||
filesystem_store_datadir = /var/lib/glance/images/
|
||||
|
||||
[keystone_authtoken]
|
||||
auth_uri = http://$KEYSTONE_HOST:5000
|
||||
auth_url = http://$KEYSTONE_HOST:35357
|
||||
memcached_servers = $MEMCACHED_HOST:11211
|
||||
auth_type = password
|
||||
project_domain_name = Default
|
||||
user_domain_name = Default
|
||||
project_name = service
|
||||
username = glance
|
||||
password = $GLANCE_PASSWORD
|
||||
|
||||
[oslo_messaging_notifications]
|
||||
driver = messagingv2
|
||||
|
||||
[oslo_messaging_rabbit]
|
||||
rabbit_host = $RABBIT_HOST
|
||||
rabbit_userid = $RABBIT_USER
|
||||
rabbit_password = $RABBIT_PASSWORD
|
||||
|
||||
[paste_deploy]
|
||||
flavor = keystone
|
||||
|
||||
EOF
|
Reference in New Issue
Block a user