-
Notifications
You must be signed in to change notification settings - Fork 45
/
gateway_sidecar.sh
executable file
·49 lines (38 loc) · 1.17 KB
/
gateway_sidecar.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh -ex
# Load main settings
cat /default_config/settings.sh
. /default_config/settings.sh
cat /config/settings.sh
. /config/settings.sh
#Get K8S DNS
K8S_DNS=$(grep nameserver /etc/resolv.conf|cut -d' ' -f2)
#create config
echo "
# DHCP server settings
interface=vxlan0
bind-interfaces
# Dynamic IPs assigned to PODs - we keep a range for static IPs
dhcp-range=${VXLAN_IP_NETWORK}.${VXLAN_GATEWAY_FIRST_DYNAMIC_IP},${VXLAN_IP_NETWORK}.255,12h
# For debugging purposes, log each DNS query as it passes through
# dnsmasq.
log-queries
# Log lots of extra information about DHCP transactions.
log-dhcp
# Log to stdout
log-facility=-
">>/etc/dnsmasq.conf
for local_cidr in ${DNS_LOCAL_CIDRS}; do
echo "
# Send ${local_cidr} DNS queries to the K8S DNS server
server=/${local_cidr}/${K8S_DNS}
">>/etc/dnsmasq.conf
done
# Need to wait until new DNS server in /etc/resolv.conf is setup
# by the VPN.
#
# dnsmasq should be able to detect changes in /etc/resolv.conf
# and reload the settings but this does not work
#
# TBD: find a better way...
sleep 10
exec dnsmasq -k