Skip to content

Commit

Permalink
add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
OriHoch committed Feb 2, 2024
1 parent 3f7f380 commit 295e2a2
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CWM_WORKER_HELM_DEPLOY_KEY: ${{ secrets.CWM_WORKER_HELM_DEPLOY_KEY }}
CWM_WORKER_CLUSTER_DEPLOY_KEY: ${{ secrets.CWM_WORKER_CLUSTER_DEPLOY_KEY }}
CWM_API_URL: ${{ secrets.CWM_API_URL }}
CWM_API_KEY: ${{ secrets.CWM_API_KEY }}
CWM_API_SECRET: ${{ secrets.CWM_API_SECRET }}
Expand Down Expand Up @@ -88,7 +89,16 @@ jobs:
if [ "$(uci github actions get-branch-name)" == "main" ]; then
uci docker tag-push \
--source-tag-name cwm_worker_operator \
--push-tag-name "ghcr.io/cloudwebmanage/cwm-worker-operator/cwm_worker_operator:latest"
--push-tag-name "ghcr.io/cloudwebmanage/cwm-worker-operator/cwm_worker_operator:latest" &&\
uci git checkout \
--github-repo-name CloudWebManage/cwm-worker-cluster \
--branch-name master \
--ssh-key "${CWM_WORKER_CLUSTER_DEPLOY_KEY}" \
--path cwm-worker-cluster \
--config-user-name cwm-worker-operator-ci &&\
cd cwm-worker-cluster &&\
bin/update_cluster_image.py cwm-worker-operator $GITHUB_SHA --git-commit &&\
git push origin master
fi
- uses: 8398a7/action-slack@v3
Expand Down
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,59 @@ kubectl port-forward service/cwm-worker-operator-redis-internal 6379
```

For more details, refer to the [CI workflow](./.github/workflows/ci.yml).

## Local Development on real cluster

Follow the steps in Local Development section until Start Infrastructure, then continue with the following steps:

```shell
# Set the cluster env vars depending on the cluster you want to connect to, you should only use dev / testing clusters
export CLUSTER_NAME=cwmc-eu-v2test
export CWM_ZONE=eu-test
export DNS_RECORDS_PREFIX=$CLUSTER_NAME
# Get a fresh token from Vault
export VAULT_TOKEN=
cd ../cwm-worker-cluster
eval "$(venv/bin/cwm-worker-cluster cluster connect $CLUSTER_NAME)"
popd >/dev/null
# Optionally, enable full verbosity debugging
export DEBUG=yes
export DEBUG_VERBOSITY=10
# Set env vars to point to the Redis databases (we will start port-forwarding later)
export INGRESS_REDIS_PORT=6381
export INTERNAL_REDIS_PORT=6382
export METRICS_REDIS_PORT=6383
export INTERNAL_REDIS_DB=0
export METRICS_REDIS_DB=0
```

Start port-forwarding to the Redis databases (you can run this multiple times if a forward was stopped):

```shell
lsof -i:6381 >/dev/null || kubectl -n cwm-worker-ingress port-forward service/cwm-worker-ingress-operator-redis 6381:6379 >/dev/null 2>&1 &
lsof -i:6382 >/dev/null || kubectl -n cwm-operator port-forward service/cwm-worker-operator-redis-internal 6382:6379 >/dev/null 2>&1 &
lsof -i:6383 >/dev/null || kubectl -n cwm-operator port-forward service/cwm-worker-operator-redis-metrics 6383:6379 >/dev/null 2>&1 &
```

Stop the relevant operator daemones running on the cluster to prevent conflicts. First, disable argocd autosync,
then scale the relevant deployments to 0, for example:

```shell
kubectl -n cwm-operator scale deployment deployer --replicas=0
```

Now you can run operator commands for the relevant daemons, for example:

```
cwm-worker-operator deployer start_daemon --once
```

When done, terminate the background jobs:

```
kill $(jobs -p)
```
4 changes: 4 additions & 0 deletions cwm_worker_operator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,7 @@ def send_agg_metrics(worker_id, minutes_json):
import json
from cwm_worker_operator.cwm_api_manager import CwmApiManager
CwmApiManager().send_agg_metrics(worker_id, json.loads(minutes_json))


if __name__ == '__main__':
main()

0 comments on commit 295e2a2

Please sign in to comment.