|
2 | 2 |
|
3 | 3 | ## Installing Kubecost for GKE Autopilot via Helm |
4 | 4 |
|
5 | | -Installing Kubecost on a GKE Autopilot cluster is similar to other cloud providers with Helm v3.1+, with a few changes. Autopilot requires the use of [Google Managed Prometheus](/install-and-configure/advanced-configuration/custom-prom/gcp-gmp-integration.md) service, which generates additional costs within your Google Cloud account. |
| 5 | +Installing Kubecost on a GKE Autopilot cluster is similar to other cloud providers with Helm v3.1+, with a few changes. Autopilot restricts privileged containers by default so the kubecost-network-costs container needs to be disabled. |
6 | 6 |
|
7 | | -`helm install kubecost/cost-analyzer -n kubecost -f values.yaml` |
8 | | - |
9 | | -Your _values.yaml_ files must contain the below parameters. Resources are specified for each section of the Kubecost deployment, and Pod Security Policies are disabled. |
10 | | - |
11 | | -```yaml |
12 | | -kubecostProductConfigs: |
13 | | - clusterName: "<clusterName>" # used for display in Kubecost UI |
14 | | - |
15 | | -kubecostModel: |
16 | | - promClusterIDLabel: cluster # warning: usage and efficiency will show as zero without this setting enabled |
17 | | - resources: |
18 | | - requests: |
19 | | - cpu: 500m |
20 | | - memory: 512Mi |
21 | | - |
22 | | -kubecostFrontend: |
23 | | - resources: |
24 | | - requests: |
25 | | - cpu: 250m |
26 | | - memory: 55Mi |
27 | | - |
28 | | -global: |
29 | | - gmp: |
30 | | - enabled: true # If true, kubecost will be configured to use GMP Prometheus image and query from Google Cloud Managed Service for Prometheus. |
31 | | - gmpProxy: |
32 | | - projectId: <GCP Project ID> |
33 | | - |
34 | | -serviceAccount: |
35 | | - annotations: |
36 | | - iam.gke.io/gcp-service-account: <GCP Service Account with Metrics Writer/Reader Permissions> |
37 | | - |
38 | | -prometheus: |
39 | | - server: |
40 | | - image: |
41 | | - repository: gke.gcr.io/prometheus-engine/prometheus |
42 | | - tag: v2.41.0-gmp.4-gke.1 |
43 | | - global: |
44 | | - external_labels: |
45 | | - cluster_id: <GKE Autopilot Cluster Name> # cluster_id should be unique for all clusters and the same value as .kubecostProductConfigs.clusterName |
46 | | - podSecurityPolicy: |
47 | | - enabled: false |
48 | | - configmapReload: |
49 | | - prometheus: |
50 | | - resources: |
51 | | - requests: |
52 | | - cpu: 250m |
53 | | - memory: 256Mi |
54 | | - nodeExporter: |
55 | | - enabled: false |
56 | | - serviceAccounts: |
57 | | - nodeExporter: |
58 | | - create: false |
59 | | - server: |
60 | | - annotations: |
61 | | - iam.gke.io/gcp-service-account: <GCP Service Account with Metrics Writer/Reader Permissions> |
62 | | - |
63 | | -networkCosts: |
64 | | - enabled: false |
65 | | - |
66 | | -podSecurityPolicy: |
67 | | - enabled: false |
68 | | - |
69 | | -grafana: |
70 | | - rbac: |
71 | | - pspEnabled: false |
72 | | - resources: |
73 | | - requests: |
74 | | - cpu: 250m |
75 | | - memory: 128Mi |
76 | | - sidecar: |
77 | | - resources: |
78 | | - requests: |
79 | | - cpu: 250m |
80 | | - memory: 384Mi |
81 | | - |
82 | | -``` |
83 | | - |
84 | | -## Turning on Kubelet/cAdvisor scraping via Google Managed Collector |
85 | | - |
86 | | -Open the OperatorConfig on your Autopilot Cluster resource for editing: |
87 | 7 |
|
88 | 8 | ```bash |
89 | | -kubectl -n gmp-public edit operatorconfig config |
| 9 | +helm upgrade --install kubecost --repo https://kubecost.github.io/kubecost/ kubecost --namespace kubecost --create-namespace --values values.yaml |
90 | 10 | ``` |
91 | 11 |
|
92 | | -Add the following collection section to the resource: |
| 12 | +Your _values.yaml_ files must contain the below parameters. |
93 | 13 |
|
94 | 14 | ```yaml |
95 | | -apiVersion: monitoring.googleapis.com/v1 |
96 | | -kind: OperatorConfig |
97 | | -metadata: |
98 | | - namespace: gmp-public |
99 | | - name: config |
100 | | -collection: |
101 | | - kubeletScraping: |
102 | | - interval: 30s |
| 15 | +global: |
| 16 | + clusterId: "clusterName" # used for display in Kubecost UI |
| 17 | +networkCosts: |
| 18 | + enabled: false |
103 | 19 | ``` |
104 | 20 |
|
105 | | -Save the file and close the editor. After a short time, the Kubelet metric endpoints will be scraped and the metrics become available for querying in Managed Service for Prometheus. |
0 commit comments