Skip to content

Commit ac3c082

Browse files
yboaronnRussell Bryant
authored and
Russell Bryant
committed
Run DNS server in container at BM server
For the DNS short term solution, the external DNS should be configured with the relevant SRV and CNAME records. In OCP-DOIT environment we'll run a DNS Server at BM that will play the external DNS role. The Neutron DNS will point to this server as the upstream server, and the BM server will point to the LAB external DNS server.
1 parent 15d6dc8 commit ac3c082

File tree

4 files changed

+81
-6
lines changed

4 files changed

+81
-6
lines changed

Diff for: 01_install_requirements.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ cd
3333
sudo tripleo-repos current-tripleo-dev
3434
sudo yum -y update
3535
sudo yum install -y python2-tripleoclient
36-
36+
# make sure that 'dig' is installed
37+
sudo yum install -y bind-utils
3738
# TRIPLEO HEAT TEMPLATES
3839
if [ ! -d $SCRIPTDIR/tripleo-heat-templates ]; then
3940
cd $SCRIPTDIR

Diff for: 02_run_all_in_one.sh

+45-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,41 @@
22
set -x
33

44
source common.sh
5+
6+
57
: ${DNS_SERVER_1:=1.1.1.1}
6-
: ${DNS_SERVER_2:=8.8.8.8}
78

9+
# run CoreDns container (host-net), Neutron upstream-dns will point to this server and CoreDns will point to external DNS server
10+
sed -i "s/DNS_SERVER_1/$DNS_SERVER_1/g" coredns_cfg/Corefile
11+
sudo docker run -d -m 128m --restart="unless-stopped" --net host --cap-add=NET_ADMIN -v "$PWD"/coredns_cfg:/etc/coredns --name coredns coredns/coredns:latest -conf /etc/coredns/Corefile
12+
13+
14+
function verify_dns {
15+
16+
ips=($(dig +short -t srv _etcd-server-ssl._tcp.ostest.shiftstack.com. @"${LOCAL_IP}"))
17+
if [[ "$?" -eq 0 && "${#ips[@]}" -ne 0 ]]; then
18+
echo "DNS resolve SRV record _etcd-server-ssl._tcp.ostest.shiftstack.com. - Success"
19+
else
20+
return 1
21+
fi
22+
23+
ips=($(dig +short google.com @"${LOCAL_IP}"))
24+
echo $ips
25+
if [[ "$?" -eq 0 && "${#ips[@]}" -ne 0 ]]; then
26+
echo "DNS resolve google.com - success"
27+
else
28+
return 1
29+
fi
30+
return 0
31+
}
32+
set +x
33+
if verify_dns; then
34+
echo "Pre tripleo deployment - DNS is working!";
35+
else
36+
echo -e "Pre tripleo deployment -DNS can not resolve SRV record, google.com\\nplease ***fix it*** (Docker service enabled? IPtables??)";
37+
exit
38+
fi
39+
set -x
840
openstack tripleo container image prepare default \
941
--output-env-file $SCRIPTDIR/containers-prepare-parameters.yaml
1042

@@ -19,11 +51,9 @@ parameter_defaults:
1951
Debug: true
2052
DeploymentUser: $USER
2153
DnsServers:
22-
- $DNS_SERVER_1
23-
- $DNS_SERVER_2
54+
- $LOCAL_IP
2455
NeutronDhcpAgentDnsmasqDnsServers:
25-
- $DNS_SERVER_1
26-
- $DNS_SERVER_2
56+
- $LOCAL_IP
2757
# needed for vip & pacemaker
2858
KernelIpNonLocalBind: 1
2959
DockerInsecureRegistryAddress:
@@ -64,3 +94,13 @@ sudo openstack tripleo deploy \
6494
sudo chown -R $USER:$USER ~/.config/openstack
6595
sed -i.bak 's/cloud:/#cloud:/' ~/.config/openstack/clouds.yaml
6696
sed -i.bak '4i\ domain_name: default' ~/.config/openstack/clouds.yaml
97+
98+
# Enable DNS port and verify that DNS still working after tripleo deployment
99+
sudo iptables -I INPUT 2 -p udp --dport 53 -j ACCEPT
100+
sudo iptables -I INPUT 3 -p udp --sport 53 -j ACCEPT
101+
set +x
102+
if verify_dns; then
103+
echo "Post tripleo deployment - DNS is working!";
104+
else
105+
echo -e "Post tripleo deployment -DNS can not resolve SRV record, google.com (IPtables??)\\nplease ****Fix it**** before running next step!";
106+
fi

Diff for: coredns_cfg/Corefile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
shiftstack.com {
2+
log
3+
errors
4+
file /etc/coredns/db.shiftstack.com {
5+
upstream DNS_SERVER_1
6+
reload 10s
7+
}
8+
}
9+
. {
10+
log
11+
errors
12+
#auto
13+
reload 10s
14+
forward . DNS_SERVER_1 {
15+
except shiftstack.com
16+
}
17+
}
18+

Diff for: coredns_cfg/db.shiftstack.com

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
$ORIGIN shiftstack.com.
2+
@ 3600 IN SOA sns.dns.icann.org. noc.dns.icann.org. (
3+
2017042745 ; serial
4+
7200 ; refresh (2 hours)
5+
3600 ; retry (1 hour)
6+
1209600 ; expire (2 weeks)
7+
3600 ; minimum (1 hour)
8+
)
9+
#ostest-master-0 IN A 10.0.0.223
10+
ostest-etcd-2.shiftstack.com. IN CNAME ostest-master-2
11+
ostest-etcd-1.shiftstack.com. IN CNAME ostest-master-1
12+
ostest-etcd-0.shiftstack.com. IN CNAME ostest-master-0
13+
_etcd-server-ssl._tcp.ostest.shiftstack.com. 8640 IN SRV 0 10 2380 ostest-etcd-0
14+
_etcd-server-ssl._tcp.ostest.shiftstack.com. 8640 IN SRV 0 10 2380 ostest-etcd-1
15+
_etcd-server-ssl._tcp.ostest.shiftstack.com. 8640 IN SRV 0 10 2380 ostest-etcd-2
16+

0 commit comments

Comments
 (0)