kube-proxy-and-dns.yaml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. kind: DaemonSet
  2. apiVersion: apps/v1
  3. metadata:
  4. name: proxy-and-dns
  5. namespace: kube-proxy-and-dns
  6. annotations:
  7. kubernetes.io/description: |
  8. This daemonset launches kube-proxy and DNS.
  9. image.openshift.io/triggers: |
  10. [
  11. {"from":{"kind":"ImageStreamTag","name":"node:v3.10"},"fieldPath":"spec.template.spec.containers[?(@.name==\"proxy-and-dns\")].image"}
  12. ]
  13. spec:
  14. selector:
  15. matchLabels:
  16. app: proxy-and-dns
  17. updateStrategy:
  18. type: RollingUpdate
  19. template:
  20. metadata:
  21. labels:
  22. app: proxy-and-dns
  23. component: network
  24. type: infra
  25. openshift.io/component: network
  26. annotations:
  27. scheduler.alpha.kubernetes.io/critical-pod: ''
  28. spec:
  29. # Requires fairly broad permissions - ability to read all services and network functions as well
  30. # as all pods.
  31. serviceAccountName: proxy
  32. hostNetwork: true
  33. hostPID: true
  34. containers:
  35. # The network container launches the kube-proxy and DNS.
  36. # It relies on an up to date node-config.yaml being present.
  37. - name: proxy-and-dns
  38. image: " "
  39. command:
  40. - /bin/bash
  41. - -c
  42. - |
  43. #!/bin/bash
  44. set -euo pipefail
  45. # if the node config doesn't exist yet, wait until it does
  46. retries=0
  47. while true; do
  48. if [[ ! -f /etc/origin/node/node-config.yaml ]]; then
  49. echo "warning: Cannot find existing node-config.yaml, waiting 15s ..." 2>&1
  50. sleep 15 & wait
  51. (( retries += 1 ))
  52. else
  53. break
  54. fi
  55. if [[ "${retries}" -gt 40 ]]; then
  56. echo "error: No existing node-config.yaml, exiting" 2>&1
  57. exit 1
  58. fi
  59. done
  60. if [[ -f /etc/sysconfig/origin-node ]]; then
  61. set -o allexport
  62. source /etc/sysconfig/origin-node
  63. fi
  64. # use either the bootstrapped node kubeconfig or the static configuration
  65. file=/etc/origin/node/node.kubeconfig
  66. if [[ ! -f "${file}" ]]; then
  67. # use the static node config if it exists
  68. # TODO: remove when static node configuration is no longer supported
  69. for f in /etc/origin/node/system*.kubeconfig; do
  70. echo "info: Using ${f} for node configuration" 1>&2
  71. file="${f}"
  72. break
  73. done
  74. fi
  75. # Use the same config as the node, but with the service account token
  76. oc config "--config=${file}" view --flatten > /tmp/kubeconfig
  77. oc config --config=/tmp/kubeconfig set-credentials sa "--token=$( cat /var/run/secrets/kubernetes.io/serviceaccount/token )"
  78. oc config --config=/tmp/kubeconfig set-context "$( oc config --config=/tmp/kubeconfig current-context )" --user=sa
  79. # Launch the kube-proxy and DNS process
  80. exec openshift start network --disable=plugins --enable=proxy,dns --config=/etc/origin/node/node-config.yaml --kubeconfig=/tmp/kubeconfig --loglevel=${DEBUG_LOGLEVEL:-2}
  81. securityContext:
  82. runAsUser: 0
  83. # Permission could be reduced by selecting an appropriate SELinux policy
  84. privileged: true
  85. volumeMounts:
  86. # Directory which contains the host configuration.
  87. - mountPath: /etc/origin/node/
  88. name: host-config
  89. readOnly: true
  90. - mountPath: /etc/sysconfig/origin-node
  91. name: host-sysconfig-node
  92. readOnly: true
  93. # Mount the entire run directory for iptables lockfile access
  94. # TODO: remove
  95. - mountPath: /var/run
  96. name: host-var-run
  97. # Run directories where we need to be able to access sockets
  98. - mountPath: /var/run/dbus/
  99. name: host-var-run-dbus
  100. readOnly: true
  101. - mountPath: /var/run/kubernetes/
  102. name: host-var-run-kubernetes
  103. readOnly: true
  104. resources:
  105. requests:
  106. cpu: 100m
  107. memory: 200Mi
  108. env:
  109. - name: OPENSHIFT_DNS_DOMAIN
  110. value: cluster.local
  111. ports:
  112. - name: healthz
  113. containerPort: 10256
  114. # TODO: Temporarily disabled until we determine how to wait for clean default
  115. # config
  116. # livenessProbe:
  117. # initialDelaySeconds: 10
  118. # httpGet:
  119. # path: /healthz
  120. # port: 10256
  121. # scheme: HTTP
  122. lifecycle:
  123. volumes:
  124. # In bootstrap mode, the host config contains information not easily available
  125. # from other locations.
  126. - name: host-config
  127. hostPath:
  128. path: /etc/origin/node
  129. - name: host-sysconfig-node
  130. hostPath:
  131. path: /etc/sysconfig/origin-node
  132. - name: host-modules
  133. hostPath:
  134. path: /lib/modules
  135. - name: host-var-run
  136. hostPath:
  137. path: /var/run
  138. - name: host-var-run-dbus
  139. hostPath:
  140. path: /var/run/dbus
  141. - name: host-var-run-kubernetes
  142. hostPath:
  143. path: /var/run/kubernetes