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.

166 lines
5.9 KiB

  1. apiVersion: v1
  2. kind: Pod
  3. metadata:
  4. name: kube-apiserver
  5. namespace: {{system_namespace}}
  6. labels:
  7. k8s-app: kube-apiserver
  8. kubespray: v2
  9. annotations:
  10. kubespray.etcd-cert/serial: "{{ etcd_client_cert_serial }}"
  11. kubespray.apiserver-cert/serial: "{{ apiserver_cert_serial }}"
  12. spec:
  13. hostNetwork: true
  14. {% if kube_version | version_compare('v1.6', '>=') %}
  15. dnsPolicy: ClusterFirst
  16. {% endif %}
  17. containers:
  18. - name: kube-apiserver
  19. image: {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }}
  20. imagePullPolicy: {{ k8s_image_pull_policy }}
  21. resources:
  22. limits:
  23. cpu: {{ kube_apiserver_cpu_limit }}
  24. memory: {{ kube_apiserver_memory_limit }}
  25. requests:
  26. cpu: {{ kube_apiserver_cpu_requests }}
  27. memory: {{ kube_apiserver_memory_requests }}
  28. command:
  29. - /hyperkube
  30. - apiserver
  31. - --advertise-address={{ ip | default(ansible_default_ipv4.address) }}
  32. - --etcd-servers={{ etcd_access_addresses }}
  33. {% if kube_version | version_compare('v1.9', '<') %}
  34. - --etcd-quorum-read=true
  35. {% endif %}
  36. - --etcd-cafile={{ etcd_cert_dir }}/ca.pem
  37. - --etcd-certfile={{ etcd_cert_dir }}/node-{{ inventory_hostname }}.pem
  38. - --etcd-keyfile={{ etcd_cert_dir }}/node-{{ inventory_hostname }}-key.pem
  39. - --insecure-bind-address={{ kube_apiserver_insecure_bind_address }}
  40. - --bind-address={{ kube_apiserver_bind_address }}
  41. - --apiserver-count={{ kube_apiserver_count }}
  42. - --admission-control={{ kube_apiserver_admission_control | join(',') }}
  43. - --service-cluster-ip-range={{ kube_service_addresses }}
  44. - --service-node-port-range={{ kube_apiserver_node_port_range }}
  45. - --client-ca-file={{ kube_cert_dir }}/ca.pem
  46. - --profiling=false
  47. - --repair-malformed-updates=false
  48. - --kubelet-client-certificate={{ kube_cert_dir }}/node-{{ inventory_hostname }}.pem
  49. - --kubelet-client-key={{ kube_cert_dir }}/node-{{ inventory_hostname }}-key.pem
  50. - --service-account-lookup=true
  51. {% if kube_basic_auth|default(true) %}
  52. - --basic-auth-file={{ kube_users_dir }}/known_users.csv
  53. {% endif %}
  54. - --tls-cert-file={{ kube_cert_dir }}/apiserver.pem
  55. - --tls-private-key-file={{ kube_cert_dir }}/apiserver-key.pem
  56. - --proxy-client-cert-file={{ kube_cert_dir }}/apiserver.pem
  57. - --proxy-client-key-file={{ kube_cert_dir }}/apiserver-key.pem
  58. {% if kube_token_auth|default(true) %}
  59. - --token-auth-file={{ kube_token_dir }}/known_tokens.csv
  60. {% endif %}
  61. - --service-account-key-file={{ kube_cert_dir }}/apiserver-key.pem
  62. {% if kube_oidc_auth|default(false) and kube_oidc_url is defined and kube_oidc_client_id is defined %}
  63. - --oidc-issuer-url={{ kube_oidc_url }}
  64. - --oidc-client-id={{ kube_oidc_client_id }}
  65. {% if kube_oidc_ca_file is defined %}
  66. - --oidc-ca-file={{ kube_oidc_ca_file }}
  67. {% endif %}
  68. {% if kube_oidc_username_claim is defined %}
  69. - --oidc-username-claim={{ kube_oidc_username_claim }}
  70. {% endif %}
  71. {% if kube_oidc_groups_claim is defined %}
  72. - --oidc-groups-claim={{ kube_oidc_groups_claim }}
  73. {% endif %}
  74. {% endif %}
  75. - --secure-port={{ kube_apiserver_port }}
  76. - --insecure-port={{ kube_apiserver_insecure_port }}
  77. - --storage-backend={{ kube_apiserver_storage_backend }}
  78. {% if kube_api_runtime_config is defined %}
  79. {% for conf in kube_api_runtime_config %}
  80. - --runtime-config={{ conf }}
  81. {% endfor %}
  82. {% endif %}
  83. {% if enable_network_policy %}
  84. {% if kube_version | version_compare('v1.8', '<') %}
  85. - --runtime-config=extensions/v1beta1/networkpolicies=true
  86. {% endif %}
  87. {% endif %}
  88. - --v={{ kube_log_level }}
  89. - --allow-privileged=true
  90. {% if cloud_provider is defined and cloud_provider in ["openstack", "azure", "vsphere"] %}
  91. - --cloud-provider={{ cloud_provider }}
  92. - --cloud-config={{ kube_config_dir }}/cloud_config
  93. {% elif cloud_provider is defined and cloud_provider == "aws" %}
  94. - --cloud-provider={{ cloud_provider }}
  95. {% endif %}
  96. {% if kube_api_anonymous_auth is defined and kube_version | version_compare('v1.5', '>=') %}
  97. - --anonymous-auth={{ kube_api_anonymous_auth }}
  98. {% endif %}
  99. {% if authorization_modes %}
  100. - --authorization-mode={{ authorization_modes|join(',') }}
  101. {% endif %}
  102. {% if kube_feature_gates %}
  103. - --feature-gates={{ kube_feature_gates|join(',') }}
  104. {% endif %}
  105. {% if apiserver_custom_flags is string %}
  106. - {{ apiserver_custom_flags }}
  107. {% else %}
  108. {% for flag in apiserver_custom_flags %}
  109. - {{ flag }}
  110. {% endfor %}
  111. {% endif %}
  112. livenessProbe:
  113. httpGet:
  114. host: 127.0.0.1
  115. path: /healthz
  116. {% if kube_apiserver_insecure_port == 0 %}
  117. port: {{ kube_apiserver_port }}
  118. scheme: HTTPS
  119. {% else %}
  120. port: {{ kube_apiserver_insecure_port }}
  121. {% endif %}
  122. failureThreshold: 8
  123. initialDelaySeconds: 15
  124. periodSeconds: 10
  125. successThreshold: 1
  126. timeoutSeconds: 15
  127. volumeMounts:
  128. - mountPath: {{ kube_config_dir }}
  129. name: kubernetes-config
  130. readOnly: true
  131. - mountPath: /etc/ssl
  132. name: ssl-certs-host
  133. readOnly: true
  134. {% for dir in ssl_ca_dirs %}
  135. - mountPath: {{ dir }}
  136. name: {{ dir | regex_replace('^/(.*)$', '\\1' ) | regex_replace('/', '-') }}
  137. readOnly: true
  138. {% endfor %}
  139. - mountPath: {{ etcd_cert_dir }}
  140. name: etcd-certs
  141. readOnly: true
  142. {% if cloud_provider is defined and cloud_provider == 'aws' and ansible_os_family == 'RedHat' %}
  143. - mountPath: /etc/ssl/certs/ca-bundle.crt
  144. name: rhel-ca-bundle
  145. readOnly: true
  146. {% endif %}
  147. volumes:
  148. - hostPath:
  149. path: {{ kube_config_dir }}
  150. name: kubernetes-config
  151. - name: ssl-certs-host
  152. hostPath:
  153. path: /etc/ssl
  154. {% for dir in ssl_ca_dirs %}
  155. - name: {{ dir | regex_replace('^/(.*)$', '\\1' ) | regex_replace('/', '-') }}
  156. hostPath:
  157. path: {{ dir }}
  158. {% endfor %}
  159. - hostPath:
  160. path: {{ etcd_cert_dir }}
  161. name: etcd-certs
  162. {% if cloud_provider is defined and cloud_provider == 'aws' and ansible_os_family == 'RedHat' %}
  163. - hostPath:
  164. path: /etc/ssl/certs/ca-bundle.crt
  165. name: rhel-ca-bundle
  166. {% endif %}