Skip to content

Commit 1df7c6c

Browse files
committed
test real deployment in ci/cd
1 parent 906aab1 commit 1df7c6c

File tree

50 files changed

+545
-160
lines changed

Some content is hidden

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

50 files changed

+545
-160
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
# Copyright 2025 CS Group
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -euo pipefail
17+
18+
APPS=rs-server-deployment/apps
19+
20+
# Lower the CPU/memory requests
21+
# Minimum memory for postgresql must be > shared_buffers, which is 1/4 of the total ram
22+
sed -i -e 's!instances: 3!instances: 1!g' -e 's!cpu: "1"!cpu: "0.1"!g' -e 's!memory: "2G"!memory: "256M"!g' -e 's!memory: "1024M"!memory: "100M"!g' "${APPS}/01-eo-cnpgstac/values.yaml"
23+
sed -i -e 's!cpu: "100m"!cpu: "1m"!g' -e 's!ram: "256Mi"!ram: "10Mi"!g'\
24+
"${APPS}/mockup-prip-s1a/values.yaml"\
25+
"${APPS}/mockup-prip-s2b/values.yaml"\
26+
"${APPS}/mockup-processor-dpr/values.yaml"\
27+
"${APPS}/mockup-station-adgs/values.yaml"\
28+
"${APPS}/mockup-station-cadip-cadip/values.yaml"\
29+
"${APPS}/mockup-station-cadip-mti/values.yaml"\
30+
"${APPS}/mockup-station-cadip-sgs/values.yaml"\
31+
"${APPS}/mockup-station-lta/values.yaml"
32+
sed -i -e 's!cpu: "100m"!cpu: "10m"!g' -e 's!ram: "256Mi"!ram: "32Mi"!g'\
33+
"${APPS}/rs-dpr-service/values.yaml"\
34+
"${APPS}/rs-server-adgs/values.yaml"\
35+
"${APPS}/rs-server-cadip/values.yaml"\
36+
"${APPS}/rs-server-catalog/values.yaml"\
37+
"${APPS}/rs-server-frontend/values.yaml"\
38+
"${APPS}/rs-server-prip/values.yaml"\
39+
"${APPS}/rs-server-staging/values.yaml"

.github/workflows/test-deployment.yml

Lines changed: 110 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,56 +29,139 @@ jobs:
2929
test-deploy:
3030
if: github.actor != 'dependabot[bot]' # ignore pull requests by github bot
3131
runs-on: ubuntu-latest
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
include:
36+
- name: "Deployment with monitoring"
37+
deploy_monitoring: true
38+
# TODO enable this in RSPY-836
39+
# - name: "Deployment without monitoring"
40+
# deploy_monitoring: false
41+
name: ${{ matrix.name }}
3242
steps:
33-
- name: Checkout repository
43+
- name: Get current branch name
44+
id: vars
45+
run: echo "branch_name=${{ github.head_ref }}" >> $GITHUB_OUTPUT
46+
- name: Check if branch exists in rs-infra-core
47+
id: check_branch
48+
run: |
49+
BRANCH=${{ steps.vars.outputs.branch_name }}
50+
if git ls-remote --heads https://github.com/RS-PYTHON/rs-infra-core.git $BRANCH | grep -q $BRANCH; then
51+
echo "branch_to_use=$BRANCH" >> $GITHUB_OUTPUT
52+
else
53+
echo "branch_to_use=" >> $GITHUB_OUTPUT # Leave empty to use default
54+
fi
55+
shell: bash
56+
- name: Checkout infra-core repository
3457
uses: actions/checkout@v4
3558
with:
3659
repository: RS-PYTHON/rs-infra-core
37-
submodules: recursive
60+
ref: ${{ steps.check_branch.outputs.branch_to_use }}
61+
- name: Checkout infra-monitoring repository
62+
uses: actions/checkout@v4
63+
if: ${{ matrix.deploy_monitoring }}
64+
with:
65+
path: rs-infra-monitoring
66+
repository: RS-PYTHON/rs-infra-monitoring
67+
- name: Checkout workflow-env repository
68+
uses: actions/checkout@v4
69+
with:
70+
path: rs-workflow-env
71+
repository: RS-PYTHON/rs-workflow-env
3872
- name: Checkout repository
3973
uses: actions/checkout@v4
4074
with:
4175
path: rs-server-deployment
4276
ref: ${{ github.ref }}
43-
- name: Install requirements
77+
- name: Cache Miniforge and Conda env
78+
id: cache-conda
79+
uses: actions/cache@v4
80+
with:
81+
path: |
82+
~/miniforge3
83+
/usr/share/miniconda
84+
key: conda-${{ runner.os }}-${{ hashFiles('.github/common/resources/install-requirements.sh') }}
85+
restore-keys: |
86+
conda-${{ runner.os }}-
87+
- name: Aggressive cleanup
4488
run: |
45-
# Install miniforge
46-
mkdir -p ~/miniforge3
47-
wget -q "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" -O ~/miniforge3/miniforge.sh
48-
bash ~/miniforge3/miniforge.sh -b -u -p ~/miniforge3
49-
rm -f ~/miniforge3/miniforge.sh
50-
51-
# Init conda
52-
~/miniforge3/bin/conda init bash
53-
54-
# Create conda env with python
55-
conda create -y -n rspy python=3.11
56-
57-
# Install Ansible, Terraform, Openstackclient
58-
conda run -n rspy conda install -y -c conda-forge ansible terraform python-openstackclient passlib boto3 kubernetes-helm kubernetes-client python-kubernetes
59-
60-
conda run -n rspy ansible-galaxy collection install openstack.cloud amazon.aws kubernetes.core
61-
ln -s /usr/share/miniconda/envs/rspy/bin/kubectl /usr/local/bin/kubectl
89+
# Cleanup disk space (level between 0 and 14, more cleaning takes more time)
90+
.github/common/resources/aggressive-cleanup.sh 2
91+
shell: bash
92+
- name: Install requirements (if cache missed)
93+
if: steps.cache-conda.outputs.cache-hit != 'true'
94+
run: |
95+
.github/common/resources/install-requirements.sh
6296
shell: bash
6397
- name: Start minikube
6498
uses: medyagh/setup-minikube@latest
6599
with:
66-
start-args: '--profile cluster.local'
100+
addons: 'metallb,metrics-server'
101+
cpus: 4
67102
memory: 8000m
103+
start-args: '--disk-size=32g'
104+
- name: "Configure cluster labels, IP and DNS (host + CoreDNS)"
105+
run: |
106+
if [ "${{ matrix.deploy_monitoring }}" = "true" ]; then
107+
.github/common/resources/configure-cluster.sh "node-role.kubernetes.io/infra= node-role.kubernetes.io/rs_env= node-role.kubernetes.io/rs_server= node-role.kubernetes.io/access_csc=" "apikeymanager iam kube monitoring oauth2-proxy processing stac-browser-auxip stac-browser-cadip stac-browser-catalog stac-browser-prip"
108+
else
109+
.github/common/resources/configure-cluster.sh "node-role.kubernetes.io/infra= node-role.kubernetes.io/rs_env= node-role.kubernetes.io/rs_server= node-role.kubernetes.io/access_csc=" "apikeymanager iam kube oauth2-proxy processing stac-browser-auxip stac-browser-cadip stac-browser-catalog stac-browser-prip"
110+
fi
111+
shell: bash
112+
- name: Deploy minio
113+
run: |
114+
# Minio for cloudnative pg - https://github.com/minio/minio/tree/master/helm/minio#installing-the-chart-toy-setup
115+
helm repo add minio https://charts.min.io/
116+
helm repo update minio
117+
if [ "${{ matrix.deploy_monitoring }}" = "true" ]; then
118+
helm install minio minio/minio --namespace minio --set mode=standalone --set replicas=1 --set persistence.enabled=false --set resources.requests.memory=128Mi --set rootUser=s3_access_key,rootPassword=s3_secret_key --set buckets[0].name=rs-cluster-psql,buckets[1].name=rs-cluster-velero,buckets[2].name=rs-cluster-loki-chunks,buckets[3].name=rs-cluster-loki-ruler,buckets[4].name=rs-cluster-tempo --create-namespace --wait
119+
else
120+
helm install minio minio/minio --namespace minio --set mode=standalone --set replicas=1 --set persistence.enabled=false --set resources.requests.memory=128Mi --set rootUser=s3_access_key,rootPassword=s3_secret_key --set buckets[0].name=rs-cluster-psql,buckets[1].name=rs-cluster-velero --create-namespace --wait
121+
fi
68122
- name: Generate inventory
69123
run: |
70-
cp -rfp inventory/sample inventory/mycluster
71-
mv inventory/mycluster/.env.template inventory/mycluster/.env
72-
mv inventory/mycluster/openrc.sh.template inventory/mycluster/openrc.sh
73-
sed -i 's!<changeme_with_full_path>/miniforge3/envs/rspy!/usr/share/miniconda/envs/rspy!g' inventory/mycluster/hosts.yaml
124+
.github/common/resources/configure-inventory.sh
125+
# --- Generate inventory
74126
conda run -n rspy --no-capture-output env PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=1 ansible-playbook registry.yaml -i inventory/mycluster/hosts.yaml -e ci_mode=true
75127
conda run -n rspy --no-capture-output env PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=1 ansible-playbook generate_inventory.yaml -i inventory/mycluster/hosts.yaml
76128
shell: bash
77-
- name: Deploy the core apps (check)
129+
- name: Deploy the core apps (for real)
130+
run: |
131+
# --- Use local cluster issuer instead of Let's Encrypt
132+
if [ "${{ matrix.deploy_monitoring }}" = "true" ]; then
133+
.github/common/resources/configure-local-ca.sh apikeymanager:processing iam:iam kube:default monitoring:monitoring processing:processing oauth2-proxy:iam stac-browser-auxip:processing stac-browser-cadip:processing stac-browser-catalog:processing stac-browser-prip:processing
134+
else
135+
.github/common/resources/configure-local-ca.sh apikeymanager:processing iam:iam kube:default processing:processing oauth2-proxy:iam stac-browser-auxip:processing stac-browser-cadip:processing stac-browser-catalog:processing stac-browser-prip:processing
136+
fi
137+
conda run -n rspy --no-capture-output env PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=1 ansible-playbook apps.yaml -i inventory/mycluster/hosts.yaml
138+
shell: bash
139+
- name: Deploy the monitoring apps (for real)
140+
if: ${{ matrix.deploy_monitoring }}
78141
run: |
79-
conda run -n rspy --no-capture-output env PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=1 ansible-playbook --check apps.yaml -i inventory/mycluster/hosts.yaml -e private_registry=true
142+
./rs-infra-monitoring/.github/common/resources/configure-minikube-deployment.sh
143+
conda run -n rspy --no-capture-output env PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=1 ansible-playbook apps.yaml -i inventory/mycluster/hosts.yaml -e '{"package_paths": ["./rs-infra-monitoring/apps/"]}'
144+
shell: bash
145+
- name: Deploy the required workflow-env apps (for real)
146+
run: |
147+
# rs-server requires apikeymanager, dask
148+
for app in apikeymanager-db apikeymanager dask-gateway ; do
149+
echo Installing $app...
150+
conda run -n rspy --no-capture-output env PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=1 ansible-playbook apps.yaml -i inventory/mycluster/hosts.yaml -e '{"package_paths": ["./rs-workflow-env/apps/"], "app": "'$app'"}'
151+
done
80152
shell: bash
81153
- name: Deploy the rs-server apps (check)
82154
run: |
83155
conda run -n rspy --no-capture-output env PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=1 ansible-playbook --check apps.yaml -i inventory/mycluster/hosts.yaml -e '{"package_paths": ["./rs-server-deployment/apps/"]}' -e private_registry=true
84156
shell: bash
157+
- name: Deploy the rs-server apps (for real)
158+
run: |
159+
sed -i 's!debug: false!debug: true!g' roles/app-installer/defaults/main.yaml
160+
./rs-server-deployment/.github/common/resources/configure-minikube-deployment.sh
161+
conda run -n rspy --no-capture-output env PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=1 ansible-playbook apps.yaml -i inventory/mycluster/hosts.yaml -e '{"package_paths": ["./rs-server-deployment/apps/"]}'
162+
shell: bash
163+
- name: 🩺 Kubernetes failure diagnostics
164+
if: failure()
165+
run: |
166+
.github/common/resources/minikube-diagnostics.sh
167+
shell: bash

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v5.0.0
5+
rev: v6.0.0
66
hooks:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
@@ -12,7 +12,7 @@ repos:
1212
- id: check-added-large-files
1313

1414
- repo: https://github.com/gruntwork-io/pre-commit
15-
rev: v0.1.29 # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases
15+
rev: v0.1.30 # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases
1616
hooks:
1717
- id: terraform-fmt
1818
# - id: terraform-validate

apps/01-dask-cluster-staging/configmap.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,3 @@ data:
203203
while True:
204204
print(f"[heartbeat] workers={current_worker_count(client)} target={TARGET_WORKERS}")
205205
time.sleep(30)
206-

apps/01-dask-cluster-staging/deployment.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,3 @@ spec:
4646
- configMap:
4747
name: dask-cluster-script
4848
name: script-volume
49-

apps/01-dask-cluster-staging/kustomization.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
15-
commonLabels:
16-
app.kubernetes.io/instance: "{{ app_name }}"
17-
18-
namespace: dask-gateway
19-
20-
resources:
21-
- configmap.yaml
22-
- deployment.yaml
23-
- secret.yaml
14+
namespace: dask-gateway
15+
resources:
16+
- configmap.yaml
17+
- deployment.yaml
18+
- secret.yaml
19+
apiVersion: kustomize.config.k8s.io/v1beta1
20+
kind: Kustomization
21+
labels:
22+
- includeSelectors: true
23+
pairs:
24+
app.kubernetes.io/instance: '{{ app_name }}'

apps/01-eo-cnpgstac/kustomization.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
commonLabels:
16-
app.kubernetes.io/instance: "{{ app_name }}"
1715
namespace: database
1816

1917
helmCharts:
2018
- name: eo-cnpgstac
19+
releaseName: '{{ app_name }}'
2120
repo: oci://643vlk6z.gra7.container-registry.ovh.net/public/
22-
releaseName: "{{ app_name }}"
23-
version: 1.0.0-alpha
2421
valuesFile: values.yaml
22+
version: 1.0.0-alpha
2523

2624
resources:
27-
- grafanadatasource.yaml
28-
- podmonitor.yaml
29-
- scheduledbackup.yaml
30-
- secret.yaml
25+
- grafanadatasource.yaml
26+
- podmonitor.yaml
27+
- scheduledbackup.yaml
28+
- secret.yaml
29+
apiVersion: kustomize.config.k8s.io/v1beta1
30+
kind: Kustomization
31+
labels:
32+
- includeSelectors: true
33+
pairs:
34+
app.kubernetes.io/instance: '{{ app_name }}'

apps/01-eo-cnpgstac/values.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
commonLabels:
16-
wait-for-deployment: Ready
17-
1815
## @section CloudNative PostGIS parameters
1916
cnpgstac:
2017
## @param cnpgstac.enabled Enabled CloudNative PostGIS
@@ -23,6 +20,9 @@ cnpgstac:
2320
## @param cnpgstac.clusterName Name of the cnpgstac cluster
2421
clusterName: cnpgstac
2522

23+
clusterLabels:
24+
wait-for-deployment: Ready
25+
2626
## Define postgres user password
2727
## ref: https://cloudnative-pg.io/documentation/current/security/#postgresql
2828
superUserAccess:
@@ -88,7 +88,7 @@ cnpgstac:
8888

8989
## Enable readonly mode in pgstac
9090
## If true, usage of titiler-pgstac is limited
91-
## ref: https://github.com/stac-utils/pgstac/pull/215 and https://github.com/stac-utils/pgstac/issues/296
91+
## ref: https://github.com/stac-utils/pgstac/pull/215 and https://github.com/stac-utils/pgstac/issues/296
9292
enableReadOnly: true
9393

9494
## CloudNative PostGIS resource requests and limits
@@ -138,4 +138,4 @@ cnpgstac:
138138
tolerations:
139139
- effect: NoSchedule
140140
key: role
141-
value: rs_server
141+
value: rs_server

apps/01-pi-db/kustomization.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
commonLabels:
16-
app.kubernetes.io/instance: "{{ app_name }}"
1715

1816
namespace: database
1917

2018
resources:
21-
- database.yaml
22-
- grafanadatasource.yaml
19+
- database.yaml
20+
- grafanadatasource.yaml
21+
apiVersion: kustomize.config.k8s.io/v1beta1
22+
kind: Kustomization
23+
labels:
24+
- includeSelectors: true
25+
pairs:
26+
app.kubernetes.io/instance: '{{ app_name }}'

apps/01-pygeoapi-db/kustomization.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
commonLabels:
16-
app.kubernetes.io/instance: "{{ app_name }}"
1715

1816
namespace: database
1917

2018
resources:
21-
- database.yaml
22-
- grafanadatasource.yaml
19+
- database.yaml
20+
- grafanadatasource.yaml
21+
apiVersion: kustomize.config.k8s.io/v1beta1
22+
kind: Kustomization
23+
labels:
24+
- includeSelectors: true
25+
pairs:
26+
app.kubernetes.io/instance: '{{ app_name }}'

0 commit comments

Comments
 (0)