diff --git a/Dockerfile.scheduler b/Dockerfile.scheduler new file mode 100644 index 0000000..3fc6681 --- /dev/null +++ b/Dockerfile.scheduler @@ -0,0 +1,7 @@ +ARG BASE + +FROM $BASE + +COPY swh-scheduler /app/swh-scheduler + +RUN pip install /app/swh-scheduler diff --git a/kubernetes/11-storage.yml b/kubernetes/11-storage.yml index 0562916..374931b 100644 --- a/kubernetes/11-storage.yml +++ b/kubernetes/11-storage.yml @@ -1,216 +1,216 @@ --- +--- apiVersion: v1 kind: ConfigMap metadata: name: storage data: config.yml: | storage: cls: local db: postgresql:///?service=swh objstorage: cls: remote url: http://objstorage:5003/ journal_writer: cls: kafka args: brokers: - kafka prefix: swh.journal.objects client_id: swh.storage.master entrypoint-init-db.sh: | #!/bin/bash set -e echo -n "waiting for database availability" set +e ko=1 while [[ $ko -gt 0 ]]; do PGCONNECT_TIMEOUT=2 psql --list &>/dev/null;ko=$?; echo -n .; sleep 0.5; done echo set -e echo Init swh-storage database echo Creating extensions... swh db init-admin --db-name ${PGDATABASE} storage echo Initializing the database... swh db init --db-name ${PGDATABASE} storage entrypoint.sh: | #!/bin/bash set -e echo "${PGHOST}:5432:${PGDATABASE}:${PGUSER}:${PGPASSWORD}" >> ~/.pgpass cat >> ~/.pg_service.conf </dev/null;ko=$?; echo -n .; sleep 0.5; done echo set -e - echo Init swh-storage database + echo Init swh-scheduler database echo Creating extensions... - swh db init-admin --db-name ${PGDATABASE} storage + swh db init-admin --db-name ${PGDATABASE} scheduler echo Initializing the database... - swh db init --db-name ${PGDATABASE} storage - + swh db init --db-name ${PGDATABASE} scheduler entrypoint.sh: | #!/bin/bash set -e echo "${PGHOST}:5432:${PGDATABASE}:${PGUSER}:${PGPASSWORD}" >> ~/.pgpass cat >> ~/.pg_service.conf < 5003/TCP 17m # curl http://$(kubectl get services objstorage -o jsonpath='{.spec.clusterIP}'):5003 SWH Objstorage API server% ``` ## Start the storage - Start the db ``` # cd kubernetes # kubectl apply -f 05-storage-db.yml persistentvolume/storage-db-pv created persistentvolumeclaim/storage-db-pvc created secret/storage-db created configmap/storage-db created deployment.apps/storage-db created service/storage-db created # kubectl get pods NAME READY STATUS RESTARTS AGE registry-deployment-7595868dc8-657ps 1/1 Running 0 46m objstorage-8587d58b68-76jbn 1/1 Running 0 15m storage-db-64b7f8b684-48n7w 1/1 Running 0 4m52s # kubectl get services storage-db NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE storage-db ClusterIP 10.43.213.178 5432/TCP 8m19s ``` - Start the storage ``` # cd kubernetes # kubectl apply -f 11-storage.yml configmap/storage created deployment.apps/storage created service/storage created ``` - Test the service ``` # kubectl get pods NAME READY STATUS RESTARTS AGE registry-deployment-7595868dc8-657ps 1/1 Running 0 49m storage-db-64b7f8b684-48n7w 1/1 Running 0 7m40s storage-6b759fb974-w9rzj 1/1 Running 0 66s # kubectl get services storage NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE storage ClusterIP 10.43.212.116 5002/TCP 2m24s # curl http://$(kubectl get services storage -o jsonpath='{.spec.clusterIP}'):5002 Software Heritage storage server

You have reached the Software Heritage storage server.
See its documentation and API for more information

``` +## Start the scheduler + +- Start the db + +``` +# cd kubernetes + +# kubectl apply -f 15-scheduler-db.yml +persistentvolume/scheduler-db-pv unchanged +persistentvolumeclaim/scheduler-db-pvc created +secret/scheduler-db configured +configmap/scheduler-db unchanged +deployment.apps/scheduler-db unchanged +service/scheduler-db unchanged + +# kubectl get services scheduler-db +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +scheduler-db ClusterIP 10.43.115.249 5433/TCP 110s +``` + +- Test the service + +``` +# kubectl apply -f 20-scheduler.yml +configmap/scheduler created +deployment.apps/scheduler created +service/scheduler created +ingress.networking.k8s.io/scheduler created + +# kubectl get services scheduler +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +scheduler ClusterIP 10.43.218.74 5008/TCP 23s + +# kubectl get pods NAME READY STATUS RESTARTS AGE +registry-deployment-5f6894c5b-9wkmr 1/1 Running 0 28m +objstorage-5b87c549b6-f6jvc 1/1 Running 0 12m +storage-db-79bfbff68-mg7fr 1/1 Running 0 107s +storage-6bfcb87b6-7s7t8 1/1 Running 0 87s +scheduler-db-666c8dc8b4-qxm9d 1/1 Running 0 73s +scheduler-595f944854-hbsj4 1/1 Running 0 62s + +# curl http://$(kubectl get services scheduler -o jsonpath='{.spec.clusterIP}'):5008 + +Software Heritage scheduler RPC server + +

You have reached the +Software Heritage +scheduler RPC server.
+See its +documentation +and API for more information

+ +% +``` + ## Development ### Skaffold To start the development environment using skaffold, use the following command: ``` skaffold --default-repo registry.default dev ``` It will build the images, deploy them on the local registry and start the services. It will monitor the projects to detect the changes and restart the containers when needed diff --git a/skaffold.yaml b/skaffold.yaml index bb0e86b..51c4507 100644 --- a/skaffold.yaml +++ b/skaffold.yaml @@ -1,28 +1,36 @@ apiVersion: skaffold/v2beta13 kind: Config metadata: name: swh-environment build: artifacts: - image: swh/stack-base docker: dockerfile: Dockerfile - image: swh/objstorage docker: dockerfile: Dockerfile.objstorage requires: - image: swh/stack-base alias: BASE - image: swh/storage docker: dockerfile: Dockerfile.storage requires: - image: swh/stack-base alias: BASE + - image: swh/scheduler + docker: + dockerfile: Dockerfile.scheduler + requires: + - image: swh/stack-base + alias: BASE deploy: kubectl: manifests: - kubernetes/01-journal.yml - kubernetes/05-storage-db.yml - kubernetes/10-objstorage.yml - kubernetes/11-storage.yml + - kubernetes/15-scheduler-db.yml + - kubernetes/20-scheduler.yml