Skip to content

Commit

Permalink
Merge pull request openshift#340 from celebdor/worker-mdns-publishing
Browse files Browse the repository at this point in the history
mdns-publisher: remove master things
  • Loading branch information
Steven Hardy authored Apr 11, 2019
2 parents e792687 + 41e29a9 commit b620126
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 2 deletions.
98 changes: 98 additions & 0 deletions assets/files/etc/kubernetes/manifests/mdns-publisher-worker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
kind: Pod
apiVersion: v1
metadata:
name: mdns-publisher
namespace: kni-infra
creationTimestamp:
deletionGracePeriodSeconds: 65
labels:
app: kni-infra-mdns
spec:
volumes:
- name: resource-dir
hostPath:
path: "/etc/kubernetes/static-pod-resources/mdns"
- name: kubeconfig
hostPath:
path: "/etc/kubernetes/kubeconfig"
- name: get-vip-subnet-cidr
hostPath:
path: "/usr/local/bin/get_vip_subnet_cidr"
- name: conf-dir
empty-dir: {}
initContainers:
- name: clusterrc-generation
image: quay.io/openshift-metalkube/kubeconfig-extractor:latest
command:
- "/usr/bin/kubeconfig-extractor"
args:
- "/etc/kubernetes/kubeconfig"
- "/etc/kubernetes/static-pod-resources/clusterrc"
resources: {}
volumeMounts:
- name: resource-dir
mountPath: "/etc/kubernetes/static-pod-resources"
- name: kubeconfig
mountPath: "/etc/kubernetes/kubeconfig"
- name: render-config
image: quay.io/openshift/origin-node:latest
command:
- "/bin/bash"
- "-c"
- |
#/bin/bash
set -ex
source /etc/kubernetes/static-pod-resources/clusterrc
CLUSTER_NAME="$NAME"
API_VIP="$(dig +noall +answer "api.${DOMAIN}" | awk '{print $NF}')"
IFACE_CIDRS="$(ip addr show | grep -v "scope host" | grep -Po 'inet \K[\d.]+/[\d.]+' | xargs)"
SUBNET_CIDR="$(/usr/local/bin/get_vip_subnet_cidr "$API_VIP" "$IFACE_CIDRS")"
PREFIX="${SUBNET_CIDR#*/}"
DNS_VIP="$(dig +noall +answer "ns1.${DOMAIN}" | awk '{print $NF}')"
ONE_CIDR="$(ip addr show to "$SUBNET_CIDR" | \
grep -Po 'inet \K[\d.]+/[\d.]+' | \
grep -v "${DNS_VIP}/$PREFIX" | \
sort | xargs | cut -f1 -d' ')"
NON_VIRTUAL_IP="${ONE_CIDR%/*}"
SHORT_HOSTNAME="$(hostname -s).local."
export SHORT_HOSTNAME
export NON_VIRTUAL_IP
export CLUSTER_NAME
/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"
- name: get-vip-subnet-cidr
mountPath: "/usr/local/bin/get_vip_subnet_cidr"
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: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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
}
4 changes: 2 additions & 2 deletions assets/templates/99_worker-mdns-publisher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ spec:
verification: {}
filesystem: root
mode: 0664
path: /etc/kubernetes/manifests/mdns-publisher.yaml
path: /etc/kubernetes/manifests/mdns-publisher-worker.yaml
- contents:
verification: {}
filesystem: root
mode: 0664
path: /etc/kubernetes/static-pod-resources/mdns/config.template
path: /etc/kubernetes/static-pod-resources/mdns/worker-config.template

0 comments on commit b620126

Please sign in to comment.