Skip to content

Commit

Permalink
Merge branch 'feat-designate' into smartme
Browse files Browse the repository at this point in the history
  • Loading branch information
artynet committed May 4, 2022
2 parents 0f419ce + 80a0899 commit c5668c3
Show file tree
Hide file tree
Showing 16 changed files with 4,765 additions and 1 deletion.
41 changes: 41 additions & 0 deletions 7-designate/7-designate
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#! /bin/bash

VERSION="latest"

docker create \
--name=s4t_designate \
--restart unless-stopped\
--network=s4t-controller-network \
--hostname designate \
-p 9002:9001 \
-p 53:53/udp \
-p 53:53/tcp \
-v s4t_designate_config:/etc/designate/ \
-v s4t_bind:/etc/bind/ \
-v /var/log/designate-conductor:/var/log/designate \
smartme/s4t_designate:$VERSION

docker cp build/bin/startDesignate s4t_designate:/usr/local/bin/
docker cp conf/adminrc s4t_designate:/root/

docker cp conf/designate.conf s4t_designate:/etc/designate/
docker cp conf/pools.yaml s4t_designate:/etc/designate/
docker cp conf/named.conf.options s4t_designate:/etc/bind/

docker run --rm \
--network=s4t-controller-network \
-v s4t_designate_config:/etc/designate/ \
-v /var/log/designate-conductor:/var/log/designate \
smartme/s4t_designate:$VERSION \
/bin/sh -c "chown -R designate:designate /var/log/designate/"

docker run --rm \
--network=s4t-controller-network \
-v s4t_designate_config:/etc/designate/ \
-v /var/log/designate-conductor:/var/log/designate \
smartme/s4t_designate:$VERSION /bin/sh -c "designate-manage database sync" designate

docker start s4t_designate

echo "aspetto che i servizi siano su"
sleep 10
18 changes: 18 additions & 0 deletions 7-designate/7.1-designate
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#! /bin/bash

IP_DESIGNATE="demo-controller.smartme.io"
HTTPS=true
DESIGNATE_PASS="smartme"

URL="http://$IP_DESIGNATE:9001"
if [ "$HTTPS" = true ] ; then
URL="https://$IP_DESIGNATE:9001"
fi

echo $URL

docker exec s4t_keystone openstack service create dns --name Designate
docker exec s4t_keystone openstack user create --password $DESIGNATE_PASS designate
docker exec s4t_keystone openstack role add --project service --user designate admin

docker exec s4t_keystone openstack endpoint create --region RegionOne dns public $URL
10 changes: 10 additions & 0 deletions 7-designate/7.2-designate
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/bash

DNS="test.felooca.info"
EMAIL="[email protected]"

docker exec s4t_designate /bin/sh -c "designate-manage pool update" designate
docker restart s4t_designate
docker exec s4t_designate /bin/bash -c "source /root/adminrc && openstack zone create --email ${EMAIL} ${DNS}."


50 changes: 50 additions & 0 deletions 7-designate/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM ubuntu:focal

ENV DEBIAN_FRONTEND=noninteractive

ENV LC_CTYPE C.UTF-8
ENV LC_ALL C.UTF-8
ENV LANGUAGE C.UTF-8
ENV LANG C.UTF-8

RUN apt-get update \
&& apt-get install nocache -y software-properties-common locales tzdata\
&& add-apt-repository -y cloud-archive:xena \
&& apt-get update && apt-get -y dist-upgrade \
&& apt-get install nocache -y build-essential python3-openstackclient \
python3 python3-all python3-setuptools nano vim wget curl \
nocache bind9 bind9utils bind9-doc designate-worker designate-producer designate-mdns \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& wget -qO- https://bootstrap.pypa.io/get-pip.py | python3 \
&& :

RUN locale-gen en_US.UTF-8
ENV TZ 'Europe/Rome'
RUN echo $TZ > /etc/timezone && rm -f /etc/localtime && ln -nfs /usr/share/zoneinfo/$TZ /etc/localtime && dpkg-reconfigure -f noninteractive tzdata

#RUN rndc-confgen -a -k designate -c /etc/bind/rndc.key -r /dev/urandom

COPY conf/adminrc /root/

COPY conf/designate.conf /etc/designate/
COPY conf/pools.yaml /etc/designate/
COPY conf/named.conf.options /etc/bind/

COPY bin/startDesignate /usr/local/bin/startDesignate
COPY scripts/designate-setup.sh /usr/local/bin/designate-setup

RUN chown -R designate:designate /var/log/designate/

RUN chmod +x /usr/local/bin/startDesignate
RUN chmod +x /usr/local/bin/designate-setup

VOLUME ["/etc/designate"]
VOLUME ["/etc/bind"]
VOLUME ["/var/log/designate"]

EXPOSE 9001
EXPOSE 53
EXPOSE 53/udp

CMD ["/usr/local/bin/startDesignate"]
68 changes: 68 additions & 0 deletions 7-designate/build/bin/startDesignate
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash


/usr/sbin/named -f -u bind &
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start bind9: $status"
exit $status
fi

# Start the first process
/usr/bin/designate-central --config-file=/etc/designate/designate.conf &
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start designate-central: $status"
exit $status
fi

# Start the second process
/usr/bin/designate-api --config-file=/etc/designate/designate.conf &
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start designate-api: $status"
exit $status
fi

/usr/bin/designate-worker --config-file=/etc/designate/designate.conf &
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start designate-worker: $status"
exit $status
fi

/usr/bin/designate-producer --config-file=/etc/designate/designate.conf &
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start designate-producer: $status"
exit $status
fi

/usr/bin/designate-mdns --config-file=/etc/designate/designate.conf
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start designate-mdns: $status"
exit $status
fi


while sleep 60; do
ps aux |grep named |grep -q -v grep
PROCESS_1_STATUS=$?
ps aux |grep designate-central |grep -q -v grep
PROCESS_2_STATUS=$?
ps aux |grep designate-api |grep -q -v grep
PROCESS_3_STATUS=$?
ps aux |grep designate-worker |grep -q -v grep
PROCESS_4_STATUS=$?
ps aux |grep designate-producer |grep -q -v grep
PROCESS_5_STATUS=$?
ps aux |grep designate-mdns |grep -q -v grep
PROCESS_6_STATUS=$?
# If the greps above find anything, they exit with 0 status
# If they are not both 0, then something is wrong
if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 -o $PROCESS_3_STATUS -ne 0 -o $PROCESS_4_STATUS -ne 0 -o $PROCESS_5_STATUS -ne 0 -o $PROCESS_6_STATUS -ne 0 ]; then
echo "One of the processes has already exited."
exit 1
fi
done
4 changes: 4 additions & 0 deletions 7-designate/build/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/bash

VERSION="latest"
docker build -t smartmeio/s4t_designate:$VERSION .
8 changes: 8 additions & 0 deletions 7-designate/build/conf/adminrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=smartme
export OS_AUTH_URL=https://demo-controller.smartme.io:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
Loading

0 comments on commit c5668c3

Please sign in to comment.