Skip to content

Commit d10514a

Browse files
author
Serhii Zakharov
authored
Make obfuscation work with a provided archive (#450)
* make obfuscation work with a provided archive * calm down linters * fixes after review * fixed installer version * print on success * fixed issue with the base domain * made docs prettier * removed base domain from the new config map * updated cluster-config-v1.json example
1 parent f1c5394 commit d10514a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1922
-99
lines changed

CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This is a rough outline of what a contributor's workflow looks like:
1919
- Make sure the tests and liting pass, and add any new tests as appropriate.
2020
- Submit a pull request to the original repository.
2121

22-
> 🎯 Tip: make sure to install the githook using the command: `$ make githooks`
22+
> 🎯 Tip: make sure to install the githook using the command: `make githooks`
2323
2424
## Format of the Commit Message
2525

@@ -39,8 +39,8 @@ and liting and prevent bad commits.
3939
## Pull Request Formats
4040

4141
Pull Requests should use the template provided, and
42-
follow the template instructions. For those that implement new
43-
enchancements or backporting must have on its own title the reference
42+
follow the template instructions. For those that implement new
43+
enchancements or backporting must have on its own title the reference
4444
to the Bugzilla bug.
4545

4646

@@ -61,4 +61,4 @@ Bug 1940432: Gahter datahubs.installers.datahub.sap.com resources from SAP clust
6161
Branches for previous releases follow the format `release-X.Y`, for example,
6262
`release-4.1`. Typically, bugs are fixed in the master branch first then
6363
backported to the appropriate release branches. Fixes backported to previous
64-
releases should have a Bugzilla bug for each version fixed.
64+
releases should have a Bugzilla bug for each version fixed.

README.md

+57-41
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ This cluster operator gathers anonymized system configuration and reports it to
1717
- [Changelog](#changelog)
1818
- [Updating the changelog](#updating-the-changelog)
1919
- [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)
2025
- [Contributing](#contributing)
2126
- [Support](#support)
2227
- [License](#license)
@@ -25,14 +30,14 @@ This cluster operator gathers anonymized system configuration and reports it to
2530

2631
To build the operator, install Go 1.11 or above and run:
2732

28-
```
29-
$ make build
33+
```shell script
34+
make build
3035
```
3136

3237
To test the operator against a remote cluster, run:
3338

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
3641
```
3742

3843
where `$KUBECONFIG` has sufficiently high permissions against the target cluster.
@@ -41,14 +46,14 @@ where `$KUBECONFIG` has sufficiently high permissions against the target cluster
4146

4247
Unit tests can be started by the following command:
4348

44-
```sh
45-
$ make test
49+
```shell script
50+
make test
4651
```
4752

4853
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:
4954

50-
```sh
51-
$ VERBOSE=-count=1 make test
55+
```shell script
56+
VERBOSE=-count=1 make test
5257
```
5358

5459
> 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
6065

6166
To start generating the document run:
6267

63-
```sh
64-
$ make docs
68+
```shell script
69+
make docs
6570
```
6671

6772
# Getting metrics from Prometheus
@@ -72,8 +77,8 @@ Certificate and key are required to access Prometheus metrics (instead 404 Forbi
7277

7378
There's a tool named `gen_cert_key.py` that can be used to automatically generate both files. It is stored in `tools` subdirectory.
7479

75-
```sh
76-
$ gen_cert_file.py kubeconfig.yaml
80+
```shell script
81+
gen_cert_file.py kubeconfig.yaml
7782
```
7883

7984
## 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
8691

8792
If the IO runs locally, the following command migth be used:
8893

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
9196
```
9297

9398
### Running IO on K8s
9499

95100
Get the token
96101

97-
```sh
98-
$ oc whoami -t
102+
```shell script
103+
oc whoami -t
99104
```
100105

101106
Read metrics from Pod
102107

103-
```sh
104-
$ oc exec \
108+
```shell script
109+
oc exec \
105110
-it deployment/insights-operator \
106111
-n openshift-insights -- \
107112
curl -k -H "Authorization: Bearer YOUR-TOKEN-HERE" 'https://localhost:8443/metrics'
108113
```
109114

110115
## Getting the data directly from Prometheus
111116

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'
115120
```
116121

117122
## Debugging Prometheus metrics without valid CA
118123

119124
Get the token
120125

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
123128
```
124129

125130
Change in `pkg/controller/operator.go` after creating `metricsGatherKubeConfig` (about line #86)
126131

127-
```ini
132+
```go
128133
metricsGatherKubeConfig.Insecure = true
129134
metricsGatherKubeConfig.BearerToken = "YOUR-TOKEN-HERE"
130135
# by default CAFile is /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt
131-
metricsGatherKubeConfig.CAFile = ""
136+
metricsGatherKubeConfig.CAFile = ""
132137
metricsGatherKubeConfig.CAData = []byte{}
133138
```
134139

@@ -141,8 +146,8 @@ metricsGatherKubeConfig.CAData = []byte{}
141146
IO starts a profiler if given the correct environment.
142147
Set the `OPENSHIFT_PROFILE` env variable to "web".
143148

144-
```sh
145-
$ export OPENSHIFT_PROFILE=web
149+
```shell script
150+
export OPENSHIFT_PROFILE=web
146151
```
147152

148153
### Collect profiling data
@@ -151,14 +156,14 @@ After IO starts the profiling can be accessed at `http://localhost:6060`, you ca
151156

152157
Some profiling examples:
153158

154-
```sh
159+
```shell script
155160
# 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
157162
```
158163

159-
```sh
164+
```shell script
160165
# heap profiling
161-
$ go tool pprof http://localhost:6060/debug/pprof/heap
166+
go tool pprof http://localhost:6060/debug/pprof/heap
162167
```
163168

164169
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
167172

168173
Starting a web ui at `localhost:8080` to visualize/analyze the profiling data:
169174

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
172177
```
173178

174179
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:
192197

193198
> 🚨 IMPORTANT: It will only work with changelogs created with this script
194199
195-
```sh
196-
$ go run cmd/changelog/main.go
200+
```shell script
201+
go run cmd/changelog/main.go
197202
```
198203

199204
2. Providing 2 command line arguments, `AFTER` and `UNTIL` dates the script will generate a new `CHANGELOG.md` within the provided time frame.
200205

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
203208
```
204209

205210
# Reported data
@@ -221,7 +226,7 @@ There is a sample IO archive maintained in this repo to use as a quick reference
221226
To keep it up-to-date it is **required** to update this manually when developing a new data enhancement.
222227

223228
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.
225230

226231
### Generating a sample archive
227232

@@ -231,10 +236,21 @@ Run the insights-operator on a test cluster (from `cluster-bot` or `Quicklab` or
231236

232237
This formats `.json` files from folder with extracted archive.
233238

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
236249
```
237250

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+
238254
# Contributing
239255

240256
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
248264

249265
# License
250266

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

Comments
 (0)