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.

209 lines
6.2 KiB

  1. # Copyright 2017 The Kubernetes Authors.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # Configuration to deploy release version of the Dashboard UI compatible with
  15. # Kubernetes 1.8.
  16. #
  17. # Example usage: kubectl create -f <this_file>
  18. # ------------------- Dashboard Secret ------------------- #
  19. apiVersion: v1
  20. kind: Secret
  21. metadata:
  22. labels:
  23. k8s-app: kubernetes-dashboard
  24. name: kubernetes-dashboard-certs
  25. namespace: {{ system_namespace }}
  26. type: Opaque
  27. ---
  28. # ------------------- Dashboard Service Account ------------------- #
  29. apiVersion: v1
  30. kind: ServiceAccount
  31. metadata:
  32. labels:
  33. k8s-app: kubernetes-dashboard
  34. name: kubernetes-dashboard
  35. namespace: {{ system_namespace }}
  36. ---
  37. # ------------------- Dashboard Role & Role Binding ------------------- #
  38. kind: Role
  39. apiVersion: rbac.authorization.k8s.io/v1
  40. metadata:
  41. name: kubernetes-dashboard-minimal
  42. namespace: {{ system_namespace }}
  43. rules:
  44. # Allow Dashboard to create 'kubernetes-dashboard-key-holder' secret.
  45. - apiGroups: [""]
  46. resources: ["secrets"]
  47. verbs: ["create"]
  48. # Allow Dashboard to create 'kubernetes-dashboard-settings' config map.
  49. - apiGroups: [""]
  50. resources: ["configmaps"]
  51. verbs: ["create"]
  52. # Allow Dashboard to get, update and delete Dashboard exclusive secrets.
  53. - apiGroups: [""]
  54. resources: ["secrets"]
  55. resourceNames: ["kubernetes-dashboard-key-holder", "kubernetes-dashboard-certs"]
  56. verbs: ["get", "update", "delete"]
  57. # Allow Dashboard to get and update 'kubernetes-dashboard-settings' config map.
  58. - apiGroups: [""]
  59. resources: ["configmaps"]
  60. resourceNames: ["kubernetes-dashboard-settings"]
  61. verbs: ["get", "update"]
  62. # Allow Dashboard to get metrics from heapster.
  63. - apiGroups: [""]
  64. resources: ["services"]
  65. resourceNames: ["heapster"]
  66. verbs: ["proxy"]
  67. - apiGroups: [""]
  68. resources: ["services/proxy"]
  69. resourceNames: ["heapster", "http:heapster:", "https:heapster:"]
  70. verbs: ["get"]
  71. ---
  72. apiVersion: rbac.authorization.k8s.io/v1
  73. kind: RoleBinding
  74. metadata:
  75. name: kubernetes-dashboard-minimal
  76. namespace: {{ system_namespace }}
  77. roleRef:
  78. apiGroup: rbac.authorization.k8s.io
  79. kind: Role
  80. name: kubernetes-dashboard-minimal
  81. subjects:
  82. - kind: ServiceAccount
  83. name: kubernetes-dashboard
  84. namespace: {{ system_namespace }}
  85. ---
  86. # ------------------- Gross Hack For anonymous auth through api proxy ------------------- #
  87. # Allows users to reach login page and other proxied dashboard URLs
  88. kind: ClusterRole
  89. apiVersion: rbac.authorization.k8s.io/v1
  90. metadata:
  91. name: kubernetes-dashboard-anonymous
  92. rules:
  93. - apiGroups: [""]
  94. resources: ["services/proxy"]
  95. resourceNames: ["https:kubernetes-dashboard:"]
  96. verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
  97. - nonResourceURLs: ["/ui", "/ui/*", "/api/v1/namespaces/{{ system_namespace }}/services/https:kubernetes-dashboard:/proxy/*"]
  98. verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
  99. ---
  100. apiVersion: rbac.authorization.k8s.io/v1
  101. kind: ClusterRoleBinding
  102. metadata:
  103. name: kubernetes-dashboard-anonymous
  104. roleRef:
  105. apiGroup: rbac.authorization.k8s.io
  106. kind: ClusterRole
  107. name: kubernetes-dashboard-anonymous
  108. subjects:
  109. - kind: User
  110. name: system:anonymous
  111. ---
  112. # ------------------- Dashboard Deployment ------------------- #
  113. kind: Deployment
  114. apiVersion: apps/v1beta2
  115. metadata:
  116. labels:
  117. k8s-app: kubernetes-dashboard
  118. name: kubernetes-dashboard
  119. namespace: {{ system_namespace }}
  120. spec:
  121. replicas: 1
  122. revisionHistoryLimit: 10
  123. selector:
  124. matchLabels:
  125. k8s-app: kubernetes-dashboard
  126. template:
  127. metadata:
  128. labels:
  129. k8s-app: kubernetes-dashboard
  130. spec:
  131. containers:
  132. - name: kubernetes-dashboard
  133. image: {{ dashboard_image_repo }}:{{ dashboard_image_tag }}
  134. imagePullPolicy: {{ k8s_image_pull_policy }}
  135. resources:
  136. limits:
  137. cpu: {{ dashboard_cpu_limit }}
  138. memory: {{ dashboard_memory_limit }}
  139. requests:
  140. cpu: {{ dashboard_cpu_requests }}
  141. memory: {{ dashboard_memory_requests }}
  142. ports:
  143. - containerPort: 8443
  144. protocol: TCP
  145. args:
  146. {% if dashboard_use_custom_certs %}
  147. - --tls-key-file={{ dashboard_tls_key_file }}
  148. - --tls-cert-file={{ dashboard_tls_cert_file }}
  149. {% else %}
  150. - --auto-generate-certificates
  151. {% endif %}
  152. - --authentication-mode=token{% if kube_basic_auth|default(false) %},basic{% endif %}
  153. # Uncomment the following line to manually specify Kubernetes API server Host
  154. # If not specified, Dashboard will attempt to auto discover the API server and connect
  155. # to it. Uncomment only if the default does not work.
  156. # - --apiserver-host=http://my-address:port
  157. volumeMounts:
  158. - name: kubernetes-dashboard-certs
  159. mountPath: /certs
  160. # Create on-disk volume to store exec logs
  161. - mountPath: /tmp
  162. name: tmp-volume
  163. livenessProbe:
  164. httpGet:
  165. scheme: HTTPS
  166. path: /
  167. port: 8443
  168. initialDelaySeconds: 30
  169. timeoutSeconds: 30
  170. volumes:
  171. - name: kubernetes-dashboard-certs
  172. secret:
  173. secretName: {{ dashboard_certs_secret_name }}
  174. - name: tmp-volume
  175. emptyDir: {}
  176. serviceAccountName: kubernetes-dashboard
  177. # Comment the following tolerations if Dashboard must not be deployed on master
  178. tolerations:
  179. - key: node-role.kubernetes.io/master
  180. effect: NoSchedule
  181. ---
  182. # ------------------- Dashboard Service ------------------- #
  183. kind: Service
  184. apiVersion: v1
  185. metadata:
  186. labels:
  187. k8s-app: kubernetes-dashboard
  188. name: kubernetes-dashboard
  189. namespace: {{ system_namespace }}
  190. spec:
  191. ports:
  192. - port: 443
  193. targetPort: 8443
  194. selector:
  195. k8s-app: kubernetes-dashboard