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.

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