sdn.yaml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. kind: DaemonSet
  2. apiVersion: apps/v1
  3. metadata:
  4. name: sdn
  5. namespace: openshift-sdn
  6. annotations:
  7. kubernetes.io/description: |
  8. This daemon set launches the OpenShift networking components (kube-proxy, DNS, and openshift-sdn).
  9. It expects that OVS is running on the node.
  10. image.openshift.io/triggers: |
  11. [
  12. {"from":{"kind":"ImageStreamTag","name":"node:v3.11"},"fieldPath":"spec.template.spec.containers[?(@.name==\"sdn\")].image"}
  13. ]
  14. spec:
  15. selector:
  16. matchLabels:
  17. app: sdn
  18. updateStrategy:
  19. type: RollingUpdate
  20. template:
  21. metadata:
  22. labels:
  23. app: sdn
  24. component: network
  25. type: infra
  26. openshift.io/component: network
  27. annotations:
  28. scheduler.alpha.kubernetes.io/critical-pod: ''
  29. spec:
  30. # Requires fairly broad permissions - ability to read all services and network functions as well
  31. # as all pods.
  32. serviceAccountName: sdn
  33. hostNetwork: true
  34. hostPID: true
  35. priorityClassName: system-node-critical
  36. containers:
  37. # The network container launches the openshift-sdn process, the kube-proxy, and the local DNS service.
  38. # It relies on an up to date node-config.yaml being present.
  39. - name: sdn
  40. image: " "
  41. command:
  42. - /bin/bash
  43. - -c
  44. - |
  45. #!/bin/bash
  46. set -euo pipefail
  47. # if another process is listening on the cni-server socket, wait until it exits
  48. trap 'kill $(jobs -p); exit 0' TERM
  49. retries=0
  50. while true; do
  51. if echo 'test' | socat - UNIX-CONNECT:/var/run/openshift-sdn/cni-server.sock >/dev/null; then
  52. echo "warning: Another process is currently listening on the CNI socket, waiting 15s ..." 2>&1
  53. sleep 15 & wait
  54. (( retries += 1 ))
  55. else
  56. break
  57. fi
  58. if [[ "${retries}" -gt 40 ]]; then
  59. echo "error: Another process is currently listening on the CNI socket, exiting" 2>&1
  60. exit 1
  61. fi
  62. done
  63. # if the node config doesn't exist yet, wait until it does
  64. retries=0
  65. while true; do
  66. if [[ ! -f /etc/origin/node/node-config.yaml ]]; then
  67. echo "warning: Cannot find existing node-config.yaml, waiting 15s ..." 2>&1
  68. sleep 15 & wait
  69. (( retries += 1 ))
  70. else
  71. break
  72. fi
  73. if [[ "${retries}" -gt 40 ]]; then
  74. echo "error: No existing node-config.yaml, exiting" 2>&1
  75. exit 1
  76. fi
  77. done
  78. # Take over network functions on the node
  79. rm -Rf /etc/cni/net.d/*
  80. rm -Rf /host/opt/cni/bin/*
  81. cp -Rf /opt/cni/bin/* /host/opt/cni/bin/
  82. if [[ -f /etc/sysconfig/origin-node ]]; then
  83. set -o allexport
  84. source /etc/sysconfig/origin-node
  85. fi
  86. # use either the bootstrapped node kubeconfig or the static configuration
  87. file=/etc/origin/node/node.kubeconfig
  88. if [[ ! -f "${file}" ]]; then
  89. # use the static node config if it exists
  90. # TODO: remove when static node configuration is no longer supported
  91. for f in /etc/origin/node/system*.kubeconfig; do
  92. echo "info: Using ${f} for node configuration" 1>&2
  93. file="${f}"
  94. break
  95. done
  96. fi
  97. # Use the same config as the node, but with the service account token
  98. oc config "--config=${file}" view --flatten > /tmp/kubeconfig
  99. oc config --config=/tmp/kubeconfig set-credentials sa "--token=$( cat /var/run/secrets/kubernetes.io/serviceaccount/token )"
  100. oc config --config=/tmp/kubeconfig set-context "$( oc config --config=/tmp/kubeconfig current-context )" --user=sa
  101. # Launch the network process
  102. exec openshift start network --config=/etc/origin/node/node-config.yaml --kubeconfig=/tmp/kubeconfig --loglevel=${DEBUG_LOGLEVEL:-2}
  103. securityContext:
  104. runAsUser: 0
  105. # Permission could be reduced by selecting an appropriate SELinux policy
  106. privileged: true
  107. volumeMounts:
  108. # Directory which contains the host configuration.
  109. - mountPath: /etc/origin/node/
  110. name: host-config
  111. readOnly: true
  112. - mountPath: /etc/sysconfig/origin-node
  113. name: host-sysconfig-node
  114. readOnly: true
  115. # Mount the entire run directory for socket access for Docker or CRI-o
  116. # TODO: remove
  117. - mountPath: /var/run
  118. name: host-var-run
  119. # Run directories where we need to be able to access sockets
  120. - mountPath: /var/run/dbus/
  121. name: host-var-run-dbus
  122. readOnly: true
  123. - mountPath: /var/run/openvswitch/
  124. name: host-var-run-ovs
  125. readOnly: true
  126. - mountPath: /var/run/kubernetes/
  127. name: host-var-run-kubernetes
  128. readOnly: true
  129. # We mount our socket here
  130. - mountPath: /var/run/openshift-sdn
  131. name: host-var-run-openshift-sdn
  132. # CNI related mounts which we take over
  133. - mountPath: /host/opt/cni/bin
  134. name: host-opt-cni-bin
  135. - mountPath: /etc/cni/net.d
  136. name: host-etc-cni-netd
  137. - mountPath: /var/lib/cni/networks/openshift-sdn
  138. name: host-var-lib-cni-networks-openshift-sdn
  139. resources:
  140. requests:
  141. cpu: 100m
  142. memory: 200Mi
  143. env:
  144. - name: OPENSHIFT_DNS_DOMAIN
  145. value: cluster.local
  146. ports:
  147. - name: healthz
  148. containerPort: 10256
  149. # TODO: Temporarily disabled until we determine how to wait for clean default
  150. # config
  151. # livenessProbe:
  152. # initialDelaySeconds: 10
  153. # httpGet:
  154. # path: /healthz
  155. # port: 10256
  156. # scheme: HTTP
  157. lifecycle:
  158. volumes:
  159. # In bootstrap mode, the host config contains information not easily available
  160. # from other locations.
  161. - name: host-config
  162. hostPath:
  163. path: /etc/origin/node
  164. - name: host-sysconfig-node
  165. hostPath:
  166. path: /etc/sysconfig/origin-node
  167. - name: host-modules
  168. hostPath:
  169. path: /lib/modules
  170. # TODO: access to the docker socket should be replaced by CRI socket
  171. - name: host-var-run
  172. hostPath:
  173. path: /var/run
  174. - name: host-var-run-dbus
  175. hostPath:
  176. path: /var/run/dbus
  177. - name: host-var-run-ovs
  178. hostPath:
  179. path: /var/run/openvswitch
  180. - name: host-var-run-kubernetes
  181. hostPath:
  182. path: /var/run/kubernetes
  183. - name: host-var-run-openshift-sdn
  184. hostPath:
  185. path: /var/run/openshift-sdn
  186. - name: host-opt-cni-bin
  187. hostPath:
  188. path: /opt/cni/bin
  189. - name: host-etc-cni-netd
  190. hostPath:
  191. path: /etc/cni/net.d
  192. - name: host-var-lib-cni-networks-openshift-sdn
  193. hostPath:
  194. path: /var/lib/cni/networks/openshift-sdn