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.

160 lines
4.9 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. # Since Calico can't network a pod until Typha is up, we need to run Typha itself
  54. # as a host-networked pod.
  55. serviceAccountName: calico-node
  56. priorityClassName: system-cluster-critical
  57. containers:
  58. - image: {{ calico_typha_image_repo }}:{{ calico_typha_image_tag }}
  59. name: calico-typha
  60. ports:
  61. - containerPort: 5473
  62. name: calico-typha
  63. protocol: TCP
  64. env:
  65. # Enable "info" logging by default. Can be set to "debug" to increase verbosity.
  66. - name: TYPHA_LOGSEVERITYSCREEN
  67. value: "info"
  68. # Disable logging to file and syslog since those don't make sense in Kubernetes.
  69. - name: TYPHA_LOGFILEPATH
  70. value: "none"
  71. - name: TYPHA_LOGSEVERITYSYS
  72. value: "none"
  73. # Monitor the Kubernetes API to find the number of running instances and rebalance
  74. # connections.
  75. - name: TYPHA_CONNECTIONREBALANCINGMODE
  76. value: "kubernetes"
  77. - name: TYPHA_DATASTORETYPE
  78. value: "kubernetes"
  79. - name: TYPHA_HEALTHENABLED
  80. value: "true"
  81. - name: TYPHA_MAXCONNECTIONSLOWERLIMIT
  82. value: "{{ typha_max_connections_lower_limit }}"
  83. {% if typha_secure %}
  84. - name: TYPHA_CAFILE
  85. value: /etc/ca/ca.crt
  86. - name: TYPHA_CLIENTCN
  87. value: typha-client
  88. - name: TYPHA_SERVERCERTFILE
  89. value: /etc/typha/server_certificate.pem
  90. - name: TYPHA_SERVERKEYFILE
  91. value: /etc/typha/server_key.pem
  92. volumeMounts:
  93. - mountPath: /etc/typha
  94. name: typha-server
  95. readOnly: true
  96. - mountPath: /etc/ca/ca.crt
  97. subPath: ca.crt
  98. name: cacert
  99. readOnly: true
  100. {% endif %}
  101. # Uncomment these lines to enable prometheus metrics. Since Typha is host-networked,
  102. # this opens a port on the host, which may need to be secured.
  103. #- name: TYPHA_PROMETHEUSMETRICSENABLED
  104. # value: "true"
  105. #- name: TYPHA_PROMETHEUSMETRICSPORT
  106. # value: "9093"
  107. # Needed for version >=3.7 when the 'host-local' ipam is used
  108. # Should never happen given templates/cni-calico.conflist.j2
  109. # Configure route aggregation based on pod CIDR.
  110. # - name: USE_POD_CIDR
  111. # value: "true"
  112. livenessProbe:
  113. httpGet:
  114. path: /liveness
  115. port: 9098
  116. host: localhost
  117. periodSeconds: 30
  118. initialDelaySeconds: 30
  119. readinessProbe:
  120. httpGet:
  121. path: /readiness
  122. port: 9098
  123. host: localhost
  124. periodSeconds: 10
  125. {% if typha_secure %}
  126. volumes:
  127. - name: typha-server
  128. secret:
  129. secretName: typha-server
  130. items:
  131. - key: tls.crt
  132. path: server_certificate.pem
  133. - key: tls.key
  134. path: server_key.pem
  135. - name: cacert
  136. hostPath:
  137. path: "{{ kube_cert_dir }}"
  138. {% endif %}
  139. ---
  140. # This manifest creates a Pod Disruption Budget for Typha to allow K8s Cluster Autoscaler to evict
  141. apiVersion: policy/v1beta1
  142. kind: PodDisruptionBudget
  143. metadata:
  144. name: calico-typha
  145. namespace: kube-system
  146. labels:
  147. k8s-app: calico-typha
  148. spec:
  149. maxUnavailable: 1
  150. selector:
  151. matchLabels:
  152. k8s-app: calico-typha