diff --git a/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-NetworkManager-conf.d-dhcp-client.conf b/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-NetworkManager-conf.d-dhcp-client.conf new file mode 100644 index 0000000000..444b415c3b --- /dev/null +++ b/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-NetworkManager-conf.d-dhcp-client.conf @@ -0,0 +1,6 @@ +contents: + source: data:,%5Bmain%5D%0Adhcp%3Ddhclient%0A + verification: {} +filesystem: root +mode: 420 +path: /etc/NetworkManager/conf.d/dhcp-client.conf diff --git a/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-dhcp-dhclient.conf b/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-dhcp-dhclient.conf new file mode 100644 index 0000000000..afc39359fc --- /dev/null +++ b/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-dhcp-dhclient.conf @@ -0,0 +1,6 @@ +contents: + source: data:,send%20dhcp-client-identifier%20%3D%20hardware%3B%0Aprepend%20domain-name-servers%20127.0.0.1%3B%0A + verification: {} +filesystem: root +mode: 420 +path: /etc/dhcp/dhclient.conf diff --git a/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-kubernetes-manifests-coredns.yaml b/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-kubernetes-manifests-coredns.yaml new file mode 100644 index 0000000000..fd1617d7d7 --- /dev/null +++ b/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-kubernetes-manifests-coredns.yaml @@ -0,0 +1,6 @@ +contents: + source: data:,kind%3A%20Pod%0AapiVersion%3A%20v1%0Ametadata%3A%0A%20%20name%3A%20coredns%0A%20%20namespace%3A%20kube-system%0A%20%20creationTimestamp%3A%0A%20%20deletionGracePeriodSeconds%3A%2065%0A%20%20labels%3A%0A%20%20%20%20app%3A%20kni-infra-mdns%0Aspec%3A%0A%20%20volumes%3A%0A%20%20-%20name%3A%20conf-dir%0A%20%20%20%20hostPath%3A%0A%20%20%20%20%20%20path%3A%20%22%2Fetc%2Fkubernetes%2Fstatic-pod-resources%2Fcoredns%22%0A%20%20containers%3A%0A%20%20-%20name%3A%20coredns%0A%20%20%20%20securityContext%3A%0A%20%20%20%20%20%20privileged%3A%20true%0A%20%20%20%20image%3A%20quay.io%2Fopenshift-metalkube%2Fcoredns-mdns%3Alatest%0A%20%20%20%20args%3A%0A%20%20%20%20-%20%22--conf%22%0A%20%20%20%20-%20%22%2Fetc%2Fcoredns%2FCorefile%22%0A%20%20%20%20resources%3A%0A%20%20%20%20%20%20requests%3A%0A%20%20%20%20%20%20%20%20cpu%3A%20150m%0A%20%20%20%20%20%20%20%20memory%3A%201Gi%0A%20%20%20%20volumeMounts%3A%0A%20%20%20%20-%20name%3A%20conf-dir%0A%20%20%20%20%20%20mountPath%3A%20%22%2Fetc%2Fcoredns%22%0A%20%20%20%20terminationMessagePolicy%3A%20FallbackToLogsOnError%0A%20%20%20%20imagePullPolicy%3A%20IfNotPresent%0A%20%20hostNetwork%3A%20true%0A%20%20tolerations%3A%0A%20%20-%20operator%3A%20Exists%0A%20%20priorityClassName%3A%20system-node-critical%0Astatus%3A%20%7B%7D%0A + verification: {} +filesystem: root +mode: 420 +path: /etc/kubernetes/manifests/coredns.yaml diff --git a/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-kubernetes-manifests-mdns-publisher.yaml b/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-kubernetes-manifests-mdns-publisher.yaml new file mode 100644 index 0000000000..2419b8bcab --- /dev/null +++ b/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-kubernetes-manifests-mdns-publisher.yaml @@ -0,0 +1,6 @@ +contents: + source: data:,kind%3A%20Pod%0AapiVersion%3A%20v1%0Ametadata%3A%0A%20%20name%3A%20mdns-publisher%0A%20%20namespace%3A%20kube-system%0A%20%20creationTimestamp%3A%0A%20%20deletionGracePeriodSeconds%3A%2065%0A%20%20labels%3A%0A%20%20%20%20app%3A%20kni-infra-mdns%0Aspec%3A%0A%20%20volumes%3A%0A%20%20-%20name%3A%20resource-dir%0A%20%20%20%20hostPath%3A%0A%20%20%20%20%20%20path%3A%20%22%2Fetc%2Fkubernetes%2Fstatic-pod-resources%2Fmdns%22%0A%20%20-%20name%3A%20conf-dir%0A%20%20%20%20hostPath%3A%0A%20%20%20%20%20%20path%3A%20%22%2Fetc%2Fkubernetes%2Fstatic-pod-resources%2Fmdns%22%0A%20%20initContainers%3A%0A%20%20-%20name%3A%20render-config%0A%20%20%20%20image%3A%20quay.io%2Fopenshift%2Forigin-node%3Alatest%0A%20%20%20%20command%3A%0A%20%20%20%20-%20%22%2Fbin%2Fbash%22%0A%20%20%20%20-%20%22-c%22%0A%20%20%20%20-%20%7C%0A%20%20%20%20%20%20%23%2Fbin%2Fbash%0A%20%20%20%20%20%20set%20-ex%0A%0A%20%20%20%20%20%20CLUSTER_NAME%3Dmy-test-cluster%0A%20%20%20%20%20%20DOMAIN%3Dmy-test-cluster.installer.team.coreos.systems%0A%20%20%20%20%20%20API_VIP%3D%22%24(dig%20%2Bnoall%20%2Banswer%20%22api.%24%7BDOMAIN%7D%22%20%7C%20awk%20'%7Bprint%20%24NF%7D')%22%0A%20%20%20%20%20%20SUBNET_CIDR%3D%22%24(ip%20addr%20show%20%7C%20grep%20-v%20%22scope%20host%22%20%7C%20grep%20-Po%20'inet%20%5CK%5B%5Cd.%5D%2B%2F%5B%5Cd.%5D%2B'%20%7C%20head%20-n1)%22%0A%20%20%20%20%20%20PREFIX%3D%22%24%7BSUBNET_CIDR%23*%2F%7D%22%0A%20%20%20%20%20%20NON_VIRTUAL_IP%3D%22%24%7BSUBNET_CIDR%25%2F*%7D%22%0A%20%20%20%20%20%20MASTER_HOSTNAME%3D%22%24(hostname%20-s%20%7C%20cut%20-d%20'-'%20-f%204)-%24(hostname%20-s%20%7C%20cut%20-d%20'-'%20-f%205).local.%22%0A%20%20%20%20%20%20ETCD_HOSTNAME%3D%22%24(echo%20%22%24MASTER_HOSTNAME%22%20%7C%20sed%20's%3Bmaster%3Betcd%3B')%22%0A%20%20%20%20%20%20export%20MASTER_HOSTNAME%0A%20%20%20%20%20%20export%20ETCD_HOSTNAME%0A%20%20%20%20%20%20export%20NON_VIRTUAL_IP%0A%20%20%20%20%20%20export%20DOMAIN%0A%20%20%20%20%20%20export%20CLUSTER_NAME%0A%20%20%20%20%20%20%2Fusr%2Flibexec%2Fplatform-python%20-c%20%22from%20__future__%20import%20print_function%0A%20%20%20%20%20%20import%20os%0A%20%20%20%20%20%20with%20open('%2Fetc%2Fkubernetes%2Fstatic-pod-resources%2Fconfig.template'%2C%20'r')%20as%20f%3A%0A%20%20%20%20%20%20%20%20%20%20content%20%3D%20f.read()%0A%20%20%20%20%20%20with%20open('%2Fetc%2Fmdns%2Fconfig.hcl'%2C%20'w')%20as%20dest%3A%0A%20%20%20%20%20%20%20%20%20%20print(os.path.expandvars(content)%2C%20file%3Ddest)%22%0A%20%20%20%20resources%3A%20%7B%7D%0A%20%20%20%20volumeMounts%3A%0A%20%20%20%20-%20name%3A%20resource-dir%0A%20%20%20%20%20%20mountPath%3A%20%22%2Fetc%2Fkubernetes%2Fstatic-pod-resources%22%0A%20%20%20%20-%20name%3A%20conf-dir%0A%20%20%20%20%20%20mountPath%3A%20%22%2Fetc%2Fmdns%22%0A%20%20%20%20imagePullPolicy%3A%20IfNotPresent%0A%20%20containers%3A%0A%20%20-%20name%3A%20mdns-publisher%0A%20%20%20%20image%3A%20quay.io%2Fopenshift-metalkube%2Fmdns-publisher%3Alatest%0A%20%20%20%20args%3A%0A%20%20%20%20-%20%22--debug%22%0A%20%20%20%20resources%3A%0A%20%20%20%20%20%20requests%3A%0A%20%20%20%20%20%20%20%20cpu%3A%20150m%0A%20%20%20%20%20%20%20%20memory%3A%201Gi%0A%20%20%20%20volumeMounts%3A%0A%20%20%20%20-%20name%3A%20conf-dir%0A%20%20%20%20%20%20mountPath%3A%20%22%2Fetc%2Fmdns%22%0A%20%20%20%20terminationMessagePolicy%3A%20FallbackToLogsOnError%0A%20%20%20%20imagePullPolicy%3A%20IfNotPresent%0A%20%20hostNetwork%3A%20true%0A%20%20tolerations%3A%0A%20%20-%20operator%3A%20Exists%0A%20%20priorityClassName%3A%20system-node-critical%0Astatus%3A%20%7B%7D%0A + verification: {} +filesystem: root +mode: 420 +path: /etc/kubernetes/manifests/mdns-publisher.yaml diff --git a/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-kubernetes-static-pod-resources-coredns-Corefile b/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-kubernetes-static-pod-resources-coredns-Corefile new file mode 100644 index 0000000000..64fb3af422 --- /dev/null +++ b/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-kubernetes-static-pod-resources-coredns-Corefile @@ -0,0 +1,6 @@ +contents: + source: data:,.%20%7B%0A%20%20%20%20log%0A%20%20%20%20mdns%20my-test-cluster.installer.team.coreos.systems%203%20my-test-cluster%0A%20%20%20%20cache%2030%0A%20%20%20%20reload%0A%20%20%20%20forward%20.%20%2Fetc%2Fresolv.conf%20%7B%0A%20%20%20%20%20%20%20%20except%20my-test-cluster.installer.team.coreos.systems%0A%20%20%20%20%7D%0A%7D%0A + verification: {} +filesystem: root +mode: 420 +path: /etc/kubernetes/static-pod-resources/coredns/Corefile diff --git a/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-kubernetes-static-pod-resources-mdns-config.template b/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-kubernetes-static-pod-resources-mdns-config.template new file mode 100644 index 0000000000..ce357d4406 --- /dev/null +++ b/pkg/controller/template/test_data/templates/master/00-master/openstack/files/-etc-kubernetes-static-pod-resources-mdns-config.template @@ -0,0 +1,6 @@ +contents: + source: data:,bind_address%20%3D%20%22%24NON_VIRTUAL_IP%22%0Acollision_avoidance%20%3D%20%22hostname%22%0A%0Aservice%20%7B%0A%20%20%20%20name%20%3D%20%22%24CLUSTER_NAME%20Etcd%22%0A%20%20%20%20host_name%20%3D%20%22%24ETCD_HOSTNAME%22%0A%20%20%20%20type%20%3D%20%22_etcd-server-ssl._tcp%22%0A%20%20%20%20domain%20%3D%20%22local.%22%0A%20%20%20%20port%20%3D%202380%0A%20%20%20%20ttl%20%3D%203200%0A%7D%0A%0Aservice%20%7B%0A%20%20%20%20name%20%3D%20%22%24CLUSTER_NAME%20Workstation%22%0A%20%20%20%20host_name%20%3D%20%22%24MASTER_HOSTNAME%22%0A%20%20%20%20type%20%3D%20%22_workstation._tcp%22%0A%20%20%20%20domain%20%3D%20%22local.%22%0A%20%20%20%20port%20%3D%2042424%0A%20%20%20%20ttl%20%3D%203200%0A%7D%0A%0Aservice%20%7B%0A%20%20%20%20name%20%3D%20%22%24CLUSTER_NAME%20EtcdWorkstation%22%0A%20%20%20%20host_name%20%3D%20%22%24ETCD_HOSTNAME%22%0A%20%20%20%20type%20%3D%20%22_workstation._tcp%22%0A%20%20%20%20domain%20%3D%20%22local.%22%0A%20%20%20%20port%20%3D%2042424%0A%20%20%20%20ttl%20%3D%20300%0A%7D%0A + verification: {} +filesystem: root +mode: 420 +path: /etc/kubernetes/static-pod-resources/mdns/config.template diff --git a/templates/master/00-master/openstack/files/NetworkManager-dhcp-client-conf.yaml b/templates/master/00-master/openstack/files/NetworkManager-dhcp-client-conf.yaml new file mode 100644 index 0000000000..766ea681f3 --- /dev/null +++ b/templates/master/00-master/openstack/files/NetworkManager-dhcp-client-conf.yaml @@ -0,0 +1,7 @@ +filesystem: "root" +mode: 0644 +path: "/etc/NetworkManager/conf.d/dhcp-client.conf" +contents: + inline: | + [main] + dhcp=dhclient diff --git a/templates/master/00-master/openstack/files/dhcp-dhclient-conf.yaml b/templates/master/00-master/openstack/files/dhcp-dhclient-conf.yaml new file mode 100644 index 0000000000..6b83ac586a --- /dev/null +++ b/templates/master/00-master/openstack/files/dhcp-dhclient-conf.yaml @@ -0,0 +1,7 @@ +filesystem: "root" +mode: 0644 +path: "/etc/dhcp/dhclient.conf" +contents: + inline: | + send dhcp-client-identifier = hardware; + prepend domain-name-servers 127.0.0.1; diff --git a/templates/master/00-master/openstack/files/openstack-coredns-corefile.yaml b/templates/master/00-master/openstack/files/openstack-coredns-corefile.yaml new file mode 100644 index 0000000000..f2280dc147 --- /dev/null +++ b/templates/master/00-master/openstack/files/openstack-coredns-corefile.yaml @@ -0,0 +1,23 @@ +filesystem: "root" +mode: 0644 +path: "/etc/kubernetes/static-pod-resources/coredns/Corefile" +contents: + inline: | + . { + log + errors + + forward . 8.8.8.8 { + except {{.EtcdDiscoveryDomain}} + } + } + + {{.EtcdDiscoveryDomain}} { + log + mdns {{.EtcdDiscoveryDomain}} 3 {{(split "." .EtcdDiscoveryDomain)._0}} + cache 30 + reload 3s + loadbalance round_robin + file /etc/coredns/coredns.db { + } + } diff --git a/templates/master/00-master/openstack/files/openstack-coredns-db.yaml b/templates/master/00-master/openstack/files/openstack-coredns-db.yaml new file mode 100644 index 0000000000..599651a41a --- /dev/null +++ b/templates/master/00-master/openstack/files/openstack-coredns-db.yaml @@ -0,0 +1,23 @@ +filesystem: "root" +mode: 0644 +path: "/etc/kubernetes/static-pod-resources/coredns/coredns.db.template" +contents: + inline: | + $ORIGIN {{.EtcdDiscoveryDomain}}. + @ 3600 IN SOA host.{{.EtcdDiscoveryDomain}}. hostmaster ( + 2 ; serial + 7200 ; refresh (2 hours) + 3600 ; retry (1 hour) + 1209600 ; expire (2 weeks) + 3600 ; minimum (1 hour) + ) + + api IN A $FLOATING_IP + + *.apps IN A $MASTER_FIXED_IPS_0 + *.apps IN A $MASTER_FIXED_IPS_1 + *.apps IN A $MASTER_FIXED_IPS_2 + + api-int IN A $MASTER_FIXED_IPS_0 + api-int IN A $MASTER_FIXED_IPS_1 + api-int IN A $MASTER_FIXED_IPS_2 diff --git a/templates/master/00-master/openstack/files/openstack-coredns.yaml b/templates/master/00-master/openstack/files/openstack-coredns.yaml new file mode 100644 index 0000000000..a6afd7c522 --- /dev/null +++ b/templates/master/00-master/openstack/files/openstack-coredns.yaml @@ -0,0 +1,116 @@ +filesystem: "root" +mode: 0644 +path: "/etc/kubernetes/manifests/coredns.yaml" +contents: + inline: | + kind: Pod + apiVersion: v1 + metadata: + name: coredns + namespace: kube-system + creationTimestamp: + deletionGracePeriodSeconds: 65 + labels: + app: kni-infra-mdns + spec: + volumes: + - name: conf-dir + hostPath: + path: "/etc/kubernetes/static-pod-resources/coredns" + - name: var-dir + hostPath: + path: "/etc/kubernetes/static-pod-resources" + - name: chroot-host + hostPath: + path: "/" + - name: kublet + hostPath: + path: "/var/lib/kubelet" + initContainers: + - name: dns-render-config + image: quay.io/openshift/origin-node:latest + command: + - "/bin/bash" + - "-c" + - | + #/bin/bash + set -ex + source /tmp/clustervars + + /usr/libexec/platform-python -c "from __future__ import print_function + import os + with open('/etc/coredns/coredns.db.template', 'r') as f: + content = f.read() + with open('/etc/coredns/coredns.db', 'w') as dest: + print(os.path.expandvars(content), file=dest)" + resources: {} + volumeMounts: + - name: conf-dir + mountPath: "/etc/coredns" + - name: var-dir + mountPath: "/tmp" + imagePullPolicy: IfNotPresent + containers: + - name: coredns + securityContext: + privileged: true + image: quay.io/openshift-metalkube/coredns-mdns:latest + args: + - "--conf" + - "/etc/coredns/Corefile" + resources: + requests: + cpu: 150m + memory: 1Gi + volumeMounts: + - name: conf-dir + mountPath: "/etc/coredns" + terminationMessagePolicy: FallbackToLogsOnError + imagePullPolicy: IfNotPresent + - name: machine-watcher + image: quay.io/openshift/origin-node:latest + command: + - "/bin/bash" + - "-c" + - | + #/bin/bash + set -e + + while true; do + masters=$(/host/bin/oc get machines -n openshift-machine-api --config /var/lib/kubelet/kubeconfig | grep -o "{{.EtcdDiscoveryDomain}}-master-[0-9]\+" || true) + workers=$(/host/bin/oc get machines -n openshift-machine-api --config /var/lib/kubelet/kubeconfig | grep -o "{{.EtcdDiscoveryDomain}}-worker-[0-9A-Za-z]\+" || true) + nodes="$masters $workers" + + if [ -n "$nodes" ]; then + for node in $nodes; do + ip=$(/host/bin/oc describe machine -n openshift-machine-api $node --config /var/lib/kubelet/kubeconfig | grep "address" | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' || true) + + # If there is an entry for the node, replace it with what is in the machines.yaml, ortherwise create an entry + if [ -n "$ip" ] && [ -z "$(cat /etc/coredns/coredns.db | grep -w $node)" ]; then + echo "$node IN A $ip" + echo "$node IN A $ip" >> /etc/coredns/coredns.db + else + sed -i "0,/$node.*/s//$node IN A $ip/" /etc/coredns/coredns.db + fi + done + fi + + sleep 1 + done + resources: {} + volumeMounts: + - name: conf-dir + mountPath: "/etc/coredns" + - name: var-dir + mountPath: "/tmp" + - name: chroot-host + mountPath: "/host" + - name: kublet + mountPath: "/var/lib/kubelet" + imagePullPolicy: IfNotPresent + terminationMessagePolicy: FallbackToLogsOnError + hostNetwork: true + tolerations: + - operator: Exists + priorityClassName: system-node-critical + status: {} diff --git a/templates/master/00-master/openstack/files/openstack-mdns-config.yaml b/templates/master/00-master/openstack/files/openstack-mdns-config.yaml new file mode 100644 index 0000000000..570dd4d500 --- /dev/null +++ b/templates/master/00-master/openstack/files/openstack-mdns-config.yaml @@ -0,0 +1,34 @@ +filesystem: "root" +mode: 0644 +path: "/etc/kubernetes/static-pod-resources/mdns/config.template" +contents: + inline: | + bind_address = "$NON_VIRTUAL_IP" + collision_avoidance = "hostname" + + service { + name = "$CLUSTER_NAME Etcd" + host_name = "$ETCD_HOSTNAME" + type = "_etcd-server-ssl._tcp" + domain = "local." + port = 2380 + ttl = 3200 + } + + service { + name = "$CLUSTER_NAME Workstation" + host_name = "$MASTER_HOSTNAME" + type = "_workstation._tcp" + domain = "local." + port = 42424 + ttl = 3200 + } + + service { + name = "$CLUSTER_NAME EtcdWorkstation" + host_name = "$ETCD_HOSTNAME" + type = "_workstation._tcp" + domain = "local." + port = 42424 + ttl = 300 + } diff --git a/templates/master/00-master/openstack/files/openstack-mdns-publisher.yaml b/templates/master/00-master/openstack/files/openstack-mdns-publisher.yaml new file mode 100644 index 0000000000..4a2e5c4b9d --- /dev/null +++ b/templates/master/00-master/openstack/files/openstack-mdns-publisher.yaml @@ -0,0 +1,77 @@ +filesystem: "root" +mode: 0644 +path: "/etc/kubernetes/manifests/mdns-publisher.yaml" +contents: + inline: | + kind: Pod + apiVersion: v1 + metadata: + name: mdns-publisher + namespace: kube-system + creationTimestamp: + deletionGracePeriodSeconds: 65 + labels: + app: kni-infra-mdns + spec: + volumes: + - name: resource-dir + hostPath: + path: "/etc/kubernetes/static-pod-resources/mdns" + - name: conf-dir + hostPath: + path: "/etc/kubernetes/static-pod-resources/mdns" + initContainers: + - name: render-config + image: quay.io/openshift/origin-node:latest + command: + - "/bin/bash" + - "-c" + - | + #/bin/bash + set -ex + + export CLUSTER_NAME={{(split "." .EtcdDiscoveryDomain)._0}} + export DOMAIN={{.EtcdDiscoveryDomain}} + + #TODO(trown): find a better way to get the host's IP and HOSTNAME + API_VIP="$(dig +noall +answer "api.${DOMAIN}" | awk '{print $NF}')" + SUBNET_CIDR="$(ip addr show | grep -v "scope host" | grep -Po 'inet \K[\d.]+/[\d.]+' | head -n1)" + PREFIX="${SUBNET_CIDR#*/}" + export NON_VIRTUAL_IP="${SUBNET_CIDR%/*}" + + HOST_NUM="$(hostname -s | grep -o '[0-9]\+$')" + export MASTER_HOSTNAME="master-$HOST_NUM.local." + export ETCD_HOSTNAME="etcd-$HOST_NUM.local." + + /usr/libexec/platform-python -c "from __future__ import print_function + import os + with open('/etc/kubernetes/static-pod-resources/config.template', 'r') as f: + content = f.read() + with open('/etc/mdns/config.hcl', 'w') as dest: + print(os.path.expandvars(content), file=dest)" + resources: {} + volumeMounts: + - name: resource-dir + mountPath: "/etc/kubernetes/static-pod-resources" + - name: conf-dir + mountPath: "/etc/mdns" + imagePullPolicy: IfNotPresent + containers: + - name: mdns-publisher + image: quay.io/openshift-metalkube/mdns-publisher:latest + args: + - "--debug" + resources: + requests: + cpu: 150m + memory: 1Gi + volumeMounts: + - name: conf-dir + mountPath: "/etc/mdns" + terminationMessagePolicy: FallbackToLogsOnError + imagePullPolicy: IfNotPresent + hostNetwork: true + tolerations: + - operator: Exists + priorityClassName: system-node-critical + status: {} diff --git a/templates/worker/00-worker/openstack/files/openstack-mdns-config.yaml b/templates/worker/00-worker/openstack/files/openstack-mdns-config.yaml new file mode 100644 index 0000000000..89ae7ba397 --- /dev/null +++ b/templates/worker/00-worker/openstack/files/openstack-mdns-config.yaml @@ -0,0 +1,17 @@ +filesystem: "root" +mode: 0644 +path: "/etc/kubernetes/static-pod-resources/mdns/config.template" +contents: + inline: | + + bind_address = "$NON_VIRTUAL_IP" + collision_avoidance = "hostname" + + service { + name = "$CLUSTER_NAME Workstation" + host_name = "$SHORT_HOSTNAME" + type = "_workstation._tcp" + domain = "local." + port = 42424 + ttl = 3200 + } diff --git a/templates/worker/00-worker/openstack/files/openstack-mdns-publisher.yaml b/templates/worker/00-worker/openstack/files/openstack-mdns-publisher.yaml new file mode 100644 index 0000000000..31fe4ff646 --- /dev/null +++ b/templates/worker/00-worker/openstack/files/openstack-mdns-publisher.yaml @@ -0,0 +1,73 @@ +filesystem: "root" +mode: 0644 +path: "/etc/kubernetes/manifests/mdns-publisher.yaml" +contents: + inline: | + kind: Pod + apiVersion: v1 + metadata: + name: mdns-publisher + namespace: kube-system + creationTimestamp: + deletionGracePeriodSeconds: 65 + labels: + app: kni-infra-mdns + spec: + volumes: + - name: resource-dir + hostPath: + path: "/etc/kubernetes/static-pod-resources/mdns" + - name: conf-dir + hostPath: + path: "/etc/kubernetes/static-pod-resources/mdns" + initContainers: + - name: render-config + image: quay.io/openshift/origin-node:latest + command: + - "/bin/bash" + - "-c" + - | + #/bin/bash + set -ex + + export CLUSTER_NAME={{(split "." .EtcdDiscoveryDomain)._0}} + + #TODO(trown): find a better way to get the host's IP and HOSTNAME + SUBNET_CIDR="$(ip addr show | grep -v "scope host" | grep -Po 'inet \K[\d.]+/[\d.]+' | head -n1)" + PREFIX="${SUBNET_CIDR#*/}" + export NON_VIRTUAL_IP="${SUBNET_CIDR%/*}" + + export SHORT_HOSTNAME="$(hostname -s).local." + + /usr/libexec/platform-python -c "from __future__ import print_function + import os + with open('/etc/kubernetes/static-pod-resources/config.template', 'r') as f: + content = f.read() + with open('/etc/mdns/config.hcl', 'w') as dest: + print(os.path.expandvars(content), file=dest)" + resources: {} + volumeMounts: + - name: resource-dir + mountPath: "/etc/kubernetes/static-pod-resources" + - name: conf-dir + mountPath: "/etc/mdns" + imagePullPolicy: IfNotPresent + containers: + - name: mdns-publisher + image: quay.io/openshift-metalkube/mdns-publisher:latest + args: + - "--debug" + resources: + requests: + cpu: 150m + memory: 1Gi + volumeMounts: + - name: conf-dir + mountPath: "/etc/mdns" + terminationMessagePolicy: FallbackToLogsOnError + imagePullPolicy: IfNotPresent + hostNetwork: true + tolerations: + - operator: Exists + priorityClassName: system-node-critical + status: {}