|
| 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: {} |
0 commit comments