Harbor is an indispensable open-source container image registry, offering robust features like policy-driven security, role-based access control, vulnerability scanning, image signing, image replication and distribution. Deploying Harbor is a common and critical step for organizations looking to streamline their containerization workflows. Harbor offers significant value through its comprehensive features and can be deployed on a virtual machine. 

This blog post will pick up where we left off, guiding you through the process of deploying Harbor on an upstream conformant Kubernetes platform using Helm

If you are interested to learn more about Harbor and how to deploy it on a VM, check out our previous blog.

Why deploy Harbor on Kubernetes?

Deploying Harbor on Kubernetes offers several advantages:

Understanding Harbor architecture and components

Harbor follows a microservices architecture, with each component serving a specific purpose in the overall container registry ecosystem. Understanding these components is crucial for effective deployment, troubleshooting, and optimization.

Image Source: Official Harbor GitHub repository

Image Source: Official Harbor GitHub repository

Core Harbor components:

For an in-depth understanding of the Harbor architecture, refer to the “Architecture Overview of Harbor” Wiki page on Harbor’s official GitHub repository.

How these components work together:

When a user pushes an image to Harbor, the request flows through the Harbor Core, which authenticates and authorizes the operation. The image data is then stored by the Registry component, with metadata saved in PostgreSQL. The Job Service can then trigger a vulnerability scan, with results stored back in the database. Redis caches frequently accessed data to improve response times. When replication is configured, the Job Service handles copying images to other Harbor instances asynchronously.

This distributed architecture ensures scalability, resilience, and separation of concerns, making Harbor suitable for enterprise-grade deployments.

Deploying Harbor on Kubernetes using Helm

Harbor cloud flow chart
  1. Prerequisites:
    • A running Kubernetes cluster
    • kubectl is configured to interact with your cluster.
    • Helm (recommended) for simplified deployment.
    • Persistent storage provisioner (e.g., NFS, iSCSI etc.). You can also configure an object storage to store the blobs of the artifacts. This is widely used for users deploying an HA instance of Harbor
    • A load balancer/ingress controller/gateway API to expose Harbor services
  1. Download Harbor Deployment Manifests: Obtain the official Harbor Helm charts or raw Kubernetes YAML files. Helm is typically preferred for its ease of configuration and management.
> helm repo add harbor https://helm.goharbor.io
> helm fetch harbor/harbor --untar
Code example
  1. Configure values.yaml: Customize the values.yaml file (for Helm) to define:
    • External URL.
    • Storage class for persistent volumes.
    • Database configuration (internal or external PostgreSQL).
    • Redis configuration.
    • Security settings (TLS/SSL certificates).
    • Administrator credentials.

For our particular scenario, we change:

  1. Deploy Harbor: Use Helm to deploy Harbor into your cluster.
> helm install harbor harbor/harbor --namespace harbor --create-namespace -f values.yaml

This command will create the necessary deployments, services, statefulsets, and persistent volume claims for Harbor.

Code example
  1. Optionally, there is a manual step to setup the load balancer that is used for the Harbor external IP. In our case, we have already set that up.
  1. Verify deployment: Check the status of Harbor pods, access the UI, and perform a test push/pull of an image.
Code example
Projects

This concludes the deployment of Harbor on a kubernetes cluster using Helm. This gets Harbor up and running however does not make it production-ready as it is missing SSL certificates that need to be set up and managed manually as well as the load balancer that fronts the Harbor service. 

Additional considerations for production deployments include implementing backup and disaster recovery strategies for the Harbor database and registry storage, configuring high availability with multiple replicas of core components, setting up monitoring and alerting using tools like Prometheus and Grafana, and implementing proper access control policies and RBAC configurations.

Summary:

Deploying Harbor on Kubernetes provides a robust, scalable, and cloud-native solution for container image management. By leveraging Helm charts and Kubernetes orchestration capabilities, organizations can quickly deploy Harbor with minimal manual configuration while benefiting from Kubernetes’ built-in reliability and scaling features.

Key takeaways from this deployment guide include understanding Harbor’s microservices architecture, properly configuring persistent storage and networking, and verifying functionality through the UI. While this basic deployment gets Harbor operational, additional hardening and production-readiness steps are necessary for enterprise environments.