Add swift boilerplate

Add swift boilerplate for Docker building and Kubernetes support
This commit is contained in:
Steven Dake 2014-09-20 13:14:59 -07:00 committed by Lars Kellogg-Stedman
parent 87276efbbd
commit 3c7e0da467
16 changed files with 273 additions and 0 deletions

View File

@ -0,0 +1,6 @@
FROM fedora-rdo-base
MAINTAINER Steven Dake <sdake@redhat.com>
ADD ./start.sh /start.sh
CMD ["/start.sh"]

View File

@ -0,0 +1,2 @@
#!/bin/bash
sudo docker build --tag fedora-rdo-swift-account-server .

View File

@ -0,0 +1,40 @@
#!/bin/sh
: ${SWIFT_DB_USER:=swift}
: ${SWIFT_DB_NAME:=swift}
: ${KEYSTONE_AUTH_PROTOCOL:=http}
: ${SWIFT_KEYSTONE_USER:=swift}
: ${ADMIN_TENANT_NAME:=admin}
if ! [ "$KEYSTONE_ADMIN_TOKEN" ]; then
echo "*** Missing KEYSTONE_ADMIN_TOKEN" >&2
exit 1
fi
if ! [ "$DB_ROOT_PASSWORD" ]; then
echo "*** Missing DB_ROOT_PASSWORD" >&2
exit 1
fi
if ! [ "$SWIFT_DB_PASSWORD" ]; then
SWIFT_DB_PASSWORD=$(openssl rand -hex 15)
export SWIFT_DB_PASSWORD
fi
sh /opt/swift/config-swift.sh account-server
mysql -h ${MARIADBMASTER_PORT_3306_TCP_ADDR} -u root \
-p${DB_ROOT_PASSWORD} mysql <<EOF
CREATE DATABASE IF NOT EXISTS ${SWIFT_DB_NAME};
GRANT ALL PRIVILEGES ON swift* TO
'${SWIFT_DB_USER}'@'%' IDENTIFIED BY '${SWIFT_DB_PASSWORD}'
EOF
export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}"
export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONEMASTER_35357_PORT_35357_TCP_ADDR}:35357/v2.0"
/bin/keystone user-create --name ${SWIFT_KEYSTONE_USER} --pass ${SWIFT_ADMIN_PASSWORD}
/bin/keystone role-create --name ${SWIFT_KEYSTONE_USER}
/bin/keystone user-role-add --user ${SWIFT_KEYSTONE_USER} --role admin --tenant ${ADMIN_TENANT_NAME}
exec /usr/bin/swift-engine

View File

@ -0,0 +1,8 @@
FROM fedora-rdo-base
MAINTAINER Steven Dake <sdake@redhat.com>
RUN yum -y install openstack-utils openstack-swift && yum clean all
# These will come after we sort out start time config
RUN mkdir /opt/swift
#COPY config-swift.sh /opt/swift/config-swift.sh

View File

@ -0,0 +1,8 @@
FROM fedora-rdo-base
MAINTAINER Steven Dake <sdake@redhat.com>
RUN yum -y install openstack-utils openstack-swift && yum clean all
# These will come after we sort out start time config
RUN mkdir /opt/swift
config-swift.sh /opt/swift/config-swift.sh

2
docker/swift/swift-base/build Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
sudo docker build --tag swift-proxy-base .

View File

@ -0,0 +1,6 @@
FROM fedora-rdo-base
MAINTAINER Steven Dake <sdake@redhat.com>
ADD ./start.sh /start.sh
CMD ["/start.sh"]

View File

@ -0,0 +1,2 @@
#!/bin/bash
sudo docker build --tag fedora-rdo-swift-container-server .

View File

@ -0,0 +1,40 @@
#!/bin/sh
: ${SWIFT_DB_USER:=swift}
: ${SWIFT_DB_NAME:=swift}
: ${KEYSTONE_AUTH_PROTOCOL:=http}
: ${SWIFT_KEYSTONE_USER:=swift}
: ${ADMIN_TENANT_NAME:=admin}
if ! [ "$KEYSTONE_ADMIN_TOKEN" ]; then
echo "*** Missing KEYSTONE_ADMIN_TOKEN" >&2
exit 1
fi
if ! [ "$DB_ROOT_PASSWORD" ]; then
echo "*** Missing DB_ROOT_PASSWORD" >&2
exit 1
fi
if ! [ "$SWIFT_DB_PASSWORD" ]; then
SWIFT_DB_PASSWORD=$(openssl rand -hex 15)
export SWIFT_DB_PASSWORD
fi
sh /opt/swift/config-swift.sh container
mysql -h ${MARIADBMASTER_PORT_3306_TCP_ADDR} -u root \
-p${DB_ROOT_PASSWORD} mysql <<EOF
CREATE DATABASE IF NOT EXISTS ${SWIFT_DB_NAME};
GRANT ALL PRIVILEGES ON swift* TO
'${SWIFT_DB_USER}'@'%' IDENTIFIED BY '${SWIFT_DB_PASSWORD}'
EOF
export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}"
export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONEMASTER_35357_PORT_35357_TCP_ADDR}:35357/v2.0"
/bin/keystone user-create --name ${SWIFT_KEYSTONE_USER} --pass ${SWIFT_ADMIN_PASSWORD}
/bin/keystone role-create --name ${SWIFT_KEYSTONE_USER}
/bin/keystone user-role-add --user ${SWIFT_KEYSTONE_USER} --role admin --tenant ${ADMIN_TENANT_NAME}
exec /usr/bin/swift-container-server

View File

@ -0,0 +1,6 @@
FROM fedora-rdo-base
MAINTAINER Steven Dake <sdake@redhat.com>
ADD ./start.sh /start.sh
CMD ["/start.sh"]

View File

@ -0,0 +1,2 @@
#!/bin/bash
sudo docker build --tag fedora-rdo-swift-object-server .

View File

@ -0,0 +1,40 @@
#!/bin/sh
: ${SWIFT_DB_USER:=swift}
: ${SWIFT_DB_NAME:=swift}
: ${KEYSTONE_AUTH_PROTOCOL:=http}
: ${SWIFT_KEYSTONE_USER:=swift}
: ${ADMIN_TENANT_NAME:=admin}
if ! [ "$KEYSTONE_ADMIN_TOKEN" ]; then
echo "*** Missing KEYSTONE_ADMIN_TOKEN" >&2
exit 1
fi
if ! [ "$DB_ROOT_PASSWORD" ]; then
echo "*** Missing DB_ROOT_PASSWORD" >&2
exit 1
fi
if ! [ "$SWIFT_DB_PASSWORD" ]; then
SWIFT_DB_PASSWORD=$(openssl rand -hex 15)
export SWIFT_DB_PASSWORD
fi
sh /opt/swift/config-swift.sh engine
mysql -h ${MARIADBMASTER_PORT_3306_TCP_ADDR} -u root \
-p${DB_ROOT_PASSWORD} mysql <<EOF
CREATE DATABASE IF NOT EXISTS ${SWIFT_DB_NAME};
GRANT ALL PRIVILEGES ON swift* TO
'${SWIFT_DB_USER}'@'%' IDENTIFIED BY '${SWIFT_DB_PASSWORD}'
EOF
export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}"
export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONEMASTER_35357_PORT_35357_TCP_ADDR}:35357/v2.0"
/bin/keystone user-create --name ${SWIFT_KEYSTONE_USER} --pass ${SWIFT_ADMIN_PASSWORD}
/bin/keystone role-create --name ${SWIFT_KEYSTONE_USER}
/bin/keystone user-role-add --user ${SWIFT_KEYSTONE_USER} --role admin --tenant ${ADMIN_TENANT_NAME}
exec /usr/bin/swift-object-server

View File

@ -0,0 +1,6 @@
FROM fedora-rdo-swift-base
MAINTAINER Steven Dake <sdake@redhat.com>
ADD ./start.sh /start.sh
CMD ["/start.sh"]

View File

@ -0,0 +1,2 @@
#!/bin/bash
sudo docker build --tag fedora-rdo-swift-proxy-server .

View File

@ -0,0 +1,5 @@
#!/bin/sh
sh /opt/swift/config-swift.sh proxy
exec /usr/bin/swift-proxy-server

98
docker/swift/swift.json Normal file
View File

@ -0,0 +1,98 @@
{
"id": "swift",
"desiredState": {
"manifest": {
"version": "v1beta1",
"id": "swift-1",
"containers": [
{
"name": "swift-account-server",
"image": "fedora-rdo-swift-account-server",
"ports": [
{"containerPort": 9292},
],
"env": [
{
"name": "DB_ROOT_PASSWORD",
"value": "password"
},
{
"name": "SWIFT_DB_PASSWORD",
"value": "swiftdbpassword"
},
{
"name": "KEYSTONE_ADMIN_TOKEN",
"value": "ADMINTOKEN"
},
]
},
{
"name": "swift-container-server",
"image": "fedora-rdo-swift-container-server",
"ports": [
{"containerPort": 9292},
],
"env": [
{
"name": "DB_ROOT_PASSWORD",
"value": "password"
},
{
"name": "SWIFT_DB_PASSWORD",
"value": "swiftdbpassword"
},
{
"name": "KEYSTONE_ADMIN_TOKEN",
"value": "ADMINTOKEN"
},
]
},
{
"name": "swift-object-server",
"image": "fedora-rdo-swift-object-server",
"ports": [
{"containerPort": 9292},
],
"env": [
{
"name": "DB_ROOT_PASSWORD",
"value": "password"
},
{
"name": "SWIFT_DB_PASSWORD",
"value": "swiftdbpassword"
},
{
"name": "KEYSTONE_ADMIN_TOKEN",
"value": "ADMINTOKEN"
},
]
},
{
"name": "swift-proxy-server",
"image": "fedora-rdo-swift-proxy-server",
"ports": [
{"containerPort": 9292},
],
"env": [
{
"name": "DB_ROOT_PASSWORD",
"value": "password"
},
{
"name": "SWIFT_DB_PASSWORD",
"value": "swiftdbpassword"
},
{
"name": "KEYSTONE_ADMIN_TOKEN",
"value": "ADMINTOKEN"
},
]
},
]
}
},
"labels": {
"name": "keystone-master"
}
}