@@ -17,6 +17,11 @@ This cluster operator gathers anonymized system configuration and reports it to
17
17
- [ Changelog] ( #changelog )
18
18
- [ Updating the changelog] ( #updating-the-changelog )
19
19
- [ Reported data] ( #reported-data )
20
+ - [ Insights Operator Archive] ( #insights-operator-archive )
21
+ - [ Sample IO archive] ( #sample-io-archive )
22
+ - [ Generating a sample archive] ( #generating-a-sample-archive )
23
+ - [ Formatting archive json files] ( #formatting-archive-json-files )
24
+ - [ Obfuscating an archive] ( #obfuscating-an-archive )
20
25
- [ Contributing] ( #contributing )
21
26
- [ Support] ( #support )
22
27
- [ License] ( #license )
@@ -25,14 +30,14 @@ This cluster operator gathers anonymized system configuration and reports it to
25
30
26
31
To build the operator, install Go 1.11 or above and run:
27
32
28
- ```
29
- $ make build
33
+ ``` shell script
34
+ make build
30
35
```
31
36
32
37
To test the operator against a remote cluster, run:
33
38
34
- ``` sh
35
- $ bin/insights-operator start --config=config/local.yaml --kubeconfig=$KUBECONFIG
39
+ ``` shell script
40
+ bin/insights-operator start --config=config/local.yaml --kubeconfig=$KUBECONFIG
36
41
```
37
42
38
43
where ` $KUBECONFIG ` has sufficiently high permissions against the target cluster.
@@ -41,14 +46,14 @@ where `$KUBECONFIG` has sufficiently high permissions against the target cluster
41
46
42
47
Unit tests can be started by the following command:
43
48
44
- ``` sh
45
- $ make test
49
+ ``` shell script
50
+ make test
46
51
```
47
52
48
53
It is also possible to specify CLI options for Go test. For example, if you need to disable test results caching, use the following command:
49
54
50
- ``` sh
51
- $ VERBOSE=-count=1 make test
55
+ ``` shell script
56
+ VERBOSE=-count=1 make test
52
57
```
53
58
54
59
> Integration (e2e) tests are not part of this repository, you can find it [ here] ( https://gitlab.cee.redhat.com/ccx/insights-operator-tests ) .
@@ -60,8 +65,8 @@ The document [docs/gathered-data](docs/gathered-data.md) contains the list of co
60
65
61
66
To start generating the document run:
62
67
63
- ``` sh
64
- $ make docs
68
+ ``` shell script
69
+ make docs
65
70
```
66
71
67
72
# Getting metrics from Prometheus
@@ -72,8 +77,8 @@ Certificate and key are required to access Prometheus metrics (instead 404 Forbi
72
77
73
78
There's a tool named ` gen_cert_key.py ` that can be used to automatically generate both files. It is stored in ` tools ` subdirectory.
74
79
75
- ``` sh
76
- $ gen_cert_file.py kubeconfig.yaml
80
+ ``` shell script
81
+ gen_cert_file.py kubeconfig.yaml
77
82
```
78
83
79
84
## Prometheus metrics provided by Insights Operator
@@ -86,49 +91,49 @@ Depending on how or where the IO is running you may have different ways to retri
86
91
87
92
If the IO runs locally, the following command migth be used:
88
93
89
- ``` sh
90
- $ curl --cert k8s.crt --key k8s.key -k https://localhost:8443/metrics
94
+ ``` shell script
95
+ curl --cert k8s.crt --key k8s.key -k https://localhost:8443/metrics
91
96
```
92
97
93
98
### Running IO on K8s
94
99
95
100
Get the token
96
101
97
- ``` sh
98
- $ oc whoami -t
102
+ ``` shell script
103
+ oc whoami -t
99
104
```
100
105
101
106
Read metrics from Pod
102
107
103
- ``` sh
104
- $ oc exec \
108
+ ``` shell script
109
+ oc exec \
105
110
-it deployment/insights-operator \
106
111
-n openshift-insights -- \
107
112
curl -k -H " Authorization: Bearer YOUR-TOKEN-HERE" ' https://localhost:8443/metrics'
108
113
```
109
114
110
115
## Getting the data directly from Prometheus
111
116
112
- ``` sh
113
- $ sudo kubefwd svc -n openshift-monitoring -d openshift-monitoring.svc -l prometheus=k8s
114
- $ curl --cert k8s.crt --key k8s.key -k ' https://prometheus-k8s.openshift-monitoring.svc:9091/metrics'
117
+ ``` shell script
118
+ sudo kubefwd svc -n openshift-monitoring -d openshift-monitoring.svc -l prometheus=k8s
119
+ curl --cert k8s.crt --key k8s.key -k ' https://prometheus-k8s.openshift-monitoring.svc:9091/metrics'
115
120
```
116
121
117
122
## Debugging Prometheus metrics without valid CA
118
123
119
124
Get the token
120
125
121
- ``` sh
122
- $ oc sa get-token prometheus-k8s -n openshift-monitoring
126
+ ``` shell script
127
+ oc sa get-token prometheus-k8s -n openshift-monitoring
123
128
```
124
129
125
130
Change in ` pkg/controller/operator.go ` after creating ` metricsGatherKubeConfig ` (about line #86 )
126
131
127
- ``` ini
132
+ ``` go
128
133
metricsGatherKubeConfig.Insecure = true
129
134
metricsGatherKubeConfig.BearerToken = " YOUR-TOKEN-HERE"
130
135
# by default CAFile is /var /run/secrets/kubernetes.io /serviceaccount/service-ca.crt
131
- metricsGatherKubeConfig.CAFile = " "
136
+ metricsGatherKubeConfig.CAFile = " "
132
137
metricsGatherKubeConfig.CAData = []byte {}
133
138
```
134
139
@@ -141,8 +146,8 @@ metricsGatherKubeConfig.CAData = []byte{}
141
146
IO starts a profiler if given the correct environment.
142
147
Set the ` OPENSHIFT_PROFILE ` env variable to "web".
143
148
144
- ``` sh
145
- $ export OPENSHIFT_PROFILE=web
149
+ ``` shell script
150
+ export OPENSHIFT_PROFILE=web
146
151
```
147
152
148
153
### Collect profiling data
@@ -151,14 +156,14 @@ After IO starts the profiling can be accessed at `http://localhost:6060`, you ca
151
156
152
157
Some profiling examples:
153
158
154
- ``` sh
159
+ ``` shell script
155
160
# CPU profiling for 30 seconds
156
- $ go tool pprof http://localhost:6060/debug/pprof/profile? seconds=30
161
+ go tool pprof http://localhost:6060/debug/pprof/profile? seconds=30
157
162
```
158
163
159
- ``` sh
164
+ ``` shell script
160
165
# heap profiling
161
- $ go tool pprof http://localhost:6060/debug/pprof/heap
166
+ go tool pprof http://localhost:6060/debug/pprof/heap
162
167
```
163
168
164
169
These commands will create a compressed file that can be visualized using a variety of tools, one of them is the ` pprof ` tool.
@@ -167,8 +172,8 @@ These commands will create a compressed file that can be visualized using a vari
167
172
168
173
Starting a web ui at ` localhost:8080 ` to visualize/analyze the profiling data:
169
174
170
- ``` sh
171
- $ go tool pprof -http=:8080 /path/to/profiling.out
175
+ ``` shell script
176
+ go tool pprof -http=:8080 /path/to/profiling.out
172
177
```
173
178
174
179
For extra info: [ check this link] ( https://jvns.ca/blog/2017/09/24/profiling-go-with-pprof/ )
@@ -192,14 +197,14 @@ It can be used 2 ways:
192
197
193
198
> 🚨 IMPORTANT: It will only work with changelogs created with this script
194
199
195
- ``` sh
196
- $ go run cmd/changelog/main.go
200
+ ``` shell script
201
+ go run cmd/changelog/main.go
197
202
```
198
203
199
204
2 . Providing 2 command line arguments, ` AFTER ` and ` UNTIL ` dates the script will generate a new ` CHANGELOG.md ` within the provided time frame.
200
205
201
- ``` sh
202
- $ go run cmd/changelog/main.go 2021-01-10 2021-01-20
206
+ ``` shell script
207
+ go run cmd/changelog/main.go 2021-01-10 2021-01-20
203
208
```
204
209
205
210
# Reported data
@@ -221,7 +226,7 @@ There is a sample IO archive maintained in this repo to use as a quick reference
221
226
To keep it up-to-date it is ** required** to update this manually when developing a new data enhancement.
222
227
223
228
Make sure the ` .json ` files are in a humanly readable format in the sample archive.
224
- By doing this its easier to review a data enhancement PR, and rule developers can easily check what data it collects.
229
+ By doing this its easier to review a data enhancement PR, and rule developers can easily check what data it collects.
225
230
226
231
### Generating a sample archive
227
232
@@ -231,10 +236,21 @@ Run the insights-operator on a test cluster (from `cluster-bot` or `Quicklab` or
231
236
232
237
This formats ` .json ` files from folder with extracted archive.
233
238
234
- ``` sh
235
- $ find . -type f -name ' *.json' -print | while read line; do cat " $line " | jq > " $line .tmp" && mv " $line .tmp" " $line " ; done
239
+ ``` shell script
240
+ find . -type f -name ' *.json' -print | while read line; do cat " $line " | jq > " $line .tmp" && mv " $line .tmp" " $line " ; done
241
+ ```
242
+
243
+ ### Obfuscating an archive
244
+
245
+ You can run obfuscation with an archive by running the next command:
246
+
247
+ ``` shell script
248
+ go run ./cmd/obfuscate-archive/main.go YOUR_ARCHIVE.tar.gz
236
249
```
237
250
251
+ where ` YOUR_ARCHIVE.tar.gz ` is the path to the archive.
252
+ The obfuscated version will be created in the same directory and called ` YOUR_ARCHIVE-obfuscated.tar.gz `
253
+
238
254
# Contributing
239
255
240
256
See [ CONTRIBUTING] ( CONTRIBUTING.md ) for workflow & convention details.
@@ -248,4 +264,4 @@ file a ticket [in Red Hat Bugzilla](https://bugzilla.redhat.com/enter_bug.cgi?pr
248
264
249
265
# License
250
266
251
- This project is licensed by the Apache License 2.0. For more information check the LICENSE file.
267
+ This project is licensed by the Apache License 2.0. For more information check the LICENSE file.
0 commit comments