From 66686005e52c223db119e16ad333ebd9941617ce Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Fri, 7 Jul 2017 14:06:39 -0500 Subject: [PATCH] DNS: add helper chart to OSH for setting up hosts resolv.conf This PS adds a chart to setup the resolv.conf on hosts running openstack-helm. The purpose of this is to reduce friction when performing basic deployments of OS-H. Change-Id: I6c6348afb01869cff9a90328ede795d92a91fb12 --- dns-helper/Chart.yaml | 23 +++++++++++++++ dns-helper/requirements.yaml | 18 ++++++++++++ dns-helper/templates/bin/_dns-helper.sh.tpl | 20 +++++++++++++ dns-helper/templates/configmap-bin.yaml | 23 +++++++++++++++ .../templates/daemonset-dns-helper.yaml | 28 ++++++++++++------- dns-helper/values.yaml | 26 +++++++++++++++++ tools/gate/basic_launch.sh | 3 ++ tools/gate/funcs/network.sh | 8 +----- tools/gate/kubeadm_aio.sh | 1 - 9 files changed, 132 insertions(+), 18 deletions(-) create mode 100644 dns-helper/Chart.yaml create mode 100644 dns-helper/requirements.yaml create mode 100644 dns-helper/templates/bin/_dns-helper.sh.tpl create mode 100644 dns-helper/templates/configmap-bin.yaml rename tools/gate/manifests/resolv-conf-util.yaml => dns-helper/templates/daemonset-dns-helper.yaml (58%) create mode 100644 dns-helper/values.yaml diff --git a/dns-helper/Chart.yaml b/dns-helper/Chart.yaml new file mode 100644 index 0000000000..cfeee1e85b --- /dev/null +++ b/dns-helper/Chart.yaml @@ -0,0 +1,23 @@ +# Copyright 2017 The Openstack-Helm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v1 +description: OpenStack-Helm DNS Helper +name: dns-helper +version: 0.1.0 +home: http://openstack-helm.readthedocs.io +sources: + - https://git.openstack.org/cgit/openstack/openstack-helm +maintainers: + - name: OpenStack-Helm Authors diff --git a/dns-helper/requirements.yaml b/dns-helper/requirements.yaml new file mode 100644 index 0000000000..53782e69b2 --- /dev/null +++ b/dns-helper/requirements.yaml @@ -0,0 +1,18 @@ +# Copyright 2017 The Openstack-Helm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +dependencies: + - name: helm-toolkit + repository: http://localhost:8879/charts + version: 0.1.0 diff --git a/dns-helper/templates/bin/_dns-helper.sh.tpl b/dns-helper/templates/bin/_dns-helper.sh.tpl new file mode 100644 index 0000000000..e16b0250f6 --- /dev/null +++ b/dns-helper/templates/bin/_dns-helper.sh.tpl @@ -0,0 +1,20 @@ +#!/bin/bash + +# Copyright 2017 The Openstack-Helm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +cat /etc/resolv.conf > /host/etc/resolv.conf +tail -f /dev/null diff --git a/dns-helper/templates/configmap-bin.yaml b/dns-helper/templates/configmap-bin.yaml new file mode 100644 index 0000000000..8cd0bd51f5 --- /dev/null +++ b/dns-helper/templates/configmap-bin.yaml @@ -0,0 +1,23 @@ +# Copyright 2017 The Openstack-Helm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{{- $envAll := . }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: dns-helper-bin +data: + dns-helper.sh: | +{{ tuple "bin/_dns-helper.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} diff --git a/tools/gate/manifests/resolv-conf-util.yaml b/dns-helper/templates/daemonset-dns-helper.yaml similarity index 58% rename from tools/gate/manifests/resolv-conf-util.yaml rename to dns-helper/templates/daemonset-dns-helper.yaml index cde8d9b918..b512ae848d 100644 --- a/tools/gate/manifests/resolv-conf-util.yaml +++ b/dns-helper/templates/daemonset-dns-helper.yaml @@ -12,30 +12,38 @@ # See the License for the specific language governing permissions and # limitations under the License. +{{- $envAll := . }} +--- apiVersion: extensions/v1beta1 kind: DaemonSet metadata: - name: resolv-conf-util + name: dns-helper spec: template: metadata: labels: - version: v0.1.0 - name: resolv-conf-util +{{ tuple $envAll "dns" "helper" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} spec: + nodeSelector: + {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} containers: - - name: resolv-conf-util - image: docker.io/ubuntu:16.04 + - name: dns-helper + image: {{ .Values.images.dns_helper }} + imagePullPolicy: {{ .Values.images.pull_policy }} command: - - /bin/bash - - -ecx - - | - cat /etc/resolv.conf > /host/etc/resolv.conf - tail -f /dev/null + - /tmp/dns-helper.sh volumeMounts: - mountPath: /host/etc/resolv.conf name: host-resolv-conf + - name: dns-helper-bin + mountPath: /tmp/dns-helper.sh + subPath: dns-helper.sh + readOnly: true volumes: - name: host-resolv-conf hostPath: path: /etc/resolv.conf + - name: dns-helper-bin + configMap: + name: dns-helper-bin + defaultMode: 0555 diff --git a/dns-helper/values.yaml b/dns-helper/values.yaml new file mode 100644 index 0000000000..16c2a34447 --- /dev/null +++ b/dns-helper/values.yaml @@ -0,0 +1,26 @@ +# Copyright 2017 The Openstack-Helm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default values for cinder. +# This is a YAML-formatted file. +# Declare name/value pairs to be passed into your templates. +# name: value + +labels: + node_selector_key: openstack-control-plane + node_selector_value: enabled + +images: + dns_helper: docker.io/ubuntu:16.04 + pull_policy: "IfNotPresent" diff --git a/tools/gate/basic_launch.sh b/tools/gate/basic_launch.sh index 5e700a6727..711ea6a0e5 100755 --- a/tools/gate/basic_launch.sh +++ b/tools/gate/basic_launch.sh @@ -29,6 +29,9 @@ if [ "x$HOST_OS" == "xfedora" ]; then sudo modprobe ip6_tables fi +helm install --namespace=openstack ${WORK_DIR}/dns-helper --name=dns-helper +kube_wait_for_pods openstack 180 + if [ "x$PVC_BACKEND" == "xceph" ]; then kubectl label nodes ceph-storage=enabled --all CONTROLLER_MANAGER_POD=$(kubectl get -n kube-system pods -l component=kube-controller-manager --no-headers -o name | head -1 | awk -F '/' '{ print $NF }') diff --git a/tools/gate/funcs/network.sh b/tools/gate/funcs/network.sh index 1b1d0d9dfb..5a22b1e59c 100755 --- a/tools/gate/funcs/network.sh +++ b/tools/gate/funcs/network.sh @@ -15,17 +15,12 @@ set -e function net_resolv_pre_kube { sudo cp -f /etc/resolv.conf /etc/resolv-pre-kube.conf + sudo rm -f /etc/resolv.conf cat << EOF | sudo tee /etc/resolv.conf nameserver 8.8.8.8 EOF } -function net_resolv_kube { - kubectl get namespace openstack || kubectl create namespace openstack - kubectl create --namespace openstack -f ${WORK_DIR}/tools/gate/manifests/resolv-conf-util.yaml - kube_wait_for_pods openstack 240 -} - function net_resolv_post_kube { sudo cp -f /etc/resolv-pre-kube.conf /etc/resolv.conf } @@ -42,4 +37,3 @@ function net_hosts_pre_kube { function net_hosts_post_kube { sudo cp -f /etc/hosts-pre-kube /etc/hosts } - diff --git a/tools/gate/kubeadm_aio.sh b/tools/gate/kubeadm_aio.sh index b60d5900dd..03e738990e 100755 --- a/tools/gate/kubeadm_aio.sh +++ b/tools/gate/kubeadm_aio.sh @@ -25,4 +25,3 @@ if [ "x$PVC_BACKEND" == "xceph" ]; then fi kubeadm_aio_launch -net_resolv_kube