cni-daemonset.yaml.j2 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. # More info about the template: https://docs.openstack.org/kuryr-kubernetes/latest/installation/containerized.html#generating-kuryr-resource-definitions-for-kubernetes
  2. apiVersion: extensions/v1beta1
  3. kind: DaemonSet
  4. metadata:
  5. name: kuryr-cni-ds
  6. namespace: {{ kuryr_namespace }}
  7. labels:
  8. tier: node
  9. app: kuryr
  10. annotations:
  11. image.openshift.io/triggers: |
  12. [
  13. {"from":{"kind":"ImageStreamTag","name":"node:v3.11"},"fieldPath":"spec.template.spec.initContainers[?(@.name==\"install-cni-plugins\")].image"},
  14. {"from":{"kind":"ImageStreamTag","name":"node:v3.11"},"fieldPath":"spec.template.spec.containers[?(@.name==\"sky-dns\")].image"}
  15. ]
  16. spec:
  17. template:
  18. metadata:
  19. labels:
  20. tier: node
  21. app: kuryr
  22. spec:
  23. hostNetwork: true
  24. tolerations:
  25. - key: node-role.kubernetes.io/master
  26. operator: Exists
  27. effect: NoSchedule
  28. serviceAccountName: kuryr-controller
  29. initContainers:
  30. - name: install-cni-plugins
  31. image: " "
  32. command:
  33. - /bin/bash
  34. - -c
  35. - |
  36. #!/bin/bash
  37. set -ex
  38. # Take over network functions on the node
  39. rm -Rf /host-cni-bin/*
  40. cp -Rf /opt/cni/bin/* /host-cni-bin/
  41. volumeMounts:
  42. - name: bin
  43. mountPath: /host-cni-bin
  44. securityContext:
  45. privileged: true
  46. containers:
  47. - name: sky-dns
  48. image: " "
  49. command:
  50. - /bin/bash
  51. - -c
  52. - |
  53. #!/bin/bash
  54. set -ex
  55. # if the node config doesn't exist yet, wait until it does
  56. retries=0
  57. while true; do
  58. if [[ ! -f /etc/origin/node/node-config.yaml ]]; then
  59. echo "warning: Cannot find existing node-config.yaml, waiting 15s ..." 2>&1
  60. sleep 15 & wait
  61. (( retries += 1 ))
  62. else
  63. break
  64. fi
  65. if [[ "${retries}" -gt 40 ]]; then
  66. echo "error: No existing node-config.yaml, exiting" 2>&1
  67. exit 1
  68. fi
  69. done
  70. if [[ -f /etc/sysconfig/origin-node ]]; then
  71. set -o allexport
  72. source /etc/sysconfig/origin-node
  73. fi
  74. # use either the bootstrapped node kubeconfig or the static configuration
  75. file=/etc/origin/node/node.kubeconfig
  76. if [[ ! -f "${file}" ]]; then
  77. # use the static node config if it exists
  78. # TODO: remove when static node configuration is no longer supported
  79. for f in /etc/origin/node/system*.kubeconfig; do
  80. echo "info: Using ${f} for node configuration" 1>&2
  81. file="${f}"
  82. break
  83. done
  84. fi
  85. # Use the same config as the node, but with the service account token
  86. oc config "--config=${file}" view --flatten > /tmp/kubeconfig
  87. oc config --config=/tmp/kubeconfig set-credentials sa "--token=$( cat /var/run/secrets/kubernetes.io/serviceaccount/token )"
  88. oc config --config=/tmp/kubeconfig set-context "$( oc config --config=/tmp/kubeconfig current-context )" --user=sa
  89. # Launch the SkyDNS
  90. exec openshift start network --enable=dns --config=/etc/origin/node/node-config.yaml --kubeconfig=/tmp/kubeconfig --loglevel=${DEBUG_LOGLEVEL:-2}
  91. securityContext:
  92. privileged: true
  93. runAsUser: 0
  94. env:
  95. - name: OPENSHIFT_DNS_DOMAIN
  96. value: cluster.local
  97. volumeMounts:
  98. - name: host-config
  99. mountPath: /etc/origin/node
  100. readOnly: true
  101. - mountPath: /etc/sysconfing/origin-node
  102. name: host-sysconfig-node
  103. readOnly: true
  104. - mountPath: /var/run
  105. name: host-var-run
  106. - name: kuryr-cni
  107. image: {{ openshift_openstack_kuryr_cni_image }}
  108. imagePullPolicy: IfNotPresent
  109. command: [ "cni_ds_init" ]
  110. env:
  111. - name: CNI_DAEMON
  112. value: "True"
  113. - name: KUBERNETES_NODE_NAME
  114. valueFrom:
  115. fieldRef:
  116. fieldPath: spec.nodeName
  117. - name: KURYR_CNI_POD_NAME
  118. valueFrom:
  119. fieldRef:
  120. fieldPath: metadata.name
  121. securityContext:
  122. privileged: true
  123. volumeMounts:
  124. - name: bin
  125. mountPath: /opt/cni/bin
  126. - name: net-conf
  127. mountPath: /etc/cni/net.d
  128. - name: config-volume
  129. mountPath: /etc/kuryr/kuryr.conf
  130. subPath: kuryr-cni.conf
  131. - name: proc
  132. mountPath: /host_proc
  133. - name: openvswitch
  134. mountPath: /var/run/openvswitch
  135. {% if enable_kuryr_cni_probes|default(true)|bool %}
  136. readinessProbe:
  137. httpGet:
  138. path: /ready
  139. port: {{ kuryr_cni_healthcheck_port }}
  140. scheme: HTTP
  141. initialDelaySeconds: 15
  142. timeoutSeconds: 5
  143. livenessProbe:
  144. httpGet:
  145. path: /alive
  146. port: {{ kuryr_cni_healthcheck_port }}
  147. initialDelaySeconds: 15
  148. {% endif %}
  149. volumes:
  150. - name: bin
  151. hostPath:
  152. path: {{ cni_bin_dir }}
  153. - name: net-conf
  154. hostPath:
  155. path: /etc/cni/net.d
  156. - name: config-volume
  157. configMap:
  158. name: kuryr-config
  159. - name: proc
  160. hostPath:
  161. path: /proc
  162. - name: openvswitch
  163. hostPath:
  164. path: /var/run/openvswitch
  165. - name: host-config
  166. hostPath:
  167. path: /etc/origin/node
  168. - name: host-sysconfig-node
  169. hostPath:
  170. path: /etc/sysconfig/origin-node
  171. - name: host-var-run
  172. hostPath:
  173. path: /var/run