Linux4Ever

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
container:harbor:start [2025/12/19 14:05] sbornecontainer:harbor:start [2025/12/22 13:05] (aktuell) sborne
Zeile 9: Zeile 9:
 ---- ----
  
-====== 1 - Installation ======+====== 1 - Vorbereitungen ====== 
 + 
 +Es sind mehrere vorbereitende Schritte notwendig. 
 + 
 +===== 1.1 - SSL-Zertifikate ===== 
 + 
 +Der Harbor bringt selbst keine Zertifikate mit. Diese müssen manuell erstellt oder von Drittanbietern besorgt werden. Eine Methode zum Erstellen eines eigenen Zertifikats ist [[:container:zertifikat|hier]] beschrieben. 
 + 
 +===== 1.2 - Docker ===== 
 + 
 +Harbor läuft als Docker-Container. Dieses Programm muss als Voraussetzung installiert werden. Docker kann aus den Repositories installiert werden, sofern die Docker-Repositories eingebunden wurden: 
 +<code> 
 + 
 +~# apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin 
 + 
 +</code> 
 + 
 +===== 1.3 - Harbor =====
  
 Harbor kann von der Seite "[[https://goharbor.io/|goharbor.io]]" (dort dann oben auf "''Getting Started''" klicken und auf dieser Seite dann unter Punkt 2 auf "''Download the Harbor Installer''"). Die verschiedenen Versionen sind auch auf der Release-Seite "[[https://github.com/goharbor/harbor/releases|https://github.com/goharbor/harbor/releases]]" zu finden. Nachfolgend wird der Offline-Installer genutzt. Zum Zeitpunkt der Dokumentation war Version 2.14.1 aktuell. Harbor kann von der Seite "[[https://goharbor.io/|goharbor.io]]" (dort dann oben auf "''Getting Started''" klicken und auf dieser Seite dann unter Punkt 2 auf "''Download the Harbor Installer''"). Die verschiedenen Versionen sind auch auf der Release-Seite "[[https://github.com/goharbor/harbor/releases|https://github.com/goharbor/harbor/releases]]" zu finden. Nachfolgend wird der Offline-Installer genutzt. Zum Zeitpunkt der Dokumentation war Version 2.14.1 aktuell.
  
-===== 1.1 - Herunterladen der Installationsdatei =====+**Schritt 1**: Herunterladen
 <code> <code>
  
Zeile 33: Zeile 50:
 </code> </code>
  
- +**Schritt 2**: Entpacken
- +
-===== 1.- Archiv entpacken =====+
 <code> <code>
  
 ~# tar xzvf harbor-offline-installer-v2.14.1.tgz ~# tar xzvf harbor-offline-installer-v2.14.1.tgz
-harbor/harbor.v2.14.1.tar.gz\ +harbor/harbor.v2.14.1.tar.gz 
-harbor/prepare\ +harbor/prepare 
-harbor/LICENSE\ +harbor/LICENSE 
-harbor/install.sh\ +harbor/install.sh 
-harbor/common.sh\+harbor/common.sh
 harbor/harbor.yml.tmpl harbor/harbor.yml.tmpl
 ~# ~#
Zeile 49: Zeile 64:
 </code> </code>
  
 +===== 1.4 - Zertifikat =====
  
 +Das zum Server erstellte Zertifikat muss für Harbor und Docker bereitgestellt werden.
  
-===== 1.Verschlüsselung =====+==== 1.4.1 Harbor ====
  
-Der Harbor bringt selbst keine Zertifikate mit. Diese müssen manuell erstellt oder von Drittanbietern besorgt werden.+Für Harbor wird unter "''/data''" ein entsprechendes Verzeichnis "''cert/''" erstellt, wohin alle benötigten Dateien kopiert werden.
  
-\\+**Schritt 1**: Erstellen der Verzeichnisstruktur: 
 +<code> 
 +~# mkdir -pv /opt/harbor/certs 
 +mkdir: Verzeichnis '/opt/harbor/certs' angelegt
  
-\\+~#
  
-==== 1.3.1 - Let's-Encrypt-Zertifikat ====+</code>
  
-[[https://letsencrypt.org/|Let's Encrypt]] bietet aktuell noch kostenlose Zertifikate anLeider war es mir in einem ersten Versuch nicht möglich, mittels des Programmes "certbot" ein SSL-Zertifikat zu generierenLaut Recherche im Internet wird noch ein Domain benötigt, welche für die Fritzbox genutzt wirdDies wird eventuell später nochmal neu getestet.+**Schritt 2**Kopieren der Zertifikatsdateien: 
 +<code> 
 +~# cp -v slxharbor.fritz.box.crt /opt/harbor/certs/ && cp -v slxharbor.fritz.box.key /opt/harbor/certs/ 
 +'slxharbor.fritz.box.crt' -> '/opt/harbor/certs/slxharbor.fritz.box.crt'
 +'slxharbor.fritz.box.key' -> '/opt/harbor/certs/slxharbor.fritz.box.key'
 +~#
  
-\\+</code>
  
-\\+==== 1.4.2 - Docker ====
  
-==== 1.3.Eigenes Zertifikat ====+Docker interpretiert "''*.crt''"-Dateien als CA-Dateien und "''*.cert''"-Dateien als Server-Zertifikate. Das Server-Zertifikat muss daher einmal umgewandelt werden.
  
-Es wird ein eigenes Zertifikat erstllt.+**Schritt 1**: Konvertieren der Datei: 
 +<code> 
 +~# openssl x509 -inform PEM -in slxharbor.fritz.box.crt -out slxharbor.fritz.box.cert
  
-\\+</code>
  
-**Schritt 1**: Erstellen des privaten Schlüssels "''ca.key''" für die CA:+**Schritt 2**: Erstellen der Verzeichnisstruktur:
 <code> <code>
-~# openssl genrsa -out ca.key 4096+~# mkdir -pv /etc/docker/certs.d/slxharbor.fritz.box 
 +mkdir: Verzeichnis '/etc/docker' angelegt\ 
 +mkdir: Verzeichnis '/etc/docker/certs.d' angelegt\ 
 +mkdir: Verzeichnis '/etc/docker/certs.d/slxharbor.fritz.box' angelegt\ 
 +~# 
 </code> </code>
  
 +**Schritt 3**: Kopieren der Zertifikate:
 +<code>
 +~# cp -v slxharbor.fritz.box.cert /etc/docker/certs.d/slxharbor.fritz.box/ && cp -v slxharbor.fritz.box.key /etc/docker/certs.d/slxharbor.fritz.box/ && cp -v ca.crt /etc/docker/certs.d/slxharbor.fritz.box/\
 +'slxharbor.fritz.box.cert' -> '/etc/docker/certs.d/slxharbor.fritz.box/slxharbor.fritz.box.cert'\
 +'slxharbor.fritz.box.key' -> '/etc/docker/certs.d/slxharbor.fritz.box/slxharbor.fritz.box.key'\
 +'ca.crt' -> '/etc/docker/certs.d/slxharbor.fritz.box/ca.crt'
 +~#
  
 +</code>
  
-**Schritt 2**: Erstellen des CA-Zertifikats "''ca.crt''":+**Schritt 4**: Docker neu starten: 
 +<code> 
 +~# systemctl restart docker 
 +~#
  
-<code>~# openssl req -x509 -new -nodes -sha512 -days 3650 -subj "/C=DE/ST=Niedersachsen/L=Hannover/O=fritz.box/OU=Personal/CN=Personal Root CA" -key ca.key -out ca.crt 
 </code> </code>
  
 +====== 2 - YAML-Datei ======
  
 +Vor der eigentlichen Installation muss die mitgelieferte YAML-Datei noch bearbeitet werden. Dazu muss die Vorlage "''harbor.yml.tmpl''" nach "''harbor.yml''" kopiert werden:
 +<code>
 +~# cp -v harbor.yml.tmpl harbor.yml\
 +'harbor.yml.tmpl' -> 'harbor.yml'
 +~#
  
-**Schritt 3**Erstellen des privaten Schlüssels "''slxharbor.fritz.box.key''" für den Server:+</code> 
 + 
 +Jetzt kann die Datei angepasst werden. Folgende Parameter wurden neu gesetzt: 
 + 
 +<code> 
 +hostnameslxharbor.fritz.box 
 +... 
 +https: 
 +  certificate: /opt/harbor/certs/slxharbor.fritz.box.crt\ 
 +  private_key: /opt/harbor/certs/slxharbor.fritz.box.key
 +... 
 +harbor_admin_password: ******* 
 +... 
 +database: 
 +  password: ******* 
 +... 
 +data_volume/data/harbor
  
-<code>~# openssl genrsa -out slxharbor.fritz.box.key 4096 
 </code> </code>
  
 +<sup>//**Hinweis**: Die gesetzten Kennwörter sollten irgendwo sicher notiert werden (zum Beispiel in Keepass).// </sup>
 +====== 3 - Installation ======
  
 +Jetzt kann das Installationsskript ausgeführt werden:
  
-**Schritt 4**: Generieren einer Zertifikatsanforderung (CSR):+<code> 
 +~# ./install.sh 
 +[Step 0]checking if docker is installed ...
  
-<code>~# openssl req -sha512 -new -subj "/C=DE/ST=Niedersachsen/L=Hannover/O=fritz.box/OU=Personal/CN=slxharbor.fritz.box" -key slxharbor.fritz.box.key -out slxharbor.fritz.box.csr+Note: docker version: 29.1.3
  
 +[Step 1]: checking docker-compose is installed ...
 +
 +Note: Docker Compose version v5.0.0
 +
 +[Step 2]: loading Harbor images ...
 +Loaded image: goharbor/trivy-adapter-photon:v2.14.1
 +Loaded image: goharbor/harbor-exporter:v2.14.1
 +Loaded image: goharbor/harbor-registryctl:v2.14.1
 +Loaded image: goharbor/prepare:v2.14.1
 +Loaded image: goharbor/harbor-log:v2.14.1
 +Loaded image: goharbor/harbor-jobservice:v2.14.1
 +Loaded image: goharbor/redis-photon:v2.14.1
 +Loaded image: goharbor/nginx-photon:v2.14.1
 +Loaded image: goharbor/registry-photon:v2.14.1
 +Loaded image: goharbor/harbor-portal:v2.14.1
 +Loaded image: goharbor/harbor-core:v2.14.1
 +Loaded image: goharbor/harbor-db:v2.14.1
 +
 +[Step 3]: preparing environment ...
 +
 +[Step 4]: preparing harbor configs ...
 +prepare base dir is set to /tmp/harbor
 +Clearing the configuration file: /config/log/rsyslog_docker.conf
 +Clearing the configuration file: /config/log/logrotate.conf
 +Clearing the configuration file: /config/portal/nginx.conf
 +Generated configuration file: /config/portal/nginx.conf
 +Generated configuration file: /config/log/logrotate.conf
 +Generated configuration file: /config/log/rsyslog_docker.conf
 +Generated configuration file: /config/nginx/nginx.conf
 +Generated configuration file: /config/core/env
 +Generated configuration file: /config/core/app.conf
 +Generated configuration file: /config/registry/config.yml
 +Generated configuration file: /config/registryctl/env
 +Generated configuration file: /config/registryctl/config.yml
 +Generated configuration file: /config/db/env
 +Generated configuration file: /config/jobservice/env
 +Generated configuration file: /config/jobservice/config.yml
 +copy /data/secret/tls/harbor_internal_ca.crt to shared trust ca dir as name harbor_internal_ca.crt ...
 +ca file /hostfs/data/secret/tls/harbor_internal_ca.crt is not exist
 +copy  to shared trust ca dir as name storage_ca_bundle.crt ...
 +copy None to shared trust ca dir as name redis_tls_ca.crt ...
 +Generated and saved secret to file: /data/secret/keys/secretkey
 +Successfully called func: create_root_cert
 +Generated configuration file: /compose_location/docker-compose.yml
 +Clean up the input dir
 +
 +Note: stopping existing Harbor instance ...
 +
 +[Step 5]: starting Harbor ...
 +[+] up 10/10
 + ✔ Network harbor_harbor       Created                                                                                                             0.0s
 + ✔ Container harbor-log        Created                                                                                                             0.1s
 + ✔ Container harbor-db         Created                                                                                                             0.1s
 + ✔ Container registry          Created                                                                                                             0.1s
 + ✔ Container harbor-portal     Created                                                                                                             0.1s
 + ✔ Container registryctl       Created                                                                                                             0.1s
 + ✔ Container redis             Created                                                                                                             0.1s
 + ✔ Container harbor-core       Created                                                                                                             0.1s
 + ✔ Container harbor-jobservice Created                                                                                                             0.1s
 + ✔ Container nginx             Created                                                                                                             0.1s
 +✔ ----Harbor has been installed and started successfully.----
 +~#
  
 </code> </code>
  
 +====== 4 - Kontrolle ======
  
 +Am Ende der Installation wurde angezeigt, dass die Installation erfolgreich war und Harbor gestartet wurde. Dies lässt sich jetzt auf mehrere Arten kontrollieren.
  
 +===== 4.1 - Docker-Container =====
 +
 +Es kann geprüft werden, welche Docker-Container gerade laufen:
 +
 +<code>
 +~# docker ps\
 +CONTAINER ID   IMAGE                                 COMMAND                  CREATED         STATUS                   PORTS                                                                                NAMES\
 +5a9ec57ad6c9   goharbor/nginx-photon:v2.14.1         "nginx -g 'daemon of…"   2 minutes ago   Up 2 minutes (healthy)   0.0.0.0:80->8080/tcp, [::]:80->8080/tcp, 0.0.0.0:443->8443/tcp, [::]:443->8443/tcp   nginx\
 +b2a1dfeaa584   goharbor/harbor-jobservice:v2.14.1    "/harbor/entrypoint.…"   2 minutes ago   Up 2 minutes (healthy)                                                                                        harbor-jobservice\
 +0b74687b2dae   goharbor/harbor-core:v2.14.1          "/harbor/entrypoint.…"   2 minutes ago   Up 2 minutes (healthy)                                                                                        harbor-core\
 +321d88d3ebcf   goharbor/redis-photon:v2.14.1         "redis-server /etc/r…"   2 minutes ago   Up 2 minutes (healthy)                                                                                        redis\
 +e65496140ab3   goharbor/registry-photon:v2.14.1      "/home/harbor/entryp…"   2 minutes ago   Up 2 minutes (healthy)                                                                                        registry\
 +6ebb82ec2e0a   goharbor/harbor-registryctl:v2.14.1   "/home/harbor/start.…"   2 minutes ago   Up 2 minutes (healthy)                                                                                        registryctl\
 +98b15e84535f   goharbor/harbor-portal:v2.14.1        "nginx -g 'daemon of…"   2 minutes ago   Up 2 minutes (healthy)                                                                                        harbor-portal\
 +1ac95fd29a67   goharbor/harbor-db:v2.14.1            "/docker-entrypoint.…"   2 minutes ago   Up 2 minutes (healthy)                                                                                        harbor-db\
 +5254d72818a9   goharbor/harbor-log:v2.14.1           "/bin/sh -c /usr/loc…"   2 minutes ago   Up 2 minutes (healthy)   127.0.0.1:1514->10514/tcp                                                            harbor-log
 +~#
 +
 +</code>
 +
 +===== 4.2 - Webseite =====
 +
 +Auch die Webseite von Harbor sollte jetzt erreichbar sein: [[https://slxharbor.fritz.box/|https://slxharbor.fritz.box/]]
 +
 +{{https://looper.de//wiki/lib/plugins/ckgedit/fckeditor/userfiles/image/container/harbor/harbor-login.png?nolink&971x547}}
 +
 +\\
 +\\
 +====== 5 - Wartung ======
 +
 +Die Wartung von Harbor wird zum entsprechenden Zeitpunkt nachgepflegt.
 +
 +\\
 +\\
 +====== 6 - Registrierung einrichten ======
 +
 +Am Beispiel von [[https://hub.docker.com/|Docker Hub]] soll die Registrierung demonstriert werden. Die Informationen wurden teilweise von der Webseite "[[https://blogs.vmware.com/cloud-foundation/2025/12/16/using-harbor-as-a-proxy-cache-for-cloud-based-registries/|blogs.vmware.com]]" entnommen. Auf der Docker-Webseite wurde ein Account erstellt, welcher zur Verbindung genutzt wird. Im Harbor wird eine neue Registrierung unter dem Menüpunkt "''Administration''" >>> "''Registries''" erstellt:
 +
 +{{https://www.looper.de//wiki/lib/plugins/ckgedit/fckeditor/userfiles/image/container/harbor/harbor-registrierung-dockerhub.png?nolink&500x510}}
 +
 +Mit Klick auf "''TEST CONNECTION''" kann die Verbindung überprüft werden. Mit "''OK''" wird die Registrierung dann hinzugefügt.
 +
 +So sollte es dann hinterher aussehen:
 +
 +{{https://www.looper.de//wiki/lib/plugins/ckgedit/fckeditor/userfiles/image/container/harbor/harbor-registrierung-dockerhub-listenansicht.png?nolink&900x251}}
 +
 +\\
 +\\
 +\\
 +\\
 +\\\\
 +\\
 ''<sub>//.Ende des Dokuments// </sub> '' ''<sub>//.Ende des Dokuments// </sub> ''
  
  
container/harbor/start.1766149554.txt.gz · Zuletzt geändert: von sborne