Skip to content

Commit b620126

Browse files
author
Steven Hardy
authored
Merge pull request openshift#340 from celebdor/worker-mdns-publishing
mdns-publisher: remove master things
2 parents e792687 + 41e29a9 commit b620126

File tree

3 files changed

+111
-2
lines changed

3 files changed

+111
-2
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
kind: Pod
3+
apiVersion: v1
4+
metadata:
5+
name: mdns-publisher
6+
namespace: kni-infra
7+
creationTimestamp:
8+
deletionGracePeriodSeconds: 65
9+
labels:
10+
app: kni-infra-mdns
11+
spec:
12+
volumes:
13+
- name: resource-dir
14+
hostPath:
15+
path: "/etc/kubernetes/static-pod-resources/mdns"
16+
- name: kubeconfig
17+
hostPath:
18+
path: "/etc/kubernetes/kubeconfig"
19+
- name: get-vip-subnet-cidr
20+
hostPath:
21+
path: "/usr/local/bin/get_vip_subnet_cidr"
22+
- name: conf-dir
23+
empty-dir: {}
24+
initContainers:
25+
- name: clusterrc-generation
26+
image: quay.io/openshift-metalkube/kubeconfig-extractor:latest
27+
command:
28+
- "/usr/bin/kubeconfig-extractor"
29+
args:
30+
- "/etc/kubernetes/kubeconfig"
31+
- "/etc/kubernetes/static-pod-resources/clusterrc"
32+
resources: {}
33+
volumeMounts:
34+
- name: resource-dir
35+
mountPath: "/etc/kubernetes/static-pod-resources"
36+
- name: kubeconfig
37+
mountPath: "/etc/kubernetes/kubeconfig"
38+
- name: render-config
39+
image: quay.io/openshift/origin-node:latest
40+
command:
41+
- "/bin/bash"
42+
- "-c"
43+
- |
44+
#/bin/bash
45+
set -ex
46+
47+
source /etc/kubernetes/static-pod-resources/clusterrc
48+
CLUSTER_NAME="$NAME"
49+
API_VIP="$(dig +noall +answer "api.${DOMAIN}" | awk '{print $NF}')"
50+
IFACE_CIDRS="$(ip addr show | grep -v "scope host" | grep -Po 'inet \K[\d.]+/[\d.]+' | xargs)"
51+
SUBNET_CIDR="$(/usr/local/bin/get_vip_subnet_cidr "$API_VIP" "$IFACE_CIDRS")"
52+
PREFIX="${SUBNET_CIDR#*/}"
53+
DNS_VIP="$(dig +noall +answer "ns1.${DOMAIN}" | awk '{print $NF}')"
54+
ONE_CIDR="$(ip addr show to "$SUBNET_CIDR" | \
55+
grep -Po 'inet \K[\d.]+/[\d.]+' | \
56+
grep -v "${DNS_VIP}/$PREFIX" | \
57+
sort | xargs | cut -f1 -d' ')"
58+
59+
NON_VIRTUAL_IP="${ONE_CIDR%/*}"
60+
SHORT_HOSTNAME="$(hostname -s).local."
61+
62+
export SHORT_HOSTNAME
63+
export NON_VIRTUAL_IP
64+
export CLUSTER_NAME
65+
/usr/libexec/platform-python -c "from __future__ import print_function
66+
import os
67+
with open('/etc/kubernetes/static-pod-resources/config.template', 'r') as f:
68+
content = f.read()
69+
with open('/etc/mdns/config.hcl', 'w') as dest:
70+
print(os.path.expandvars(content), file=dest)"
71+
resources: {}
72+
volumeMounts:
73+
- name: resource-dir
74+
mountPath: "/etc/kubernetes/static-pod-resources"
75+
- name: conf-dir
76+
mountPath: "/etc/mdns"
77+
- name: get-vip-subnet-cidr
78+
mountPath: "/usr/local/bin/get_vip_subnet_cidr"
79+
imagePullPolicy: IfNotPresent
80+
containers:
81+
- name: mdns-publisher
82+
image: quay.io/openshift-metalkube/mdns-publisher:latest
83+
args:
84+
- "--debug"
85+
resources:
86+
requests:
87+
cpu: 150m
88+
memory: 1Gi
89+
volumeMounts:
90+
- name: conf-dir
91+
mountPath: "/etc/mdns"
92+
terminationMessagePolicy: FallbackToLogsOnError
93+
imagePullPolicy: IfNotPresent
94+
hostNetwork: true
95+
tolerations:
96+
- operator: Exists
97+
priorityClassName: system-node-critical
98+
status: {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
bind_address = "$NON_VIRTUAL_IP"
2+
collision_avoidance = "hostname"
3+
4+
service {
5+
name = "$CLUSTER_NAME Workstation"
6+
host_name = "$SHORT_HOSTNAME"
7+
type = "_workstation._tcp"
8+
domain = "local."
9+
port = 42424
10+
ttl = 3200
11+
}

assets/templates/99_worker-mdns-publisher.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ spec:
1515
verification: {}
1616
filesystem: root
1717
mode: 0664
18-
path: /etc/kubernetes/manifests/mdns-publisher.yaml
18+
path: /etc/kubernetes/manifests/mdns-publisher-worker.yaml
1919
- contents:
2020
verification: {}
2121
filesystem: root
2222
mode: 0664
23-
path: /etc/kubernetes/static-pod-resources/mdns/config.template
23+
path: /etc/kubernetes/static-pod-resources/mdns/worker-config.template

0 commit comments

Comments
 (0)