Skip to content

Commit 49a113b

Browse files
feat: add profile to launch harbor as external registry (#416)
* feat: update `k3-create.sh` Signed-off-by: Guilhem Barthés <[email protected]> * doc: add page about how to use harbor Signed-off-by: Guilhem Barthés <[email protected]> * fix: wrong hot modification Signed-off-by: Guilhem Barthés <[email protected]> * fix: add placeholder for `HARBOR_REGISTRY_DOMAIN` Signed-off-by: Guilhem Barthés <[email protected]> * fix: format Signed-off-by: Guilhem Barthés <[email protected]> * chore: add precision to harbor deployment doc Signed-off-by: SdgJlbl <[email protected]> --------- Signed-off-by: Guilhem Barthés <[email protected]> Signed-off-by: SdgJlbl <[email protected]> Co-authored-by: SdgJlbl <[email protected]>
1 parent 49c33c4 commit 49a113b

File tree

3 files changed

+138
-2
lines changed

3 files changed

+138
-2
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
**************************
2+
Harbor in local deployment
3+
**************************
4+
5+
6+
7+
This page describes how to use Harbor in our development setup, using skaffold. It is divided in two categories: the first one describes how to use a harbor registry inside the `k3d` cluster, meanwhile the second describes how to use a harbor registry outside of the cluster. The third section describes the set-up that will be needed.
8+
9+
10+
11+
Use in-cluster Harbor
12+
=====================
13+
14+
First-time set-up (specific to in-cluster)
15+
------------------------------------------
16+
17+
As ``sudo``, add ``127.0.0.1 registry.org-2.com`` to ``/etc/hosts``
18+
19+
.. code:: bash
20+
21+
echo "127.0.0.1 registry.org-2.com" | sudo tee -a /etc/hosts
22+
23+
Use
24+
---
25+
26+
1. Set ``HARBOR_CERT_PATH`` to point to the absolute path to ``orchestrator/examples/tools/ca.crt``
27+
28+
.. code-block:: bash
29+
30+
export HARBOR_CERT_PATH=<absolute_path_to_orchestrator_repo>/orchestrator/examples/tools/ca.crt
31+
32+
2. Re-create the cluster and launch skaffold on the orchestrator
33+
34+
.. code-block:: bash
35+
36+
./k3-create.sh
37+
cd orchestrator
38+
skaffold run
39+
40+
3. Start ``substra-backend`` with profile ``org-2-harbor``
41+
42+
4. Activate port-forward (port ``30046``) on
43+
``harbor-nginx-xxxxxxxxxx-xxxxx`` (referred as ``<pod_name>``),
44+
depending of your tool:
45+
46+
- ``kubectl``:
47+
48+
.. code:: bash
49+
50+
kubectl port-forward -n harbor deployments/harbor-nginx 30046:https
51+
52+
- ``k9s``:
53+
54+
1. Hover pod ``<pod_name>``
55+
2. Press ``<SHIFT>+F``
56+
3. Replace ``nginx::30000`` by ``nginx::30046`` (the
57+
``Local port`` should be replaced by ``30046``)
58+
59+
5. Follow the instructions in Harbor-set-up with the following informations:
60+
61+
- URL: https://registry.org-2.com:30046
62+
- Identifier: ``admin``
63+
- Password: ``harborP@ssword2403``
64+
65+
Use external Harbor
66+
===================
67+
68+
1. Follow the Harbor-set-up
69+
70+
2. Create ``docker-config`` secret
71+
72+
.. code:: bash
73+
74+
kubectl create secret docker-registry docker-config -n org-2 --docker-server=<your-registry-server> --docker-username=<your-name>
75+
76+
3. Update your value file (you can use ``backend-org-2-harbor.yaml`` as a model)
77+
78+
.. code:: yaml
79+
80+
docker-registry:
81+
enabled: false
82+
83+
containerRegistry:
84+
local: false
85+
scheme:
86+
host: # The host, without the port, as it is defined in the field port
87+
pullDomain: # The harbor host, with the port as it won't use the port field
88+
port: 443
89+
90+
kaniko:
91+
dockerConfigSecretName: docker-config # Equals to the name given to the secret at the previous step
92+
93+
94+
Harbor-set-up
95+
=============
96+
97+
1. In the frontend, create project ``substra``
98+
99+
2. Set the variable ```HARBOR_REGISTRY_DOMAIN``` to your registry URL
100+
101+
.. code-block:: bash
102+
103+
export HARBOR_REGISTRY_DOMAIN=<registry_url>
104+
105+
3. Login to the registry
106+
107+
.. code-block:: bash
108+
109+
docker login $HARBOR_REGISTRY_DOMAIN
110+
111+
4. Manually add base image
112+
113+
1. Pull image
114+
115+
.. code:: bash
116+
117+
docker pull ghcr.io/substra/substra-tools:latest
118+
119+
2. Tag it
120+
121+
.. code:: bash
122+
123+
docker tag ghcr.io/substra/substra-tools:latest $HARBOR_REGISTRY_DOMAIN/substra/substra-tools:latest
124+
125+
3. Push to repository
126+
127+
.. code:: bash
128+
129+
docker push $HARBOR_REGISTRY_DOMAIN/substra/substra-tools:latest

docs/source/how-to/developing-substra/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ The following guides might be of interest if you are interested in contributing
66
.. toctree::
77
:maxdepth: 1
88

9-
local-deployment.rst
9+
local-deployment.rst
10+
harbor.rst

docs/source/how-to/developing-substra/local-deployment/k3-create.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ k3d cluster delete || echo 'No cluster'
1111
mkdir -p /tmp/org-1
1212
mkdir -p /tmp/org-2
1313
mkdir -p /tmp/org-3
14-
k3d cluster create --api-port 127.0.0.1:6443 -p 80:80@loadbalancer -p 443:443@loadbalancer --k3s-arg "--disable=traefik,metrics-server@server:*" --volume /tmp/org-1:/tmp/org-1 --volume /tmp/org-2:/tmp/org-2 --volume /tmp/org-3:/tmp/org-3
14+
args=()
15+
16+
if [ "$HARBOR_CERT_PATH" ]; then
17+
args+=("--volume" "${HARBOR_CERT_PATH}:/etc/ssl/certs/harbor.crt")
18+
fi
19+
20+
k3d cluster create --api-port 127.0.0.1:6443 -p 80:80@loadbalancer -p 443:443@loadbalancer --k3s-arg "--disable=traefik,metrics-server@server:*" --volume /tmp/org-1:/tmp/org-1 --volume /tmp/org-2:/tmp/org-2 --volume /tmp/org-3:/tmp/org-3 "${args[@]}"
1521

1622
# Patch and install nginx-ingress
1723
curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/kind/deploy.yaml > /tmp/deploy.yaml

0 commit comments

Comments
 (0)