Skip to content
This repository was archived by the owner on Jul 4, 2023. It is now read-only.

Commit 5cd633e

Browse files
author
Riaan Nolan
committed
trun of systemd-resolve, install dnsmasq, config dns forwarder to consul, set nameserver in Dockerfile for Nomad waypoint deployments, working nice, w00t w00t
1 parent 66c7417 commit 5cd633e

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed

hashicorp/consul.sh

+27-24
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ function consul-install() {
55

66
arch=$(lscpu | grep "Architecture" | awk '{print $NF}')
77
if [[ $arch == x86_64* ]]; then
8-
ARCH="amd64"
8+
ARCH="amd64"
99
elif [[ $arch == aarch64 ]]; then
10-
ARCH="arm64"
10+
ARCH="arm64"
1111
fi
1212
echo -e '\e[38;5;198m'"CPU is $ARCH"
1313

@@ -123,33 +123,36 @@ EOF
123123
consul kv put fabio/config/countdashtest1 "route add countdashtest fabio.service.consul:9999/countdashtest http://10.9.99.10:9022/ opts \"strip=/countdashtest\""
124124
consul kv put fabio/config/docsify "route add docsify docsify.service.consul:9999/ http://10.9.99.10:3333"
125125

126-
echo -e '\e[38;5;198m'"++++ Adding Consul for DNS lookups"
127-
# https://learn.hashicorp.com/tutorials/consul/dns-forwarding#systemd-resolved-setup
128-
mkdir -p /etc/systemd/resolved.conf.d/
129-
cat <<EOF | sudo tee /etc/systemd/resolved.conf.d/consul.conf
130-
[Resolve]
131-
DNS=127.0.0.1
132-
DNSSEC=false
133-
Domains=~consul
126+
echo -e '\e[38;5;198m'"++++ Install DNSMasq"
127+
sudo systemctl disable systemd-resolved
128+
sudo systemctl stop systemd-resolved
129+
sleep 10;
130+
sudo apt-get install -y dnsmasq
131+
echo -e '\e[38;5;198m'"++++ Adding DNSMasq config for Consul for DNS lookups"
132+
# https://learn.hashicorp.com/tutorials/consul/dns-forwarding#dnsmasq-setup
133+
cat <<EOF | sudo tee /etc/dnsmasq.d/10-consul
134+
# Enable forward lookup of the 'consul' domain:
135+
server=/consul/10.9.99.10#8600
136+
137+
# Uncomment and modify as appropriate to enable reverse DNS lookups for
138+
# common netblocks found in RFC 1918, 5735, and 6598:
139+
#rev-server=0.0.0.0/8,127.0.0.1#8600
140+
#rev-server=10.0.0.0/8,127.0.0.1#8600
141+
#rev-server=100.64.0.0/10,127.0.0.1#8600
142+
#rev-server=127.0.0.1/8,127.0.0.1#8600
143+
#rev-server=169.254.0.0/16,127.0.0.1#8600
144+
#rev-server=172.16.0.0/12,127.0.0.1#8600
145+
#rev-server=192.168.0.0/16,127.0.0.1#8600
146+
#rev-server=224.0.0.0/4,127.0.0.1#8600
147+
#rev-server=240.0.0.0/4,127.0.0.1#8600
134148
EOF
135-
136-
iptables --table nat --append OUTPUT --destination localhost --protocol udp --match udp --dport 53 --jump REDIRECT --to-ports 8600
137-
iptables --table nat --append OUTPUT --destination localhost --protocol tcp --match tcp --dport 53 --jump REDIRECT --to-ports 8600
138-
iptables -vnL -t nat| grep 8600
139-
140-
echo -e '\e[38;5;198m'"++++ Restart systemd-resolved"
141-
systemctl restart systemd-resolved
149+
sudo systemctl restart dnsmasq
142150

143-
echo -e '\e[38;5;198m'"++++ Validate the systemd-resolved configuration"
151+
echo -e '\e[38;5;198m'"++++ Set /etc/resolv.conf configuration"
144152
cat <<EOF | sudo tee /etc/resolv.conf
145-
nameserver 127.0.0.1
153+
nameserver 10.9.99.10
146154
nameserver 8.8.8.8
147155
EOF
148-
systemctl is-active systemd-resolved
149-
resolvectl domain
150-
resolvectl query consul.service.consul
151-
ls -l /etc/resolv.conf
152-
host consul.service.consul
153156

154157
echo -e '\e[38;5;198m'"++++ Consul http://localhost:8500"
155158
echo -e '\e[38;5;198m'"++++ Consul Documentation http://localhost:3333/#/hashicorp/README?id=consul"

hashicorp/waypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function waypoint-nomad() {
136136
sudo rm -rf /opt/nomad/data/volume/waypoint/*
137137
echo -e '\e[38;5;198m'"++++ Waypoint Install on Platform Hashicorp Nomad"
138138
export NOMAD_ADDR='http://localhost:4646'
139-
sudo --preserve-env=PATH -u vagrant waypoint install -platform=nomad -nomad-dc=dc1 -accept-tos -nomad-host-volume=waypoint -context-create=nomad -runner=false
139+
sudo --preserve-env=PATH -u vagrant waypoint install -platform=nomad -nomad-dc=dc1 -accept-tos -nomad-host-volume=waypoint -nomad-consul-service=true -context-create=nomad -runner=false
140140
sleep 60;
141141
nomad job status
142142
nomad status

hashicorp/waypoint/custom-examples/nomad-trex-nodejs/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ RUN npm install
1010

1111
COPY . .
1212

13+
RUN echo "nameserver 10.9.99.10" > /etc/resolv.conf
14+
1315
EXPOSE 6001
1416

1517
CMD [ "node", "index.js" ]

0 commit comments

Comments
 (0)