1
- import { exec } from "../util/shell" ;
2
- import { Werft } from "../util/werft" ;
3
- import * as fs from "fs" ;
1
+ import { exec } from "../util/shell" ;
2
+ import { Werft } from "../util/werft" ;
4
3
5
4
type MonitoringSatelliteInstallerOptions = {
6
5
werft : Werft ;
@@ -20,7 +19,8 @@ const sliceName = "observability";
20
19
* Installs monitoring-satellite, while updating its dependencies to the latest commit in the branch it is running.
21
20
*/
22
21
export class MonitoringSatelliteInstaller {
23
- constructor ( private readonly options : MonitoringSatelliteInstallerOptions ) { }
22
+ constructor ( private readonly options : MonitoringSatelliteInstallerOptions ) {
23
+ }
24
24
25
25
public async install ( ) {
26
26
const {
@@ -31,94 +31,16 @@ export class MonitoringSatelliteInstaller {
31
31
32
32
werft . log (
33
33
sliceName ,
34
- `Cloning observability repository - Branch: ${ branch } ` ,
35
- ) ;
36
- exec (
37
- `git clone --branch ${ branch } https://roboquat:$(cat /mnt/secrets/monitoring-satellite-preview-token/token)@github.com/gitpod-io/observability.git` ,
38
- { silent : true } ,
39
- ) ;
40
- let currentCommit = exec ( `git rev-parse HEAD` , { silent : true } ) . stdout . trim ( ) ;
41
- let pwd = exec ( `pwd` , { silent : true } ) . stdout . trim ( ) ;
42
- werft . log (
43
- sliceName ,
44
- `Updating Gitpod's mixin in monitoring-satellite's jsonnetfile.json to latest commit SHA: ${ currentCommit } ` ,
34
+ `Installing observability stack - Branch: ${ branch } ` ,
45
35
) ;
46
36
47
- let jsonnetFile = JSON . parse ( fs . readFileSync ( `${ pwd } /observability/jsonnetfile.json` , "utf8" ) ) ;
48
- jsonnetFile . dependencies . forEach ( ( dep ) => {
49
- if ( dep . name == "gitpod" ) {
50
- dep . version = currentCommit ;
51
- }
52
- } ) ;
53
- fs . writeFileSync ( `${ pwd } /observability/jsonnetfile.json` , JSON . stringify ( jsonnetFile ) ) ;
54
- exec ( `cd observability && jb update` , { slice : sliceName } ) ;
55
-
56
- // As YAML is indentation sensitive we're using json instead so we don't have to worry about
57
- // getting the indentation right when formatting the code in TypeScript.
58
- const observabilityInstallerRenderCmd = `cd observability && \
59
- make generate && \
60
- ./hack/deploy-crds.sh --kubeconfig ${ this . options . kubeconfigPath } && \
61
- kubectl create ns monitoring-satellite --kubeconfig ${ this . options . kubeconfigPath } || true && \
62
- cd installer && echo '
63
- {
64
- "gitpod": {
65
- "installServiceMonitors": true
66
- },
67
- "pyrra": {
68
- "install": true
69
- },
70
- "prometheus": {
71
- "externalLabels": {
72
- "cluster": "${ previewName } ",
73
- "environment": "preview-environments",
74
- },
75
- "resources": {
76
- "requests": {
77
- "memory": "200Mi",
78
- "cpu": "50m",
79
- },
80
- },
81
- "remoteWrite": [{
82
- "username": "${ process . env . PROM_REMOTE_WRITE_USER } ",
83
- "password": "${ process . env . PROM_REMOTE_WRITE_PASSWORD } ",
84
- "url": "https://victoriametrics.gitpod.io/api/v1/write",
85
- "writeRelabelConfigs": [{
86
- "sourceLabels": ["__name__", "job"],
87
- "separator": ";",
88
- "regex": "rest_client_requests_total.*|http_prober_.*",
89
- "action": "keep",
90
- }],
91
- }],
92
- },
93
- "imports": {
94
- "yaml": [{
95
- "gitURL": "https://github.com/gitpod-io/observability",
96
- "path": "monitoring-satellite/manifests/kube-prometheus-rules",
97
- },
98
- {
99
- "gitURL": "https://github.com/gitpod-io/observability",
100
- "path": "monitoring-satellite/manifests/kubescape",
101
- },
102
- {
103
- "gitURL": "https://github.com/gitpod-io/observability",
104
- "path": "monitoring-satellite/manifests/grafana",
105
- },
106
- {
107
- "gitURL": "https://github.com/gitpod-io/observability",
108
- "path": "monitoring-satellite/manifests/probers",
109
- }],
110
- },
111
- }' | go run main.go render --config - | kubectl --kubeconfig ${ this . options . kubeconfigPath } apply -f -` ;
112
- const renderingResult = exec ( observabilityInstallerRenderCmd , { silent : false , dontCheckRc : true } ) ;
113
- if ( renderingResult . code > 0 ) {
114
- const err = new Error ( `Failed rendering YAML with exit code ${ renderingResult . code } ` )
115
- renderingResult . stderr . split ( '\n' ) . forEach ( stderrLine => werft . log ( sliceName , stderrLine ) )
116
- werft . failSlice ( sliceName , err )
117
- return
118
- }
37
+ const installSatellite = exec ( `KUBE_PATH=${ this . options . kubeconfigPath } PREVIEW_NAME=${ previewName } .werft/observability/install-satellite.sh` , { slice : sliceName } ) ;
119
38
120
- // The grafana YAML files we're importing have nodeSelector tied to a nodepool that don't exist in previews
121
- // We're hot-patching the removal os such nodeSelector to make sure Grafana starts
122
- exec ( `kubectl patch deployments.apps -n monitoring-satellite grafana --type=json -p="[{'op': 'remove', 'path': '/spec/template/spec/nodeSelector'}]"` )
39
+ if ( installSatellite . code > 0 ) {
40
+ const err = new Error ( `Failed installing monitoring-satellite` )
41
+ installSatellite . stderr . split ( '\n' ) . forEach ( stderrLine => werft . log ( sliceName , stderrLine ) )
42
+ werft . failSlice ( sliceName , err )
43
+ return
44
+ }
123
45
}
124
46
}
0 commit comments