Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions helm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Makefile for kube-summary-exporter Helm chart

CHART_NAME = kube-summary-exporter
RELEASE_NAME = kube-summary-exporter
NAMESPACE = monitoring

.PHONY: lint template install upgrade uninstall package dry-run

# Lint the Helm chart
lint:
helm lint $(CHART_NAME)

# Render templates for debugging
template:
helm template $(RELEASE_NAME) $(CHART_NAME) --debug

# Install the chart
install:
helm install $(RELEASE_NAME) $(CHART_NAME) --namespace $(NAMESPACE) --create-namespace

# Upgrade the chart
upgrade:
helm upgrade $(RELEASE_NAME) $(CHART_NAME) --namespace $(NAMESPACE)

# Uninstall the chart
uninstall:
helm uninstall $(RELEASE_NAME) --namespace $(NAMESPACE)

# Package the chart
package:
helm package $(CHART_NAME)

# Dry run installation
dry-run:
helm install $(RELEASE_NAME) $(CHART_NAME) --namespace $(NAMESPACE) --dry-run --debug

# Show chart values
show-values:
helm show values $(CHART_NAME)

# Show chart info
show-chart:
helm show chart $(CHART_NAME)

# Test the release
test:
helm test $(RELEASE_NAME) --namespace $(NAMESPACE)

# Get status
status:
helm status $(RELEASE_NAME) --namespace $(NAMESPACE)

# List releases
list:
helm list --namespace $(NAMESPACE)
182 changes: 182 additions & 0 deletions helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# Kube Summary Exporter Helm Chart

This Helm chart deploys kube-summary-exporter on a Kubernetes cluster using the Helm package manager.

## Prerequisites

- Kubernetes 1.16+
- Helm 3.0+
- RBAC enabled cluster (for ServiceAccount and ClusterRole)

## Installation

From this directory:

```bash
# Install the chart
helm install kube-summary-exporter ./kube-summary-exporter --namespace monitoring --create-namespace

# Or use the Makefile
make install
```

## Configuration

The following table lists the configurable parameters of the kube-summary-exporter chart and their default values.

| Parameter | Description | Default |
|-----------|-------------|---------|
| `replicaCount` | Number of replicas | `1` |
| `image.repository` | Container image repository | `quay.io/utilitywarehouse/kube-summary-exporter` |
| `image.pullPolicy` | Container image pull policy | `IfNotPresent` |
| `image.tag` | Container image tag | `"latest"` |
| `service.type` | Kubernetes service type | `ClusterIP` |
| `service.port` | Service port | `9779` |
| `config.listenAddress` | Address to listen on for HTTP requests | `":9779"` |
| `config.kubeconfig` | Path to kubeconfig file (empty for in-cluster) | `""` |
| `rbac.create` | Create RBAC resources | `true` |
| `serviceAccount.create` | Create service account | `true` |
| `serviceMonitor.enabled` | Create ServiceMonitor for Prometheus Operator | `true` |
| `serviceMonitorNodes.enabled` | Create ServiceMonitor for /nodes endpoint | `true` |

### ServiceMonitor Configuration

The chart includes two ServiceMonitors for Prometheus Operator:

1. **serviceMonitor**: Scrapes `/metrics` endpoint (exporter metrics)
2. **serviceMonitorNodes**: Scrapes `/nodes` endpoint (Kubernetes summary metrics)

Both ServiceMonitors are configured with the label `release: kube-prom-stack` by default. Update `serviceMonitor.additionalLabels.release` to match your Prometheus Operator release name.

## Usage Examples

### Custom Values Installation

Create a `values.yaml` file:

```yaml
image:
tag: "v1.0.0"

resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 50m
memory: 64Mi

serviceMonitor:
additionalLabels:
release: my-prometheus

nodeSelector:
kubernetes.io/os: linux
```

Install with custom values:

```bash
helm install kube-summary-exporter ./kube-summary-exporter -f values.yaml --namespace monitoring --create-namespace
```

### Disable ServiceMonitors

If you don't use Prometheus Operator:

```bash
helm install kube-summary-exporter ./kube-summary-exporter \
--set serviceMonitor.enabled=false \
--set serviceMonitorNodes.enabled=false \
--namespace monitoring --create-namespace
```

## Accessing the Application

After installation, you can access the kube-summary-exporter using port-forward:

```bash
export POD_NAME=$(kubectl get pods --namespace monitoring -l "app.kubernetes.io/name=kube-summary-exporter" -o jsonpath="{.items[0].metadata.name}")
kubectl --namespace monitoring port-forward $POD_NAME 9779:9779
```

Then visit:
- http://localhost:9779/ - Home page
- http://localhost:9779/nodes - Metrics for all nodes
- http://localhost:9779/node/{node-name} - Metrics for specific node
- http://localhost:9779/metrics - Exporter metrics

## Available Commands (Makefile)

From the helm directory, you can use:

```bash
make lint # Lint the Helm chart
make template # Render templates for debugging
make install # Install the chart
make upgrade # Upgrade the chart
make uninstall # Uninstall the chart
make package # Package the chart
make dry-run # Dry run installation
make show-values # Show chart values
make show-chart # Show chart info
make test # Test the release
make status # Get release status
make list # List releases
```

## Troubleshooting

### ServiceMonitor Not Picked Up

If Prometheus isn't discovering your ServiceMonitor:

1. Check your Prometheus serviceMonitorSelector labels:
```bash
kubectl get prometheus -o yaml | grep -A 10 serviceMonitorSelector
```

2. Ensure the `release` label matches your Prometheus release name:
```yaml
serviceMonitor:
additionalLabels:
release: your-prometheus-release-name
```

3. Verify namespace permissions and RBAC for Prometheus

### Pod Not Starting

Check the logs:
```bash
kubectl logs -n monitoring deployment/kube-summary-exporter
```

Common issues:
- RBAC permissions (check ServiceAccount and ClusterRole)
- Image pull issues (check imagePullSecrets)
- Resource constraints

## Metrics Exposed

The exporter provides detailed Kubernetes node and container metrics including:

- Container logs filesystem usage
- Container rootfs usage
- Node runtime ImageFS usage
- Pod ephemeral storage usage

See the [main README](../README.md) for a complete list of available metrics.

## Development

To contribute to this chart:

1. Make changes to templates or values
2. Test with `helm template` and `helm lint`
3. Verify installation works in a test cluster
4. Update this README if adding new configuration options

## License

This chart is part of the kube-summary-exporter project. See the main repository for license information.
18 changes: 18 additions & 0 deletions helm/kube-summary-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v2
name: kube-summary-exporter
description: A Helm chart for kube-summary-exporter - Exports Prometheus metrics for the Kubernetes Summary API
type: application
version: 0.1.0
appVersion: "latest"
keywords:
- kubernetes
- prometheus
- monitoring
- metrics
- summary-api
home: https://github.com/utilitywarehouse/kube-summary-exporter
sources:
- https://github.com/utilitywarehouse/kube-summary-exporter
maintainers:
- name: kube-summary-exporter
url: https://github.com/utilitywarehouse/kube-summary-exporter
39 changes: 39 additions & 0 deletions helm/kube-summary-exporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
1. Get the application URL by running these commands:
{{- if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "kube-summary-exporter.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "kube-summary-exporter.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "kube-summary-exporter.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "kube-summary-exporter.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:9779 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 9779:$CONTAINER_PORT
{{- end }}

2. kube-summary-exporter provides the following endpoints:
- /: Home page with links to other endpoints
- /nodes: Metrics for all nodes in the cluster
- /node/{node}: Metrics for a specific node
- /metrics: Prometheus metrics about the exporter itself

3. Example Prometheus scrape configuration:
Add the following to your Prometheus configuration to scrape metrics:

- job_name: "kubernetes-summary"
kubernetes_sd_configs:
- role: node
relabel_configs:
- source_labels: [__meta_kubernetes_node_label_role]
action: replace
target_label: role
- source_labels: [__meta_kubernetes_node_name]
regex: (.+)
target_label: __metrics_path__
replacement: /node/${1}
- target_label: __address__
replacement: {{ include "kube-summary-exporter.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.service.port }}
62 changes: 62 additions & 0 deletions helm/kube-summary-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "kube-summary-exporter.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "kube-summary-exporter.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "kube-summary-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "kube-summary-exporter.labels" -}}
helm.sh/chart: {{ include "kube-summary-exporter.chart" . }}
{{ include "kube-summary-exporter.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "kube-summary-exporter.selectorLabels" -}}
app.kubernetes.io/name: {{ include "kube-summary-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "kube-summary-exporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "kube-summary-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
12 changes: 12 additions & 0 deletions helm/kube-summary-exporter/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "kube-summary-exporter.fullname" . }}
labels:
{{- include "kube-summary-exporter.labels" . | nindent 4 }}
rules:
{{- with .Values.rbac.rules }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
16 changes: 16 additions & 0 deletions helm/kube-summary-exporter/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "kube-summary-exporter.fullname" . }}
labels:
{{- include "kube-summary-exporter.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "kube-summary-exporter.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "kube-summary-exporter.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
Loading