You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
5.0 KiB

  1. # This manifest creates a Service, which will be backed by Calico's Typha daemon.
  2. # Typha sits in between Felix and the API server, reducing Calico's load on the API server.
  3. apiVersion: v1
  4. kind: Service
  5. metadata:
  6. name: calico-typha
  7. namespace: kube-system
  8. labels:
  9. k8s-app: calico-typha
  10. spec:
  11. ports:
  12. - port: 5473
  13. protocol: TCP
  14. targetPort: calico-typha
  15. name: calico-typha
  16. selector:
  17. k8s-app: calico-typha
  18. ---
  19. # This manifest creates a Deployment of Typha to back the above service.
  20. apiVersion: apps/v1
  21. kind: Deployment
  22. metadata:
  23. name: calico-typha
  24. namespace: kube-system
  25. labels:
  26. k8s-app: calico-typha
  27. spec:
  28. # Number of Typha replicas. To enable Typha, set this to a non-zero value *and* set the
  29. # typha_service_name variable in the calico-config ConfigMap above.
  30. #
  31. # We recommend using Typha if you have more than 50 nodes. Above 100 nodes it is essential
  32. # (when using the Kubernetes datastore). Use one replica for every 100-200 nodes. In
  33. # production, we recommend running at least 3 replicas to reduce the impact of rolling upgrade.
  34. replicas: {{ typha_replicas }}
  35. revisionHistoryLimit: 2
  36. selector:
  37. matchLabels:
  38. k8s-app: calico-typha
  39. template:
  40. metadata:
  41. labels:
  42. k8s-app: calico-typha
  43. annotations:
  44. cluster-autoscaler.kubernetes.io/safe-to-evict: 'true'
  45. spec:
  46. nodeSelector:
  47. kubernetes.io/os: linux
  48. hostNetwork: true
  49. tolerations:
  50. - key: node-role.kubernetes.io/master
  51. operator: Exists
  52. effect: NoSchedule
  53. - key: node-role.kubernetes.io/control-plane
  54. operator: Exists
  55. effect: NoSchedule
  56. # Since Calico can't network a pod until Typha is up, we need to run Typha itself
  57. # as a host-networked pod.
  58. serviceAccountName: calico-node
  59. priorityClassName: system-cluster-critical
  60. containers:
  61. - image: {{ calico_typha_image_repo }}:{{ calico_typha_image_tag }}
  62. name: calico-typha
  63. ports:
  64. - containerPort: 5473
  65. name: calico-typha
  66. protocol: TCP
  67. env:
  68. # Enable "info" logging by default. Can be set to "debug" to increase verbosity.
  69. - name: TYPHA_LOGSEVERITYSCREEN
  70. value: "info"
  71. # Disable logging to file and syslog since those don't make sense in Kubernetes.
  72. - name: TYPHA_LOGFILEPATH
  73. value: "none"
  74. - name: TYPHA_LOGSEVERITYSYS
  75. value: "none"
  76. # Monitor the Kubernetes API to find the number of running instances and rebalance
  77. # connections.
  78. - name: TYPHA_CONNECTIONREBALANCINGMODE
  79. value: "kubernetes"
  80. - name: TYPHA_DATASTORETYPE
  81. value: "kubernetes"
  82. - name: TYPHA_HEALTHENABLED
  83. value: "true"
  84. - name: TYPHA_MAXCONNECTIONSLOWERLIMIT
  85. value: "{{ typha_max_connections_lower_limit }}"
  86. {% if typha_secure %}
  87. - name: TYPHA_CAFILE
  88. value: /etc/ca/ca.crt
  89. - name: TYPHA_CLIENTCN
  90. value: typha-client
  91. - name: TYPHA_SERVERCERTFILE
  92. value: /etc/typha/server_certificate.pem
  93. - name: TYPHA_SERVERKEYFILE
  94. value: /etc/typha/server_key.pem
  95. volumeMounts:
  96. - mountPath: /etc/typha
  97. name: typha-server
  98. readOnly: true
  99. - mountPath: /etc/ca/ca.crt
  100. subPath: ca.crt
  101. name: cacert
  102. readOnly: true
  103. {% endif %}
  104. # Uncomment these lines to enable prometheus metrics. Since Typha is host-networked,
  105. # this opens a port on the host, which may need to be secured.
  106. #- name: TYPHA_PROMETHEUSMETRICSENABLED
  107. # value: "true"
  108. #- name: TYPHA_PROMETHEUSMETRICSPORT
  109. # value: "9093"
  110. # Needed for version >=3.7 when the 'host-local' ipam is used
  111. # Should never happen given templates/cni-calico.conflist.j2
  112. # Configure route aggregation based on pod CIDR.
  113. # - name: USE_POD_CIDR
  114. # value: "true"
  115. livenessProbe:
  116. httpGet:
  117. path: /liveness
  118. port: 9098
  119. host: localhost
  120. periodSeconds: 30
  121. initialDelaySeconds: 30
  122. readinessProbe:
  123. httpGet:
  124. path: /readiness
  125. port: 9098
  126. host: localhost
  127. periodSeconds: 10
  128. {% if typha_secure %}
  129. volumes:
  130. - name: typha-server
  131. secret:
  132. secretName: typha-server
  133. items:
  134. - key: tls.crt
  135. path: server_certificate.pem
  136. - key: tls.key
  137. path: server_key.pem
  138. - name: cacert
  139. hostPath:
  140. path: "{{ kube_cert_dir }}"
  141. {% endif %}
  142. ---
  143. # This manifest creates a Pod Disruption Budget for Typha to allow K8s Cluster Autoscaler to evict
  144. apiVersion: policy/v1beta1
  145. kind: PodDisruptionBudget
  146. metadata:
  147. name: calico-typha
  148. namespace: kube-system
  149. labels:
  150. k8s-app: calico-typha
  151. spec:
  152. maxUnavailable: 1
  153. selector:
  154. matchLabels:
  155. k8s-app: calico-typha