@@ -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
0 commit comments