exporter.yaml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. # Based on the split YAML files, this is aggregated for convenience of deployment.
  2. ---
  3. # The namespace cost-model will run in
  4. apiVersion: v1
  5. kind: Namespace
  6. metadata:
  7. name: cost-model
  8. ---
  9. # Service account for permissions
  10. apiVersion: v1
  11. kind: ServiceAccount
  12. metadata:
  13. name: cost-model
  14. ---
  15. # Cluster role so cost model can gather data about the cluster
  16. # No write permissions are allowed
  17. apiVersion: rbac.authorization.k8s.io/v1
  18. kind: ClusterRole
  19. metadata:
  20. name: cost-model
  21. rules:
  22. - apiGroups:
  23. - ''
  24. resources:
  25. - configmaps
  26. - deployments
  27. - nodes
  28. - pods
  29. - services
  30. - resourcequotas
  31. - replicationcontrollers
  32. - limitranges
  33. - persistentvolumeclaims
  34. - persistentvolumes
  35. - namespaces
  36. - endpoints
  37. verbs:
  38. - get
  39. - list
  40. - watch
  41. - apiGroups:
  42. - extensions
  43. resources:
  44. - daemonsets
  45. - deployments
  46. - replicasets
  47. verbs:
  48. - get
  49. - list
  50. - watch
  51. - apiGroups:
  52. - apps
  53. resources:
  54. - statefulsets
  55. - deployments
  56. - daemonsets
  57. - replicasets
  58. verbs:
  59. - list
  60. - watch
  61. - apiGroups:
  62. - batch
  63. resources:
  64. - cronjobs
  65. - jobs
  66. verbs:
  67. - get
  68. - list
  69. - watch
  70. - apiGroups:
  71. - autoscaling
  72. resources:
  73. - horizontalpodautoscalers
  74. verbs:
  75. - get
  76. - list
  77. - watch
  78. - apiGroups:
  79. - policy
  80. resources:
  81. - poddisruptionbudgets
  82. verbs:
  83. - get
  84. - list
  85. - watch
  86. - apiGroups:
  87. - storage.k8s.io
  88. resources:
  89. - storageclasses
  90. verbs:
  91. - get
  92. - list
  93. - watch
  94. ---
  95. # Bind the role to the service account
  96. apiVersion: rbac.authorization.k8s.io/v1
  97. kind: ClusterRoleBinding
  98. metadata:
  99. name: cost-model
  100. roleRef:
  101. apiGroup: rbac.authorization.k8s.io
  102. kind: ClusterRole
  103. name: cost-model
  104. subjects:
  105. - kind: ServiceAccount
  106. name: cost-model
  107. namespace: cost-model
  108. ---
  109. # Create a deployment for a single cost model pod
  110. #
  111. # See environment variables if you would like to add a Prometheus for
  112. # cost model to read from for full functionality.
  113. apiVersion: apps/v1
  114. kind: Deployment
  115. metadata:
  116. name: cost-model
  117. labels:
  118. app: cost-model
  119. spec:
  120. replicas: 1
  121. selector:
  122. matchLabels:
  123. app: cost-model
  124. strategy:
  125. rollingUpdate:
  126. maxSurge: 1
  127. maxUnavailable: 1
  128. type: RollingUpdate
  129. template:
  130. metadata:
  131. labels:
  132. app: cost-model
  133. spec:
  134. restartPolicy: Always
  135. serviceAccountName: cost-model
  136. containers:
  137. - image: quay.io/kubecost1/kubecost-cost-model:latest
  138. name: cost-model
  139. resources:
  140. requests:
  141. cpu: "10m"
  142. memory: "55M"
  143. env:
  144. - name: PROMETHEUS_SERVER_ENDPOINT
  145. value: "{{prometheusEndpoint}}" # The endpoint should have the form http://<service-name>.<namespace-name>.svc
  146. - name: CLOUD_PROVIDER_API_KEY
  147. value: "AIzaSyD29bGxmHAVEOBYtgd8sYM2gM2ekfxQX4U" # The GCP Pricing API requires a key. This is supplied just for evaluation.
  148. - name: CLUSTER_ID
  149. value: "cluster-one" # Default cluster ID to use if cluster_id is not set in Prometheus metrics.
  150. imagePullPolicy: Always
  151. ---
  152. # Expose the cost model with a service
  153. #
  154. # Without a Prometheus endpoint configured in the deployment,
  155. # only cost-model/metrics will have useful data as it is intended
  156. # to be used as just an exporter.
  157. kind: Service
  158. apiVersion: v1
  159. metadata:
  160. name: cost-model
  161. spec:
  162. selector:
  163. app: cost-model
  164. type: ClusterIP
  165. ports:
  166. - name: cost-model
  167. port: 9003
  168. targetPort: 9003
  169. ---