7
7
# Don't track us.
8
8
analytics_settings (False )
9
9
10
- # The upgrade job may take a long time to run, so it is disabled by default.
11
- enable_postgres_upgrade = False
12
-
13
10
if not os .getenv ('TILT_VALUES_PATH' ):
14
11
fail ("TILT_VALUES_PATH is not set." )
15
12
if not os .path .exists (os .getenv ('TILT_VALUES_PATH' )):
16
13
fail ("TILT_VALUES_PATH " + os .getenv ('TILT_VALUES_PATH' ) + " does not exist." )
17
14
15
+ # The upgrade job may take a long time to run, so it is disabled by default.
16
+ enable_postgres_upgrade = False
17
+
18
18
load ('ext://helm_resource' , 'helm_resource' , 'helm_repo' )
19
19
helm_repo (
20
20
'Bitnami Helm Repo' ,
@@ -27,93 +27,16 @@ helm_repo(
27
27
labels = ['Repositories' ],
28
28
)
29
29
30
- ########### Cortex Core Services
31
- tilt_values = os .getenv ('TILT_VALUES_PATH' )
32
- docker_build ('ghcr.io/cobaltcore-dev/cortex' , '.' , only = [
33
- 'internal/' , 'commands/' , 'main.go' , 'go.mod' , 'go.sum' , 'Makefile' ,
34
- ])
35
- local ('sh helm/sync.sh helm/cortex' )
36
- k8s_yaml (helm ('./helm/cortex' , name = 'cortex' , values = [tilt_values ]))
37
- k8s_resource ('cortex-syncer' , port_forwards = [
38
- port_forward (8001 , 2112 ),
39
- ], links = [
40
- link ('localhost:8001/metrics' , '/metrics' ),
41
- ], labels = ['Core-Services' ])
42
- k8s_resource ('cortex-extractor' , port_forwards = [
43
- port_forward (8002 , 2112 ),
44
- ], links = [
45
- link ('localhost:8002/metrics' , '/metrics' ),
46
- ], labels = ['Core-Services' ])
47
- k8s_resource ('cortex-scheduler-nova' , port_forwards = [
48
- port_forward (8003 , 8080 ),
49
- port_forward (8004 , 2112 ),
50
- ], links = [
51
- link ('localhost:8004/metrics' , '/metrics' ),
52
- ], labels = ['Core-Services' ])
53
- k8s_resource ('cortex-scheduler-manila' , port_forwards = [
54
- port_forward (8005 , 8080 ),
55
- port_forward (8006 , 2112 ),
56
- ], links = [
57
- link ('localhost:8006/metrics' , '/metrics' ),
58
- ], labels = ['Core-Services' ])
59
- k8s_resource ('cortex-kpis' , port_forwards = [
60
- port_forward (8007 , 2112 ),
61
- ], links = [
62
- link ('localhost:8007/metrics' , '/metrics' ),
63
- ], labels = ['Core-Services' ])
64
- k8s_resource ('cortex-descheduler-nova' , port_forwards = [
65
- port_forward (8008 , 2112 ),
66
- ], links = [
67
- link ('localhost:8008/metrics' , '/metrics' ),
68
- ], labels = ['Core-Services' ])
69
-
70
- ########### Cortex Commands
71
- k8s_resource ('cortex-cli' , labels = ['Commands' ])
72
- local_resource (
73
- 'Run E2E Tests' ,
74
- 'kubectl exec -it deploy/cortex-cli -- /usr/bin/cortex checks' ,
75
- deps = ['./internal/checks' ],
76
- labels = ['Commands' ],
77
- trigger_mode = TRIGGER_MODE_MANUAL ,
78
- auto_init = False ,
79
- )
80
- k8s_resource ('cortex-migrations' , labels = ['Commands' ])
81
-
82
- ########### RabbitMQ MQTT for Cortex Core Service
83
- local ('sh helm/sync.sh helm/cortex-mqtt' )
84
- k8s_yaml (helm ('./helm/cortex-mqtt' , name = 'cortex-mqtt' ))
85
- k8s_resource ('cortex-mqtt' , port_forwards = [
86
- port_forward (1883 , 1883 ), # Direct TCP connection
87
- port_forward (9000 , 15675 ), # Websocket connection
88
- ], labels = ['Core-Services' ])
89
-
90
- ########### Postgres DB for Cortex Core Service
91
- local ('sh helm/sync.sh helm/cortex-postgres' )
92
- job_flag = 'upgradeJob.enabled=' + str (enable_postgres_upgrade ).lower ()
93
- k8s_yaml (helm ('./helm/cortex-postgres' , name = 'cortex-postgres' , set = job_flag ))
94
- k8s_resource ('cortex-postgresql' , port_forwards = [
95
- port_forward (5432 , 5432 ),
96
- ], labels = ['Database' ])
97
- if enable_postgres_upgrade :
98
- # Get the version from the chart.
99
- cmd = "helm show chart ./helm/cortex-postgres | grep -E '^version:' | awk '{print $2}'"
100
- chart_version = str (local (cmd )).strip ()
101
- # Use the chart version to name the pre-upgrade job.
102
- k8s_resource ('cortex-postgresql-pre-upgrade-' + chart_version , labels = ['Database' ])
103
- k8s_resource ('cortex-postgresql-post-upgrade-' + chart_version , labels = ['Database' ])
104
-
105
- ########### Monitoring
106
- local ('sh helm/sync.sh helm/cortex-prometheus-operator' )
107
- k8s_yaml (helm ('./helm/cortex-prometheus-operator' , name = 'cortex-prometheus-operator' )) # Operator
108
- local ('sh helm/sync.sh helm/cortex-prometheus' )
109
- k8s_yaml (helm ('./helm/cortex-prometheus' , name = 'cortex-prometheus' )) # Alerts + ServiceMonitor
30
+ ########### Dev Dependencies
31
+ local ('sh helm/sync.sh helm/dev/cortex-prometheus-operator' )
32
+ k8s_yaml (helm ('./helm/dev/cortex-prometheus-operator' , name = 'cortex-prometheus-operator' )) # Operator
110
33
k8s_resource ('cortex-prometheus-operator' , labels = ['Monitoring' ])
111
34
k8s_resource (
112
35
new_name = 'cortex-prometheus' ,
113
- port_forwards = [port_forward (9090 , 9090 )],
36
+ port_forwards = [port_forward (3000 , 9090 )],
114
37
links = [
115
- link ('http://localhost:9090 ' , 'metrics' ),
116
- link ('http://localhost:9090 /alerts' , 'alerts' ),
38
+ link ('http://localhost:3000 ' , 'metrics' ),
39
+ link ('http://localhost:3000 /alerts' , 'alerts' ),
117
40
],
118
41
objects = ['cortex-prometheus:Prometheus:default' ],
119
42
labels = ['Monitoring' ],
@@ -126,17 +49,120 @@ k8s_resource(
126
49
docker_build ('cortex-visualizer' , 'visualizer' )
127
50
k8s_yaml ('./visualizer/app.yaml' )
128
51
k8s_resource ('cortex-visualizer' , port_forwards = [
129
- port_forward (8009 , 80 ),
52
+ port_forward (4000 , 80 ),
130
53
], links = [
131
- link ('localhost:8009 /nova.html' , 'nova visualizer' ),
132
- link ('localhost:8009 /manila.html' , 'manila visualizer' ),
54
+ link ('localhost:4000 /nova.html' , 'nova visualizer' ),
55
+ link ('localhost:4000 /manila.html' , 'manila visualizer' ),
133
56
], labels = ['Monitoring' ])
134
-
135
- ########### Plutono (Grafana Fork)
136
57
docker_build ('cortex-plutono' , 'plutono' )
137
58
k8s_yaml ('./plutono/app.yaml' )
138
59
k8s_resource ('cortex-plutono' , port_forwards = [
139
- port_forward (3000 , 3000 , name = 'plutono' ),
60
+ port_forward (5000 , 3000 , name = 'plutono' ),
140
61
], links = [
141
- link ('http://localhost:3000 /d/cortex/cortex?orgId=1' , 'cortex dashboard' ),
62
+ link ('http://localhost:5000 /d/cortex/cortex?orgId=1' , 'cortex dashboard' ),
142
63
], labels = ['Monitoring' ])
64
+
65
+ ########### Cortex Bundles
66
+ tilt_values = os .getenv ('TILT_VALUES_PATH' )
67
+ docker_build ('ghcr.io/cobaltcore-dev/cortex' , '.' , only = [
68
+ 'internal/' , 'commands/' , 'main.go' , 'go.mod' , 'go.sum' , 'Makefile' ,
69
+ ])
70
+
71
+ # Package the lib charts locally and sync them to the bundle charts. In this way
72
+ # we can bump the lib charts locally and test them before pushing them to the OCI registry.
73
+ lib_charts = ['cortex-core' , 'cortex-postgres' , 'cortex-mqtt' ]
74
+ bundle_charts = ['cortex-nova' , 'cortex-manila' ]
75
+ for lib_chart in lib_charts :
76
+ watch_file ('helm/library/' + lib_chart ) # React to lib chart changes.
77
+ local ('sh helm/sync.sh helm/library/' + lib_chart )
78
+ for bundle_chart in bundle_charts :
79
+ local ('helm package helm/library/' + lib_chart )
80
+ gen_tgz = str (local ('ls ' + lib_chart + '-*.tgz' )).strip ()
81
+ cmp = 'sh helm/cmp.sh ' + gen_tgz + ' helm/bundles/' + bundle_chart + '/charts/' + gen_tgz
82
+ cmp_result = str (local (cmp )).strip ()
83
+ if cmp_result == 'true' : # same chart
84
+ print ('Skipping ' + lib_chart + ' as it is already up to date in ' + bundle_chart )
85
+ # Make sure the gen_tgz is removed from the local directory.
86
+ local ('rm -f ' + gen_tgz )
87
+ else :
88
+ local ('mv -f ' + gen_tgz + ' helm/bundles/' + bundle_chart + '/charts/' )
89
+ # Ensure the bundle charts are up to date.
90
+ for bundle_chart in bundle_charts :
91
+ local ('sh helm/sync.sh helm/bundles/' + bundle_chart )
92
+
93
+ # Deploy the Cortex bundles.
94
+ k8s_yaml (helm ('./helm/bundles/cortex-nova' , name = 'cortex-nova' , values = [tilt_values ]))
95
+ k8s_yaml (helm ('./helm/bundles/cortex-manila' , name = 'cortex-manila' , values = [tilt_values ]))
96
+
97
+ # Note: place resources higher in this list to ensure their local port stays the same.
98
+ # Elements placed lower in the list will have their local port shifted by elements inserted above.
99
+ resources = [
100
+ (
101
+ 'MQTT' ,
102
+ [
103
+ 'cortex-nova-mqtt' ,
104
+ 'cortex-manila-mqtt' ,
105
+ ],
106
+ [(1883 , 'tcp' )],
107
+ ),
108
+ (
109
+ 'Database' ,
110
+ [
111
+ 'cortex-nova-postgresql' ,
112
+ 'cortex-manila-postgresql' ,
113
+ ],
114
+ [(5432 , 'psql' )],
115
+ ),
116
+ (
117
+ 'Cortex-Nova' ,
118
+ [
119
+ 'cortex-nova-migrations' ,
120
+ 'cortex-nova-cli' ,
121
+ 'cortex-nova-syncer' ,
122
+ 'cortex-nova-extractor' ,
123
+ 'cortex-nova-kpis' ,
124
+ 'cortex-nova-scheduler' ,
125
+ 'cortex-nova-descheduler' ,
126
+ ],
127
+ [(2112 , 'metrics' ), (8080 , 'api' )],
128
+ ),
129
+ (
130
+ 'Cortex-Manila' ,
131
+ [
132
+ 'cortex-manila-migrations' ,
133
+ 'cortex-manila-cli' ,
134
+ 'cortex-manila-syncer' ,
135
+ 'cortex-manila-extractor' ,
136
+ 'cortex-manila-kpis' ,
137
+ 'cortex-manila-scheduler' ,
138
+ ],
139
+ [(2112 , 'metrics' ), (8080 , 'api' )],
140
+ ),
141
+ ]
142
+ local_port = 8000
143
+ for label , components , service_ports in resources :
144
+ for component in components :
145
+ k8s_resource (
146
+ component ,
147
+ port_forwards = [
148
+ port_forward (local_port + i , service_port )
149
+ for i , (service_port , _ ) in enumerate (service_ports )
150
+ ],
151
+ links = [
152
+ link ('http://localhost:' + str (local_port + i ) + '/' + service_port_name , '/' + service_port_name )
153
+ for i , (_ , service_port_name ) in enumerate (service_ports )
154
+ ],
155
+ labels = [label ],
156
+ )
157
+ local_port += len (service_ports )
158
+
159
+ ########### E2E Tests
160
+ local_resource (
161
+ 'Run E2E Tests' ,
162
+ '/bin/sh -c "kubectl exec deploy/cortex-nova-cli -- /usr/bin/cortex checks" && ' + \
163
+ '/bin/sh -c "kubectl exec deploy/cortex-manila-cli -- /usr/bin/cortex checks"' ,
164
+ deps = ['./internal/checks' ],
165
+ labels = ['Commands' ],
166
+ trigger_mode = TRIGGER_MODE_MANUAL ,
167
+ auto_init = False ,
168
+ )
0 commit comments