Skip to content

Commit bbe8f07

Browse files
committed
docs: add user guide for additionalConfigMaps
Signed-off-by: Vibhu Prashar <[email protected]>
1 parent 4f52a99 commit bbe8f07

File tree

1 file changed

+268
-0
lines changed

1 file changed

+268
-0
lines changed
Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
# ⚙️ Configuring Kepler with Custom ConfigMaps
2+
3+
This guide explains how to customize Kepler's configuration using the `additionalConfigMaps` feature in the PowerMonitor custom resource.
4+
5+
## 📋 Overview
6+
7+
The Kepler Operator allows you to customize Kepler's behavior by providing additional configuration through Kubernetes ConfigMaps. When you reference ConfigMaps in your PowerMonitor CR, the operator automatically:
8+
9+
1. Merges your custom configuration with the default Kepler configuration
10+
2. Updates the Kepler DaemonSet with the new configuration
11+
3. Automatically triggers a rollout when the ConfigMap changes
12+
13+
## ✅ Prerequisites
14+
15+
- Kepler Operator installed in your cluster
16+
- PowerMonitor CR deployed
17+
- Access to create ConfigMaps in the namespace where Kepler is deployed (default: `power-monitor`)
18+
19+
## 🚀 Step-by-Step Configuration
20+
21+
### 📝 Step 1: Create a ConfigMap with Your Custom Configuration
22+
23+
Create a ConfigMap containing your Kepler configuration in a file named `config.yaml`. The ConfigMap must exist in the same namespace as the PowerMonitor deployment.
24+
25+
```yaml
26+
apiVersion: v1
27+
kind: ConfigMap
28+
metadata:
29+
name: my-kepler-config
30+
namespace: power-monitor
31+
data:
32+
config.yaml: |
33+
dev:
34+
fake-cpu-meter:
35+
enabled: false
36+
```
37+
38+
Apply the ConfigMap:
39+
40+
```bash
41+
kubectl apply -f my-kepler-config.yaml
42+
```
43+
44+
### 🔗 Step 2: Reference the ConfigMap in Your PowerMonitor CR
45+
46+
Update your PowerMonitor custom resource to reference the ConfigMap you created:
47+
48+
```yaml
49+
apiVersion: kepler.system.sustainable.computing.io/v1alpha1
50+
kind: PowerMonitor
51+
metadata:
52+
name: power-monitor
53+
spec:
54+
kepler:
55+
config:
56+
logLevel: info
57+
additionalConfigMaps:
58+
- name: my-kepler-config
59+
deployment:
60+
security:
61+
mode: none
62+
```
63+
64+
Apply the updated PowerMonitor CR:
65+
66+
```bash
67+
kubectl apply -f power-monitor.yaml
68+
```
69+
70+
### ✔️ Step 3: Verify the Configuration
71+
72+
The operator will automatically reconcile the DaemonSet with your new configuration. You can monitor the rollout:
73+
74+
```bash
75+
# Check PowerMonitor status
76+
kubectl get powermonitor power-monitor
77+
78+
# Watch DaemonSet rollout
79+
kubectl rollout status daemonset/power-monitor -n power-monitor
80+
81+
# Verify the ConfigMap is mounted
82+
kubectl describe daemonset power-monitor -n power-monitor
83+
```
84+
85+
## 💡 Configuration Examples
86+
87+
### 📤 Example 1: Enabling the Stdout Exporter
88+
89+
```yaml
90+
apiVersion: v1
91+
kind: ConfigMap
92+
metadata:
93+
name: kepler-stdout-config
94+
namespace: power-monitor
95+
data:
96+
config.yaml: |
97+
exporter:
98+
stdout:
99+
enabled: true
100+
```
101+
102+
### 📊 Example 2: Customizing Prometheus Exporter Settings
103+
104+
```yaml
105+
apiVersion: v1
106+
kind: ConfigMap
107+
metadata:
108+
name: kepler-prometheus-config
109+
namespace: power-monitor
110+
data:
111+
config.yaml: |
112+
exporter:
113+
prometheus:
114+
enabled: true
115+
debugCollectors:
116+
- go
117+
```
118+
119+
### 🔧 Example 3: Enabling Development Features
120+
121+
Enable fake CPU meter for testing environments:
122+
123+
```yaml
124+
apiVersion: v1
125+
kind: ConfigMap
126+
metadata:
127+
name: kepler-dev-config
128+
namespace: power-monitor
129+
data:
130+
config.yaml: |
131+
dev:
132+
fake-cpu-meter:
133+
enabled: true
134+
```
135+
136+
### 🐛 Example 4: Enabling pprof Debug Endpoints
137+
138+
```yaml
139+
apiVersion: v1
140+
kind: ConfigMap
141+
metadata:
142+
name: kepler-pprof-config
143+
namespace: power-monitor
144+
data:
145+
config.yaml: |
146+
debug:
147+
pprof:
148+
enabled: true
149+
```
150+
151+
## 🗂️ Using Multiple ConfigMaps
152+
153+
You can reference multiple ConfigMaps to organize your configuration. The operator merges them in the order specified:
154+
155+
```yaml
156+
spec:
157+
kepler:
158+
config:
159+
additionalConfigMaps:
160+
- name: my-kepler-config
161+
- name: kepler-stdout-config
162+
- name: kepler-prometheus-config
163+
- name: kepler-dev-config
164+
- name: kepler-pprof-config
165+
```
166+
167+
**📌 Note:** If there are conflicting settings across multiple ConfigMaps, the later ConfigMap in the list takes precedence.
168+
169+
**💡 Tip:** Settings controlled by `spec.kepler.config` still override the merged ConfigMap values. Use `additionalConfigMaps` only for fields that are not exposed in the CR spec.
170+
171+
## 🔄 Updating Configuration
172+
173+
To update Kepler's configuration:
174+
175+
1. **Update the ConfigMap:**
176+
177+
```bash
178+
kubectl edit configmap my-kepler-config -n power-monitor
179+
```
180+
181+
2. **The operator automatically detects the change** and triggers a DaemonSet rollout with the updated configuration.
182+
183+
3. **Monitor the rollout:**
184+
185+
```bash
186+
kubectl rollout status daemonset/power-monitor -n power-monitor
187+
```
188+
189+
## 🔍 Troubleshooting
190+
191+
### ❌ ConfigMap Not Found
192+
193+
If you see an error like `configMap my-kepler-config not found in power-monitor namespace`:
194+
195+
1. Verify the ConfigMap exists:
196+
197+
```bash
198+
kubectl get configmap my-kepler-config -n power-monitor
199+
```
200+
201+
2. Ensure the namespace matches your PowerMonitor deployment namespace
202+
203+
3. Check the ConfigMap name is correctly spelled in the PowerMonitor CR
204+
205+
### ⚠️ Configuration Not Applied
206+
207+
If your configuration changes aren't taking effect:
208+
209+
1. Check the PowerMonitor status for reconciliation errors:
210+
211+
```bash
212+
kubectl describe powermonitor power-monitor
213+
```
214+
215+
2. Verify the ConfigMap has the correct structure with a `config.yaml` key:
216+
217+
```bash
218+
kubectl get configmap my-kepler-config -n power-monitor -o yaml
219+
```
220+
221+
3. Check the operator logs:
222+
223+
```bash
224+
kubectl logs -n openshift-operators deployment/kepler-operator-controller-manager
225+
```
226+
227+
### 🔁 DaemonSet Not Rolling Out
228+
229+
If the DaemonSet doesn't roll out after updating the ConfigMap:
230+
231+
1. Check if the ConfigMap hash annotation changed:
232+
233+
```bash
234+
kubectl get daemonset power-monitor -n power-monitor -o jsonpath='{.spec.template.metadata.annotations}'
235+
```
236+
237+
2. Manually trigger a rollout:
238+
239+
```bash
240+
kubectl rollout restart daemonset/power-monitor -n power-monitor
241+
```
242+
243+
## ⭐ Best Practices
244+
245+
1. **Use Descriptive Names:** Name your ConfigMaps descriptively (e.g., `kepler-production-config`, `kepler-dev-settings`)
246+
247+
2. **Test Before Production:** Test configuration changes in a development environment first
248+
249+
3. **Monitor Changes:** Watch the DaemonSet rollout after making configuration changes
250+
251+
4. **Validate YAML:** Ensure your `config.yaml` is valid YAML before creating the ConfigMap
252+
253+
5. **Document Changes:** Add comments or annotations to explain why specific configurations were chosen
254+
255+
6. **Use Multiple ConfigMaps:** Separate concerns by using different ConfigMaps for different aspects (e.g., metrics, performance, debugging)
256+
257+
## 📚 Related Resources
258+
259+
- [PowerMonitor API Reference](../api.md#powermonitor)
260+
- [Kepler Configuration Reference](https://sustainable-computing.io/kepler/usage/configuration/)
261+
- [Kepler Documentation](https://sustainable-computing.io/)
262+
263+
## 💬 Additional Support
264+
265+
For more information or help:
266+
267+
- Visit the [Kepler Operator repository](https://github.com/sustainable-computing-io/kepler-operator)
268+
- File an issue on [GitHub](https://github.com/sustainable-computing-io/kepler-operator/issues)

0 commit comments

Comments
 (0)