Skip to content

Commit 986ecdf

Browse files
Separate nova + manila deployments
1 parent 936e28a commit 986ecdf

Some content is hidden

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

74 files changed

+2274
-2289
lines changed

.github/renovate.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,6 @@
3434
"automerge": true,
3535
"groupName": "github.com/sapcc"
3636
},
37-
{
38-
"enabled": false,
39-
"matchPackageNames": [
40-
"postgresql"
41-
]
42-
},
43-
{
44-
"enabled": false,
45-
"matchFileNames": [
46-
"helm/cortex-postgres/**"
47-
]
48-
},
4937
{
5038
"matchPackageNames": [
5139
"!/^github\\.com\\/sapcc\\/.*/",

.github/workflows/check-alerts.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Check Alerts using Promtool
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**/*.rules.yaml'
7+
- '**/*.alerts.yaml'
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout PR
15+
uses: actions/checkout@v4
16+
17+
- name: Get changed rule and alert files
18+
id: changed
19+
uses: tj-actions/changed-files@v46
20+
with:
21+
files: |
22+
**/*.rules.yaml
23+
**/*.alerts.yaml
24+
25+
- name: Check changed rule and alert files via promtool
26+
if: steps.changed.outputs.any_changed == 'true'
27+
uses: peimanja/[email protected]
28+
with:
29+
promtool_actions_subcommand: 'rules'
30+
promtool_actions_files: ${{ steps.changed.outputs.all_changed_files }}
31+
promtool_actions_version: 'latest'
32+
promtool_actions_comment: 'false'

.github/workflows/push-charts.yaml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,39 @@ jobs:
2626
registry: ${{ env.REGISTRY }}
2727
username: ${{ github.actor }}
2828
password: ${{ secrets.GITHUB_TOKEN }}
29-
- name: Get all changed Chart.yaml files
30-
id: changed-chart-yaml-files
29+
- name: Get all changed library Chart.yaml files
30+
id: changed-chart-yaml-files-library
3131
uses: tj-actions/changed-files@v46
3232
with:
3333
files: |
34-
**/Chart.yaml
35-
- name: Push chart to registry
36-
if: steps.changed-chart-yaml-files.outputs.all_changed_files != ''
34+
helm/library/**/Chart.yaml
35+
- name: Push library charts to registry
36+
if: steps.changed-chart-yaml-files-library.outputs.all_changed_files != ''
3737
shell: bash
3838
env:
39-
ALL_CHANGED_FILES: ${{ steps.changed-chart-yaml-files.outputs.all_changed_files }}
39+
ALL_CHANGED_FILES: ${{ steps.changed-chart-yaml-files-library.outputs.all_changed_files }}
4040
run: |
4141
for CHART_FILE in ${ALL_CHANGED_FILES}; do
4242
CHART_DIR=$(dirname $CHART_FILE)
4343
helm package $CHART_DIR --dependency-update --destination $CHART_DIR
4444
CHART_PACKAGE=$(ls $CHART_DIR/*.tgz)
4545
helm push $CHART_PACKAGE oci://${{ env.REGISTRY }}/${{ github.repository }}/charts/
46-
done
46+
done
47+
- name: Get all changed bundle Chart.yaml files
48+
id: changed-chart-yaml-files-bundle
49+
uses: tj-actions/changed-files@v46
50+
with:
51+
files: |
52+
helm/bundles/**/Chart.yaml
53+
- name: Push bundle charts to registry
54+
if: steps.changed-chart-yaml-files-bundle.outputs.all_changed_files != ''
55+
shell: bash
56+
env:
57+
ALL_CHANGED_FILES: ${{ steps.changed-chart-yaml-files-bundle.outputs.all_changed_files }}
58+
run: |
59+
for CHART_FILE in ${ALL_CHANGED_FILES}; do
60+
CHART_DIR=$(dirname $CHART_FILE)
61+
helm package $CHART_DIR --dependency-update --destination $CHART_DIR
62+
CHART_PACKAGE=$(ls $CHART_DIR/*.tgz)
63+
helm push $CHART_PACKAGE oci://${{ env.REGISTRY }}/${{ github.repository }}/charts/
64+
done

.github/workflows/update-helm-tag.yml renamed to .github/workflows/update-appversion.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Update Helm Image Tag
1+
name: Update Helm AppVersion
22

33
on:
44
workflow_run:
@@ -7,7 +7,7 @@ on:
77
- completed
88

99
jobs:
10-
update-helm-tag:
10+
update-appversion:
1111
if: >-
1212
${{ github.event.workflow_run.conclusion == 'success' && !contains(github.event.workflow_run.head_commit.message, '[skip ci]') }}
1313
runs-on: ubuntu-latest
@@ -23,14 +23,14 @@ jobs:
2323
id: vars
2424
run: echo "sha=sha-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
2525

26-
- name: Update image.tag in values.yaml
26+
- name: Update appVersion in Chart.yaml
2727
run: |
28-
sed -i 's/^\([ ]*tag:[ ]*\).*/\1"${{ steps.vars.outputs.sha }}"/' helm/cortex/values.yaml
28+
sed -i 's/^\([ ]*appVersion:[ ]*\).*/\1"${{ steps.vars.outputs.sha }}"/' helm/library/cortex-core/Chart.yaml
2929
3030
- name: Commit and push changes
3131
run: |
3232
git config user.name "github-actions[bot]"
3333
git config user.email "github-actions[bot]@users.noreply.github.com"
34-
git add helm/cortex/values.yaml
35-
git commit -m "Bump cortex image tag in chart to ${{ steps.vars.outputs.sha }} [skip ci]" || echo "No changes to commit"
34+
git add helm/library/cortex-core/Chart.yaml
35+
git commit -m "Bump helm/library/cortex-core appVersion to ${{ steps.vars.outputs.sha }} [skip ci]" || echo "No changes to commit"
3636
git push origin HEAD:main

Tiltfile

Lines changed: 119 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
# Don't track us.
88
analytics_settings(False)
99

10-
# The upgrade job may take a long time to run, so it is disabled by default.
11-
enable_postgres_upgrade = False
12-
1310
if not os.getenv('TILT_VALUES_PATH'):
1411
fail("TILT_VALUES_PATH is not set.")
1512
if not os.path.exists(os.getenv('TILT_VALUES_PATH')):
1613
fail("TILT_VALUES_PATH "+ os.getenv('TILT_VALUES_PATH') + " does not exist.")
1714

15+
# The upgrade job may take a long time to run, so it is disabled by default.
16+
enable_postgres_upgrade = False
17+
1818
load('ext://helm_resource', 'helm_resource', 'helm_repo')
1919
helm_repo(
2020
'Bitnami Helm Repo',
@@ -27,93 +27,16 @@ helm_repo(
2727
labels=['Repositories'],
2828
)
2929

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
11033
k8s_resource('cortex-prometheus-operator', labels=['Monitoring'])
11134
k8s_resource(
11235
new_name='cortex-prometheus',
113-
port_forwards=[port_forward(9090, 9090)],
36+
port_forwards=[port_forward(3000, 9090)],
11437
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'),
11740
],
11841
objects=['cortex-prometheus:Prometheus:default'],
11942
labels=['Monitoring'],
@@ -126,17 +49,120 @@ k8s_resource(
12649
docker_build('cortex-visualizer', 'visualizer')
12750
k8s_yaml('./visualizer/app.yaml')
12851
k8s_resource('cortex-visualizer', port_forwards=[
129-
port_forward(8009, 80),
52+
port_forward(4000, 80),
13053
], 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'),
13356
], labels=['Monitoring'])
134-
135-
########### Plutono (Grafana Fork)
13657
docker_build('cortex-plutono', 'plutono')
13758
k8s_yaml('./plutono/app.yaml')
13859
k8s_resource('cortex-plutono', port_forwards=[
139-
port_forward(3000, 3000, name='plutono'),
60+
port_forward(5000, 3000, name='plutono'),
14061
], 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'),
14263
], 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+
)

commands/checks/manila/checks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func checkManilaSchedulerReturnsValidHosts(ctx context.Context, config conf.Conf
7575
Weights: weights,
7676
}
7777
port := strconv.Itoa(config.GetAPIConfig().Port)
78-
apiURL := "http://cortex-scheduler-manila:" + port + "/scheduler/manila/external"
78+
apiURL := "http://cortex-manila-scheduler:" + port + "/scheduler/manila/external"
7979
slog.Info("sending request to external scheduler", "apiURL", apiURL)
8080

8181
requestBody := must.Return(json.Marshal(request))

commands/checks/nova/checks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func checkNovaSchedulerReturnsValidHosts(ctx context.Context, config conf.Config
8181
Weights: weights,
8282
}
8383
port := strconv.Itoa(config.GetAPIConfig().Port)
84-
apiURL := "http://cortex-scheduler-nova:" + port + "/scheduler/nova/external"
84+
apiURL := "http://cortex-nova-scheduler:" + port + "/scheduler/nova/external"
8585
slog.Info("sending request to external scheduler", "apiURL", apiURL)
8686

8787
requestBody := must.Return(json.Marshal(request))

0 commit comments

Comments
 (0)