Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP-23051: Change default kube-state-metrics behavior to use Cloudzero subchart #91

Merged
merged 15 commits into from
Nov 13, 2024
30 changes: 0 additions & 30 deletions charts/cloudzero-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ helm install <RELEASE_NAME> cloudzero/cloudzero-agent \
--set clusterName=<CLUSTER_NAME> \
--set-string cloudAccountId=<CLOUD_ACCOUNT_ID> \
--set region=<REGION> \
# optionally deploy kube-state-metrics if it doesn't exist in the cluster already
--set kube-state-metrics.enabled=<true|false>
```

### Update Helm Chart
Expand All @@ -58,7 +56,6 @@ helm upgrade <RELEASE_NAME> cloudzero/cloudzero-agent \
--set clusterName=<CLUSTER_NAME> \
--set-string cloudAccountId=<CLOUD_ACCOUNT_ID> \
--set region=<REGION> \
--set kube-state-metrics.enabled=<true|false>
```

### Mandatory Values
Expand Down Expand Up @@ -109,33 +106,6 @@ helm install <RELEASE_NAME> cloudzero/cloudzero-agent \
-f values-override.yaml
```

### Metric Exporters

This chart depends on metrics from [kube-state-metrics](https://github.com/kubernetes/kube-state-metrics). There are two installation options for providing the `kube-state-metrics` metrics to the cloudzero-agent. If you don't know which option is right for you, use the second option.

#### Option 1 (default): Use existing kube-state-metrics

Using an existing `kube-state-metrics` exporter may be desirable for minimizing cost. By default, the `cloudzero-agent` will attempt to find an existing `kube-state-metrics` K8s Service by searching for a K8s Service with the annotation `prometheus.io/scrape: "true"`. If an existing `kube-state-metrics` Service exists but does not have that annotation and you do not wish to add it, see the **Custom Scrape Configs** section below.

In addition to the above, the existing `kube-state-metrics` Service address should be added in `values-override.yaml` as shown below so that the `cloudzero-agent` can validate the connection:

```yaml
validator:
serviceEndpoints:
kubeStateMetrics: <kube-state-metrics>.<example-namespace>.svc.cluster.local:8080
```


#### Option 2: Use kube-state-metrics subchart

Alternatively, deploy the `kube-state-metrics` subchart that comes packaged with this chart. This is done by enabling settings in `values-override.yaml` as shown:

```yaml
kube-state-metrics:
enabled: true
```
In this option, no additional configuration is required in the `validator` field.

### Secret Management

The chart requires a CloudZero API key to send metric data. Admins can retrieve API keys [here](https://app.cloudzero.com/organization/api-keys).
Expand Down
2 changes: 1 addition & 1 deletion charts/cloudzero-agent/templates/validatorcm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ data:
{{- if .Values.validator.serviceEndpoints.kubeStateMetrics }}
kube_state_metrics_service_endpoint: http://{{ .Values.validator.serviceEndpoints.kubeStateMetrics }}/
{{- else }}
kube_state_metrics_service_endpoint: http://{{- if .Release.Name }}{{.Release.Name}}-{{- end }}kube-state-metrics:8080/
kube_state_metrics_service_endpoint: http://{{- if .Release.Name }}{{.Release.Name}}-{{- end }}state-metrics:8080/
{{- end }}
{{- if .Values.validator.serviceEndpoints.prometheusNodeExporter }}
prometheus_node_exporter_service_endpoint: http://{{ .Values.validator.serviceEndpoints.prometheusNodeExporter }}/
Expand Down
10 changes: 9 additions & 1 deletion charts/cloudzero-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@ prometheusConfig:
additionalScrapeJobs: []

kube-state-metrics:
enabled: false
enabled: true
fullnameOverride: "cloudzero-state-metrics"
extraArgs:
- --metric-labels-allowlist=pods=[app.kubernetes.io/component]
# Disable CloudZero KSM as a Scrape Target since the service endpoint is explicity defined
# by the Validators config file.
prometheusScrape: false
# Set a default port other than 8080 to avoid collisions with any existing KSM services.
service:
port: 8080

prometheus-node-exporter:
enabled: false

Expand Down
21 changes: 21 additions & 0 deletions docs/releases/0.0.30-beta.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## [0.0.30-beta](https://github.com/cloudzero/cloudzero-charts/compare/v0.0.28...v0.0.30-beta) (2024-11-12)

Improve Kube State Metrics Install

### Upgrade Steps
To install, specify the version of the beta chart:

``` bash
helm upgrade --install -n cz-prom-agent cz-prom-agent charts/cloudzero-agent \
--set apiKey=$api_key \
--set clusterName='cluster' \
--set-string cloudAccountId="account_id" \
--set region='region' \
--version 0.0.30-beta

```

### Improvements
* **CloudZero Metrics:** CloudZero State Metrics is enabled/installed by default.

```
Loading