Harbor
Harbor Overview
Section titled âHarbor OverviewâWhat is Harbor?
Section titled âWhat is Harbor?âHarbor?
Section titled âHarbor?â
Harbor is an open-source registry that secures artifacts with policy and role-based access control, ensures images are scanned and free from vulnerabilities, and signs images as trusted. As a CNCF (Cloud Native Computing Foundation) Graduated project, Harbor delivers compliance, performance, and interoperability to help you consistently and securely manage artifacts across cloud-native computing platforms such as Kubernetes and Docker.


(Source: https://landscape.cncf.io/?category=container-registry&grouping=category)
Architecture Overview
Section titled âArchitecture Overviewâ
Main Feature
Section titled âMain Featureâ
- Security and vulnerability analysis
- Harbor regularly scans images to check for vulnerabilities and performs policy checks to prevent vulnerable images from being deployed.
- Content signing and validation
- Multi-tenant
- Extensible API and web UI
- Image replication across multiple Harbor instances
- You can replicate (synchronize) images and charts between multiple registry instances based on policies that use filters (repository, tag, label). Harbor automatically retries replication when an error occurs. This can be used to support load balancing, achieve high availability, and facilitate multi-datacenter deployments in hybrid and multi-cloud scenarios.
- Identity integration and role-based access control(RBAC) : You can grant user permissions separately per project, and actions are restricted according to those permissions.

Why Harbor?
Section titled âWhy Harbor?âpublic vs. private
Section titled âpublic vs. privateâThere are two types of container registries: public and private.
- A public registry is basic in terms of abilities/offerings and easy to use, making it suitable for individuals or small teams who want to get a registry up and running as quickly as possible. However, as the scale grows, security issues such as patching, privacy, and access control may arise.
- A private registry provides a way to integrate security and privacy into enterprise container image storage that is hosted remotely or on-premises. A company can choose to build and deploy its own container registry or choose a commercial private registry service. Such private registries often come with advanced security features and technical support.
nexus vs. harbor
Section titled ânexus vs. harborâ| Â | nexus | harbor |
| docker | Â An integrated repository concept where Docker Registry is not the primary feature | In addition to a Docker Registry, it provides extra features such as Garbage Collection and Docker image vulnerability scanning |
| Active/Active HA | HA-C supported only for Nexus Repository Pro (Starts at 3,000$/year) | Supports image synchronization between registries via Replication |

Harbor?
Section titled âHarbor?â| pros | cons |
| identity management | hard to setup on k8s cluster |
| API and graphical UI | |
| Vulnerability scanning | |
| image replication | |
| online or offline installation |
Our Harbor Architecture
Section titled âOur Harbor Architectureâ
Practice
Section titled âPracticeâConfiguring an HTTPS Ingress Controller
Section titled âConfiguring an HTTPS Ingress ControllerâHarbor optionally supports HTTP connections, but the Docker Client always tries to connect to the registry using HTTPS first.

Create an HTTPS Ingress Controller on EKS
Section titled âCreate an HTTPS Ingress Controller on EKSâAn ingress controller is software that provides a reverse proxy, configurable traffic routing, and TLS termination for Kubernetes services. Kubernetes ingress resources are used to configure ingress rules and routing for individual Kubernetes services. Using an ingress controller and ingress rules, you can route traffic to multiple services in a Kubernetes cluster using a single IP address.
1) Install the nginx ingress controller
Section titled â1) Install the nginx ingress controllerâ# create namespacekubectl create ns dp3-ingress-basic
# Helm repo addhelm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
# install Nginx Ingress Controller with Helmhelm install dp3-nginx-ingress ingress-nginx/ingress-nginx \ --namespace dp3-ingress-basic \ --set controller.replicaCount=2 \ --set controller.nodeSelector."beta\.kubernetes\.io/os"=linux \ --set defaultBackend.nodeSelector."beta\.kubernetes\.io/os"=linux \ --set controller.admissionWebhooks.patch.nodeSelector."beta\.kubernetes\.io/os"=linux2) Add a Record to the Route 53 hosted zone
Section titled â2) Add a Record to the Route 53 hosted zoneâ![]()
3) Install cert-manager
Section titled â3) Install cert-managerâCert-manager is open source that automatically provisions and manages TLS (formerly SSL) certificates within a k8s cluster.
Cert-manager can issue certificates using things like letâs encrypt and Vault. It also automatically renews certificates before they expire, even after issuance.

# Label the ingress-basic namespace to disable resource validationkubectl label ns dp3-ingress-basic cert-manager.io/disable-validation=true
# Add the Jetstack Helm repositoryhelm repo add jetstack https://charts.jetstack.io
# Update your local Helm chart repository cachehelm repo update
# Install the cert-manager Helm charthelm install dp3-cert-manager jetstack/cert-manager \ --namespace dp3-ingress-basic \ --set installCRDs=true \ --set nodeSelector."kubernetes\.io/os"=linux \ --set webhook.nodeSelector."kubernetes\.io/os"=linux \ --set cainjector.nodeSelector."kubernetes\.io/os"=linux4) Create a Cluster Issuer
Section titled â4) Create a Cluster IssuerâLetâs Encrypt is a certificate authority that provides free X.509 certificates for Transport Layer Security encryption through an automated process that eliminates the previously complex steps of manually creating, validating, digitally signing, installing, and renewing certificates for secure websites.
= Automatic creation of free SSL certificates
Create the ClusterIssuer used by cert-manager so that certificates can be issued from Letâs Encrypt.
apiVersion: cert-manager.io/v1kind: ClusterIssuermetadata: name: letsencryptspec: acme: server: https://acme-v02.api.letsencrypt.org/directory email: MY_EMAIL_ADDRESS privateKeySecretRef: name: letsencrypt solvers: - http01: ingress: class: nginx podTemplate: spec: nodeSelector: "kubernetes.io/os": linuxAfter applying the Cluster Issuer, when you create an ingress resource, content like the following appears under spec.
tls: - hosts: - [YOUR_DOMAIN] secretName: tls-secretIf you configure this part appropriately, the following processing proceeds.
- It validates the domain configured in spec.tls.hosts. It runs the web server needed for validation and updates the routing configuration.
- When the certificate is issued, it is stored in the secret specified in spec.tls.secretName. If the secret does not exist, it creates and stores a new one.
When the certificate issuance completes normally, you can query the certificate with the Ready = True state as shown below.

This completes the preparation to automatically create an SSL certificate each time an Ingress is created.
+) Appendix
Section titled â+) Appendixâ- kubed
What if you want to use a certificate you created earlier in a different namespace?
kubed synchronizes configmaps/secrets between clusters or namespaces.

Install kubed with Helm
helm repo add appscode https://charts.appscode.com/stable/helm install dp3-kubed appscode/kubed --namespace dp3-ingress-basic \ --set config.clusterName=demo-cluster-001 \ --set apiserver.enabled=false
And to share the secret with the ns where harbor will be installed, label the current ns. (I applied the label âapp=dp3â.)
kubectl label ns dp3-ingress-basic app=dp3
Annotate the secret to be shared with other namespaces.
kubectl annotate secret tls-secret -n dp3-ingress-basic kubed.appscode.com/sync="app=dp3"
Installing Harbor
Section titled âInstalling HarborâInstall harbor with Helm
helm repo add harbor https://helm.goharbor.iohelm install dp3-harbor -n dp3-harbor harbor/harbor \ --set expose.ingress.hosts.core=harbor.example.com \ --set persistence.enabled=true \ --set externalURL=https://harbor.example.comVerify the created resources

3rd-party components such as chartmuseum, notary, and trivy were also installed. The function of each component is as follows.
- notary : a tool for managing Docker image signatures - redis : data caching, job metadata cache - postgresql : stores backend storage data - Clair : container vulnerability analysis - trivy : container vulnerability analysis - jobservice : used for image replication based on work that can queue and process background jobs - chartmuseum: helm chart repository
Modify the host in the ingress and access harbor.example.com in the browser.

Keycloak OIDC Integration and Access Control
Section titled âKeycloak OIDC Integration and Access ControlâAdd a Client to Keycloak
Section titled âAdd a Client to KeycloakâCreate a Client in the demo Realm.

Enter the domain to integrate with Keycloak in the Root URL and Save.
Next, enter Settings


In Client Setting, set Access Type = confidential and then go to the Credentials tab,

You can see that a Secret uuid was generated as shown above!
We will proceed with the integration using this Client Id and Secret
Harbor Configuration
Section titled âHarbor ConfigurationâAfter connecting with the Harbor administrator account, select Configuration from the left menu.
Here, enter auth mode=OIDC, provider=keycloak, endpoint= the keycloak domain
and enter the client id and secret you verified earlier in keycloak.



A LOGIN VIA OIDC PROVIDER button was created. Now you can access Harbor through your Keycloak account.
Now, for per-user (or per-group) access control via Keycloak accounts,
we will verify whether the user created in keycloak can be controlled through the Harbor UI, and also test CLI login and docker events.
First, enter the Realm of the keycloak integrated with harbor, select the Users menu, and press the Add user button.

Create one appropriately. After creating the user by pressing the Save button, enter the Credentials tab.

Enter password / confirmation and press the âSet Passwordâ button. Next, enter the Role Mappings tab.

In the Client Roles combo box, select the client connected to harbor, and map the Role.
Now that a User has been appropriately created, press the âLogin via OIDC Providerâ button in the Harbor Web UI to log in.

After changing the password, a window appears to enter the OIDC username

Once you enter this as well, you are logged in to harbor. Afterward, if you go in with the admin account, you can see that the account you just created appears in users.

Now we will send a CLI command as that user.
Connect again as the user you created earlier and click the OIDC username in the top right to enter the User profile.


Copy the CLI secret and attempt docker login [YOUR_DOMAIN].
docker login harbor2.example.comLog in with the OIDC username and CLI secret configured in harbor.

Registry Replication
Section titled âRegistry ReplicationâConfiguring Redundancy
Section titled âConfiguring RedundancyâAmong the features officially supported by Harbor, there is âConfiguring Replicationâ.
This synchronizes resources (images, charts, etc.) between multiple registries.
When a Harbor system administrator configures a Replication Rule, all resources matching the defined filter pattern are replicated to the target registry when the trigger condition is met.
cf) However, in actual production environments, you often need to mirror to release tens or hundreds of cluster nodes. In this case, a single download registry cannot meet the demands of many nodes, so you configure multiple instance registries to perform load balancing.

As shown above, Harbor supports replication of various registries.
I configured one more harbor Registry in advance (harbor2), and registered the existing harborâs endpoint in harbor2

Once youâve registered the endpoint, enter the Replications menu and try creating a Rule.

You can see that the endpoint you just registered appears in the Destination registry (the registry to synchronize data to).
push-based and pull-based determine whether to replicate from another registry or replicate to another registry when replicating an artifact. (Official Harbor docs: Select Push-based or Pull-based replication, depending on whether you want to replicate artifacts to or from the remote registry.)
Once youâve registered it this way, the data is synchronized with the existing harbor each time an image is pushed to harbor2 as shown below.

Image push to harbor2

kmchoi-test was also pushed to the existing harbor.
However, registering the existing harbor Registry in harbor2 only means one-way synchronization from harbor2->harbor,
so if you want two-way synchronization, you must also create a Rule with the harbor2 Registry in harbor.
Vulnerability Scanning
Section titled âVulnerability ScanningâEnter Projects > Repo
In the Artifacts tab, select the desired image and click the SCAN button

Once the scan is complete and you click the artifact, you can check the scan results as follows.

If you hover over Vulnerabilities, you can also check the vulnerability statistics.
