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:20] 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>
  
-===== 1.- Archiv entpacken =====+**Schritt 2**: 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 47: Zeile 64:
 </code> </code>
  
-===== 1.Verschlüsselung =====+===== 1.Zertifikat =====
  
-Der Harbor bringt selbst keine Zertifikate mit. Diese müssen manuell erstellt oder von Drittanbietern besorgt werden.+Das zum Server erstellte Zertifikat muss für Harbor und Docker bereitgestellt werden.
  
-==== 1.3.1 - Let's-Encrypt-Zertifikat ====+==== 1.4.1 - Harbor ====
  
-[[https://letsencrypt.org/|Let's Encrypt]] bietet aktuell noch kostenlose Zertifikate an. Leider war es mir in einem ersten Versuch nicht möglich, mittels des Programmes "certbot" ein SSL-Zertifikat zu generieren. Laut Recherche im Internet wird noch ein Domain benötigtwelche für die Fritzbox genutzt wird. Dies wird eventuell später nochmal neu getestet.+Für Harbor wird unter "''/data''" ein entsprechendes Verzeichnis "''cert/''" erstelltwohin alle benötigten Dateien kopiert werden.
  
-==== 1.3.2 Eigenes Zertifikat ====+**Schritt 1**: Erstellen der Verzeichnisstruktur: 
 +<code> 
 +~# mkdir -pv /opt/harbor/certs 
 +mkdir: Verzeichnis '/opt/harbor/certs' angelegt
  
-Es wird ein eigenes Zertifikat erstllt.+~#
  
-**Schritt 1**: Erstellen des privaten Schlüssels "''ca.key''" für die CA:+</code> 
 + 
 +**Schritt 2**: Kopieren der Zertifikatsdateien:
 <code> <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'\
 +~#
  
-~# openssl genrsa -out ca.key 4096+</code> 
 + 
 +==== 1.4.2 - Docker ==== 
 + 
 +Docker interpretiert "''*.crt''"-Dateien als CA-Dateien und "''*.cert''"-Dateien als Server-Zertifikate. Das Server-Zertifikat muss daher einmal umgewandelt werden. 
 + 
 +**Schritt 1**: Konvertieren der Datei: 
 +<code> 
 +~# openssl x509 -inform PEM -in slxharbor.fritz.box.crt -out slxharbor.fritz.box.cert
  
 </code> </code>
  
-**Schritt 2**: Erstellen des CA-Zertifikats "''ca.crt''":+**Schritt 2**: Erstellen der Verzeichnisstruktur:
 <code> <code>
-~# openssl req -x509 -new -nodes -sha512 -days 3650 -subj "/C=DE/ST=Niedersachsen/L=Hannover/O=looper/OU=Personal/CN=Personal Root CA" -key ca.key -out ca.crt+~# 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**: Erstellen des privaten Schlüssels "''slxharbor.fritz.box.key''" für den Server:+**Schritt 3**: Kopieren der Zertifikate:
 <code> <code>
-~# openssl genrsa -out slxharbor.fritz.box.key 4096+~# 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> </code>
  
-**Schritt 4**: Generieren einer Zertifikatsanforderung (CSR):+**Schritt 4**: Docker neu starten:
 <code> <code>
-~# openssl req -sha512 -new -subj "/C=DE/ST=Niedersachsen/L=Hannover/O=looper/OU=Personal/CN=slxharbor.fritz.box" -key slxharbor.fritz.box.key -out slxharbor.fritz.box.csr+~# systemctl restart docker 
 +~#
  
 </code> </code>
  
-**Schritt 5**: Erstellen der X509-Erweiterungsdatei "''v3.ext''":+====== 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> <code>
-~# catv3.ext <<-EOF +~# cp -v harbor.yml.tmpl harbor.yml\ 
-authorityKeyIdentifier=keyid,issuer +'harbor.yml.tmpl' -'harbor.yml' 
-basicConstraints=CA:FALSE +~# 
-keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment + 
-extendedKeyUsage = serverAuth +</code> 
-subjectAltName @alt_names+ 
 +Jetzt kann die Datei angepasst werden. Folgende Parameter wurden neu gesetzt: 
 + 
 +<code> 
 +hostname: slxharbor.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> 
 + 
 +<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: 
 + 
 +<code> 
 +~# ./install.sh 
 +[Step 0]: checking if docker is installed ... 
 + 
 +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 ...
  
-[alt_names] +[Step 5]: starting Harbor ... 
-DNS.1=slxharbor.fritz.box +[+] up 10/10 
-DNS.2=slxharbor.fritz + ✔ Network harbor_harbor       Created                                                                                                             0.0s 
-DNS.3=slxharbor + ✔ Container harbor-log        Created                                                                                                             0.1s 
-DNS.4=harbor.fritz.box + ✔ Container harbor-db         Created                                                                                                             0.1s 
-DNS.5=harbor + ✔ Container registry          Created                                                                                                             0.1s 
-EOF+ ✔ 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>
  
-**Schritt 6**: Erstellen des Zertifikats "''slxharbor.fritz.box.crt''":+====== 4 - Kontrolle ====== 
 + 
 +Am Ende der Installation wurde angezeigt, dass die Installation erfolgreich war und Harbor gestartet wurdeDies lässt sich jetzt auf mehrere Arten kontrollieren. 
 + 
 +===== 4.1 - Docker-Container ===== 
 + 
 +Es kann geprüft werden, welche Docker-Container gerade laufen: 
 <code> <code>
-~# openssl x509 -req -sha512 -days 3650 -extfile v3.ext -CA ca.crt -CAkey ca.key -CAcreateserial -in slxharbor.fritz.box.csr -out slxharbor.fritz.box.crt +~# docker ps\ 
-Certificate request self-signature ok +CONTAINER ID   IMAGE                                 COMMAND                  CREATED         STATUS                   PORTS                                                                                NAMES\ 
-subject=C=DE, ST=Niedersachsen, L=Hannover, O=looper, OU=Personal, CN=slxharbor.fritz.box+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> </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.1766150410.txt.gz · Zuletzt geändert: von sborne