Skip to content

Commit 295e2a2

Browse files
committed
add ci
1 parent 3f7f380 commit 295e2a2

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
- env:
1717
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1818
CWM_WORKER_HELM_DEPLOY_KEY: ${{ secrets.CWM_WORKER_HELM_DEPLOY_KEY }}
19+
CWM_WORKER_CLUSTER_DEPLOY_KEY: ${{ secrets.CWM_WORKER_CLUSTER_DEPLOY_KEY }}
1920
CWM_API_URL: ${{ secrets.CWM_API_URL }}
2021
CWM_API_KEY: ${{ secrets.CWM_API_KEY }}
2122
CWM_API_SECRET: ${{ secrets.CWM_API_SECRET }}
@@ -88,7 +89,16 @@ jobs:
8889
if [ "$(uci github actions get-branch-name)" == "main" ]; then
8990
uci docker tag-push \
9091
--source-tag-name cwm_worker_operator \
91-
--push-tag-name "ghcr.io/cloudwebmanage/cwm-worker-operator/cwm_worker_operator:latest"
92+
--push-tag-name "ghcr.io/cloudwebmanage/cwm-worker-operator/cwm_worker_operator:latest" &&\
93+
uci git checkout \
94+
--github-repo-name CloudWebManage/cwm-worker-cluster \
95+
--branch-name master \
96+
--ssh-key "${CWM_WORKER_CLUSTER_DEPLOY_KEY}" \
97+
--path cwm-worker-cluster \
98+
--config-user-name cwm-worker-operator-ci &&\
99+
cd cwm-worker-cluster &&\
100+
bin/update_cluster_image.py cwm-worker-operator $GITHUB_SHA --git-commit &&\
101+
git push origin master
92102
fi
93103
94104
- uses: 8398a7/action-slack@v3

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,59 @@ kubectl port-forward service/cwm-worker-operator-redis-internal 6379
210210
```
211211

212212
For more details, refer to the [CI workflow](./.github/workflows/ci.yml).
213+
214+
## Local Development on real cluster
215+
216+
Follow the steps in Local Development section until Start Infrastructure, then continue with the following steps:
217+
218+
```shell
219+
# Set the cluster env vars depending on the cluster you want to connect to, you should only use dev / testing clusters
220+
export CLUSTER_NAME=cwmc-eu-v2test
221+
export CWM_ZONE=eu-test
222+
export DNS_RECORDS_PREFIX=$CLUSTER_NAME
223+
224+
# Get a fresh token from Vault
225+
export VAULT_TOKEN=
226+
227+
cd ../cwm-worker-cluster
228+
eval "$(venv/bin/cwm-worker-cluster cluster connect $CLUSTER_NAME)"
229+
popd >/dev/null
230+
231+
# Optionally, enable full verbosity debugging
232+
export DEBUG=yes
233+
export DEBUG_VERBOSITY=10
234+
235+
# Set env vars to point to the Redis databases (we will start port-forwarding later)
236+
export INGRESS_REDIS_PORT=6381
237+
export INTERNAL_REDIS_PORT=6382
238+
export METRICS_REDIS_PORT=6383
239+
export INTERNAL_REDIS_DB=0
240+
export METRICS_REDIS_DB=0
241+
```
242+
243+
Start port-forwarding to the Redis databases (you can run this multiple times if a forward was stopped):
244+
245+
```shell
246+
lsof -i:6381 >/dev/null || kubectl -n cwm-worker-ingress port-forward service/cwm-worker-ingress-operator-redis 6381:6379 >/dev/null 2>&1 &
247+
lsof -i:6382 >/dev/null || kubectl -n cwm-operator port-forward service/cwm-worker-operator-redis-internal 6382:6379 >/dev/null 2>&1 &
248+
lsof -i:6383 >/dev/null || kubectl -n cwm-operator port-forward service/cwm-worker-operator-redis-metrics 6383:6379 >/dev/null 2>&1 &
249+
```
250+
251+
Stop the relevant operator daemones running on the cluster to prevent conflicts. First, disable argocd autosync,
252+
then scale the relevant deployments to 0, for example:
253+
254+
```shell
255+
kubectl -n cwm-operator scale deployment deployer --replicas=0
256+
```
257+
258+
Now you can run operator commands for the relevant daemons, for example:
259+
260+
```
261+
cwm-worker-operator deployer start_daemon --once
262+
```
263+
264+
When done, terminate the background jobs:
265+
266+
```
267+
kill $(jobs -p)
268+
```

cwm_worker_operator/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,7 @@ def send_agg_metrics(worker_id, minutes_json):
176176
import json
177177
from cwm_worker_operator.cwm_api_manager import CwmApiManager
178178
CwmApiManager().send_agg_metrics(worker_id, json.loads(minutes_json))
179+
180+
181+
if __name__ == '__main__':
182+
main()

0 commit comments

Comments
 (0)