From 46f750edae74225a4dfbcce1f70990e1122a9613 Mon Sep 17 00:00:00 2001 From: Antoni Segura Puimedon Date: Fri, 29 Jun 2018 17:44:41 +0200 Subject: [PATCH] devstack support for openshift-dns This adds a new devstack service to provide cluster local DNS for Pods. It uses dnsmasq to still allow access to the upstream nameserver, so an extra devstack service openshift-dnsmasq is also created. Change-Id: I43a6b5423bd32a564511ea10ae620922bbad2d2a Signed-off-by: Antoni Segura Puimedon --- .zuul.d/octavia.yaml | 2 + devstack/lib/kuryr_kubernetes | 142 +++++++++++++++++++++++++++ devstack/local.conf.openshift.sample | 2 + devstack/plugin.sh | 13 +++ 4 files changed, 159 insertions(+) diff --git a/.zuul.d/octavia.yaml b/.zuul.d/octavia.yaml index 0294e5c90..7adc62ee9 100644 --- a/.zuul.d/octavia.yaml +++ b/.zuul.d/octavia.yaml @@ -93,6 +93,8 @@ kubelet: false openshift-master: true openshift-node: true + openshift-dnsmasq: true + openshift-dns: true - job: name: kuryr-kubernetes-tempest-daemon-openshift-octavia diff --git a/devstack/lib/kuryr_kubernetes b/devstack/lib/kuryr_kubernetes index 59698717c..3d4eec965 100644 --- a/devstack/lib/kuryr_kubernetes +++ b/devstack/lib/kuryr_kubernetes @@ -1057,3 +1057,145 @@ function get_loadbalancer_attribute { neutron lbaas-loadbalancer-show "$lb_name" -c "$lb_attr" -f value fi } + +# openshift_node_set_dns_config +# Description: Configures Openshift node's DNS section atomically +# Params: +# node_conf_path: path_to_node_config +# upstream_dns_ip: IP of the upstream DNS +function openshift_node_set_dns_config { + local openshift_dnsmasq_recursive_resolv + local upstream_dns_ip + openshift_dnsmasq_recursive_resolv="${OPENSHIFT_DATA_DIR}/node/resolv.conf" + + upstream_dns_ip="$2" + cat > "$openshift_dnsmasq_recursive_resolv" << EOF +nameserver $upstream_dns_ip +EOF + + python - < "$openshift_dnsmasq_conf_path" << EOF +server=${upstream_dns_ip} +no-resolv +domain-needed +no-negcache +max-cache-ttl=1 +# Enable dbus so openshift dns can use it to set cluster.local rules +enable-dbus +dns-forward-max=10000 +cache-size=10000 +bind-dynamic +# Do not bind to localhost addresses 127.0.0.1/8 (where skydns binds) +except-interface=lo +EOF + + #Open port 53 so pods can reach the DNS server + sudo iptables -I INPUT 1 -p udp -m udp --dport 53 -j ACCEPT + + dnsmasq_binary="$(command -v dnsmasq)" + cmd="${dnsmasq_binary} -k -C ${openshift_dnsmasq_conf_path}" + if [[ "$USE_SYSTEMD" = "True" ]]; then + # If systemd is being used, proceed as normal + run_process openshift-dnsmasq "$cmd" root root + else + # If screen is being used, there is a possibility that the devstack + # environment is on a stable branch. Older versions of run_process have + # a different signature. Sudo is used as a workaround that works in + # both older and newer versions of devstack. + run_process openshift-dnsmasq "sudo $cmd" + fi + + sudo cp /etc/resolv.conf /etc/resolv.conf.orig + search_domains=$(awk '/search/ {for (i=2; i