Git Product home page Git Product logo

harbor-operator's Introduction

Harbor Operator

CI Pipeline CodeQL Codacy Badge Go Reference

ATTENTIONS: THE main BRANCH MAY BE IN AN UNSTABLE OR EVEN BROKEN STATE DURING DEVELOPMENT.

Harbor is a CNCF hosted open source trusted cloud-native registry project that stores, signs, and scans content. Harbor is composed on numerous stateful and stateless components and dependencies that may be deployed, updated, healed, backuped or scaled respecting some constraints.

The Harbor Operator provides an easy and solid solution to deploy and manage a full Harbor service stack including both the harbor service components and its relevant dependent services such as database, cache and storage services to the target Kubernetes clusters in a scalable and high-available way. The Harbor Operator defines a set of Harbor-related custom resources on top of Kubernetes Custom Resources. The Kubernetes API can then be used in a declarative way to manage Harbor deployment stack and ensure its scalability and high-availability operation, thanks to the Kubernetes control loop. The project harbor-operator aims to cover both Day1 and Day2 operations of an enterprise-grade Harbor deployment.

Features

Harbor deployment stack is controlled by a custom Harbor resource HarborCluster. HarborCluster owns the custom resource Harbor that represents the Harbor own service stack, and the custom resources of the related dependent services (PostgreSQL, Redis and MinIO) that are required when deploying the full Harbor deployment stack.

  • Provides strong flexibility to deploy different stacks of Harbor cluster (identified by HarborCluster CR)
    • Minimal stack: only required Harbor components Core, Registry, Registry Controller, Job Service and Portal are provisioned.
    • Standard stack: the optional Harbor components Notary, Trivy, ChartMuseum and Metrics Exporter can be selected to enable.
    • Full stack: both the Harbor components (required+optional) and also the related dependent services including the database (PostgreSQL), cache (Redis) and storage (MinIO) can be deployed into the Kubernetes cluster together with a scalable and high-available way.
  • Supports configuring either external or in-cluster deployed dependent services
  • Supports a variety of backend storage configurations
    • filesystem: A storage driver configured to use a directory tree in the a kubernetes volume.
    • s3: A driver storing objects in an Amazon Simple Storage Service (S3) bucket.
    • swift: A driver storing objects in Openstack Swift.
    • azure: A driver storing objects in Microsoft Azure Blob Storage.
    • gcs: A driver storing objects in a Google Cloud Storage bucket.
  • Supports updating the deployed Harbor cluster
    • Adjust replicas of components
    • Add/remove the optional Harbor components
  • Supports upgrading the managed Harbor registry version
  • Deletes all the linked resources when deleting the Harbor cluster
  • Support services exposed with ingress: nginx(default), gce, contour and ncp
  • Support Day2 operations
    • Configures Harbor system settings with configuration CRD (recommend) or labeled ConfigMap (deprecated)

Future features

  • Support Day2 operations
    • Image pulling secret auto-injection
      • Auto mapping Kubernetes namespaces to the Harbor project
    • Image pulling path auto-rewriting
      • Transparent proxy cache settings
    • Certification auto injection
    • Manage Harbor resources with the declaration way
      • Robot account
      • and more
  • Auto-scaling for each component.
  • Backup/restore data (registry layer, chartmuseum data, databases content).
  • Support services exposed with LoadBalancer

Release plans

Getting started

For a quick first try follow the instructions of this tutorial.

Versioning

Versions of the underlying components are listed below:

Components Harbor MinIO operator PostgreSQL operator Redis operator
Versions 2.5.x [1] 4.4.28 1.7.0 1.1.1

NOTES:

[1] .x means all the patch releases of Harbor can be naturally supported in one operator version.

Compatibility

Applicative Kubernetes versions

Harbor operator supports two extra Kubernetes versions besides the current latest version (n-2 pattern):

Versions 1.21 1.22 1.23 1.24
Compatibility ✔️ ✔️ ✔️ ✔️

Cert manager versions

Harbor operator relies on cert manager to manage kinds of certificates used by Harbor cluster components. Table shown below lists the compatibilities of cert manager versions:

Versions 1.6[.3] 1.7[.3] 1.8[.2] 1.9[.1]
Compatibility ✔️ ✔️ ✔️ ✔️

Ingress controller types

Harbor operator exposes the frontend service with ingress (CRD version: v1beta1). Table shown below lists the ingress controller types supported.

Ingress Controller Compatibility Description
default ✔️ Default ingress controller like NGINX
gce ✔️ Google Cloud Engine ingress controller
ncp ✔️ NSX-T Container plugin ingress controller
contour ✔️ Ingress controller that works by deploying the Envoy proxy

NOTES:

✔️ : supported ✖️ : not supported ⭕ : not verified (probably supported)

Documentation

Contributions

Harbor operator project is developed and maintained by the Harbor operator workgroup. If you're willing to join the group and do contributions to operator project, welcome to contact us. Follow the Development guide to start on the project.

Special thanks to the contributors who did significant contributions (see feature area).

Community

Additional references

Related links

Recognition

The operator was initially developed by OVHcloud and donated to the Harbor community as one of its governing projects in March 2020, becoming the basis of the official Harbor Operator.

OVHcloud uses the operator at scale to operate part of its private registry service. But the operator was designed in an agnostic way and it's continuing to evolve into a more pervasive architecture to bring values to any companies in search of deploying and managing one or multiple Harbor.

License

See LICENSE for licensing details.

harbor-operator's People

Contributors

bitsf avatar cagiti avatar chlins avatar christianloewel avatar cndoit18 avatar colinlabs avatar dependabot[bot] avatar ghostbaby avatar heww avatar holyhope avatar jmonsinjon avatar jsuchome avatar lengrongfu avatar lubronzhan avatar marcelmue avatar mhurtrel avatar p4ndafr avatar sagikazarmark avatar sguyennet avatar shouenhsiao avatar soulseen avatar steven-zou avatar testwill avatar thcdrt avatar wangcanfengxs avatar william-young-97 avatar xavierduthil avatar xoanmi avatar ywk253100 avatar yxxhero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

harbor-operator's Issues

The ready condition is False, but the core component is healthy

Pod Status

root@example-large0:~# kubectl get pod
NAME                                                      READY   STATUS    RESTARTS   AGE
all-in-one-database-postgresql-0                          1/1     Running   0          13h
all-in-one-minio-56d65664f8-znx6b                         1/1     Running   0          13h
all-in-one-redis-master-0                                 1/1     Running   0          13h
all-in-one-redis-slave-0                                  1/1     Running   0          13h
all-in-one-redis-slave-1                                  1/1     Running   0          13h
harborcluster-sample-harbor-core-669d75dd4-qh8fs          1/1     Running   0          2m3s
harborcluster-sample-harbor-jobservice-564cffbcb5-95dc9   1/1     Running   0          2m3s
harborcluster-sample-harbor-portal-bdd9d9b85-gjzjs        1/1     Running   0          2m3s
harborcluster-sample-harbor-registry-9f9f6b546-j7mf9      2/2     Running   0          2m3s

Core Component Health

kubectl exec -it harborcluster-sample-harbor-core-669d75dd4-qh8fs bash

curl localhost:8080/api/health

{"status":"healthy","components":[{"name":"redis","status":"healthy"},{"name":"registry","status":"healthy"},{"name":"jobservice","status":"healthy"},{"name":"core","status":"healthy"},{"name":"registryctl","status":"healthy"},{"name":"portal","status":"healthy"},{"name":"database","status":"healthy"}]}

Harbor Status

status:
  conditions:
  - lastTransitionTime: "2020-09-15T03:27:24Z"
    lastUpdateTime: "2020-09-15T03:27:24Z"
    status: "True"
    type: Applied
  - lastTransitionTime: "2020-09-15T11:09:17Z"
    lastUpdateTime: "2020-09-15T21:09:17Z"
    message: 'cannot get health response: unknown (get service harborcluster-sample-harbor-core)'
    reason: unknown (get service harborcluster-sample-harbor-core)
    status: "False"
    type: Ready
  observedGeneration: 1

Introduce global secret reference for database and Redis

At present, different components using Redis will have different secrets that containing the connection info of different databases or Redis instances.

As allowing the user to configure the unique HA database service or sentinel Redis service and keep the current multiple secrets approach, we can introduce a global secret reference:

  • If the component level secret is specified, then use component level secret reference
  • Otherwise, use the global one as the default secret

have a error in make install-dependencies

If you are reporting a problem, please make sure the following information are provided:

Expected behavior and actual behavior:
I follow installation doc to install harbor-operator. When I run make install-dependencies, I have a error

➜  harbor-operator git:(master) ✗ make install-dependencies
which: no controller-gen in (/usr/local/bin:/usr/bin:/home/centos/bin:/usr/local/sbin:/usr/sbin:/home/centos/gocode/bin)
which: no markdownlint in (/usr/local/bin:/usr/bin:/home/centos/bin:/usr/local/sbin:/usr/sbin:/home/centos/gocode/bin)
which: no golangci-lint in (/usr/local/bin:/usr/bin:/home/centos/bin:/usr/local/sbin:/usr/sbin:/home/centos/gocode/bin)
which: no pkger in (/usr/local/bin:/usr/bin:/home/centos/bin:/usr/local/sbin:/usr/sbin:/home/centos/gocode/bin)
which: no kubebuilder in (/usr/local/bin:/usr/bin:/home/centos/bin:/usr/local/sbin:/usr/sbin:/home/centos/gocode/bin)
which: no kustomize in (/usr/local/bin:/usr/bin:/home/centos/bin:/usr/local/sbin:/usr/sbin:/home/centos/gocode/bin)
which: no gomplate in (/usr/local/bin:/usr/bin:/home/centos/bin:/usr/local/sbin:/usr/sbin:/home/centos/gocode/bin)
which: no goreleaser in (/usr/local/bin:/usr/bin:/home/centos/bin:/usr/local/sbin:/usr/sbin:/home/centos/gocode/bin)
/usr/local/bin/helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
/usr/local/bin/helm get notes core-database \
        || /usr/local/bin/helm install core-database bitnami/postgresql
Error: getting deployed release "core-database": release: "core-database" not found
Error: This command needs 1 argument: chart name
make: *** [install-dependencies] Error 1

Steps to reproduce the problem:

make install-dependencies

Versions:
Please specify the versions of following systems.

  • harbor operator version: [0.5.0]
  • harbor version: [x.y.z]
  • kubernetes version: [1.18.2]
  • Any additional relevant versions such as CertManager

Move `TrivyStorage` to the trivy component?

TrivyStorage *HarborStorageTrivyStorageSpec json:"trivyStorage,omitempty"``

It is a temp storage for trivy to hold CVE DB and is more close to Trivy component itself. Maybe it's better and more clear to put it under the trivy component.

Harbor status based on other resources status

Harbor resource status should be based on dependencies status.
Suggestion: Ensure all deployments are ready to set Harbor to ready.

Reminder: for now, to check the Harbor readiness, the operator calls the /api/health (through the apiserver).
The new way should reduce resource consumption and will be finer status message.

Rename `HarborHelm1_4_0Spec` to a more general one?

I understand the current operator spec is referring to the harbor chart V1.4 templates.

My concern is anyway those two specs will be developed separately in the future. Some configuration may be introduced into the operator spec but not put into the chart template. And If the chart version is upgrading or templates are changed for fixing some bugs in the chart and maybe no influences to the operator, will the operator define a new spec object HarborHelm1_5_0Spec then?

Miss Issure for registry cert

Miss create Issuer for registry cert in Harbor CR namespace.

image

Need to use YAML to create Issuer.

apiVersion: cert-manager.io/v1alpha2
kind: Issuer
metadata:
  name: selfsigned-issuer
  namespace: pg
spec:
  selfSigned: {}

we should consider support setup only one redis in the example

Currently in installation guide, step make install-dependencies will install 3 redis clusters for different components, actually we don't need so many redis instance, and in customer environment they may also only buy one redis cluster with different Database number, so we should also support such case.

redis-cli -n 1

registry components sometimes restart when push big blob

install harbor with harbor-oprator in KIND k8s cluster, with 4G memory, and set nginx proxy-body-size=0
When push docker image golang, which is about 800MB, we can see the docker client failed retry for several times, and the registry pod restart several time.
it is ok that push image busybox.

Not sure if there is memory leak, or healthcheck timeout that leads to the restart

Split components into multiple CRD/controllers

Split the Harbor CRD into multiple smaller one.
So every components can be reconciled independently.

Have a definition for following components

  • ChartMuseum
  • Clair
  • Core
  • JobService
  • NotaryServer
  • NotarySigner
  • Portal
  • Registry
  • RegistryController

And an other definition Harbor which can handle all of them.

BTW with multiple controllers this would reconcile faster.

Feature request - repository and robot custom resources

It would be a great addition to harbor operator to be able to have the operator create a repository and robot account based on custom resources

Currently I need to use the harbor API to create a repositories and robot accounts post install, store the robot token somewhere, create a dockerconfigjson secret for in cluster access to harbor.

All of these things could be automated within the operator allowing declarative deployment of these resources.

Failed to deploy sample with `make sample`

Error:

Error from server (InternalError): error when creating "STDIN": Internal error occurred: failed calling webhook "mharbor.kb.io": the server could not find the requested resource
Makefile:117: recipe for target 'sample' failed
make: *** [sample] Error 1

Check endpoints of webhook SVC:

kubectl describe service -n harbor-operator-system harbor-operator-webhook-service
Name:              harbor-operator-webhook-service
Namespace:         harbor-operator-system
Labels:            <none>
Annotations:       kubectl.kubernetes.io/last-applied-configuration:
                     {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"harbor-operator-webhook-service","namespace":"harbor-operator-sys...
Selector:          control-plane=controller-manager
Type:              ClusterIP
IP:                10.96.115.134
Port:              <unset>  443/TCP
TargetPort:        9443/TCP
Endpoints:         10.244.1.12:9443
Session Affinity:  None
Events:            <none>

Certificates documentation

Harbor resource definition requires a public exposed certificate (through ingresses) and an issuer to create internal certificates. This is unclear for new comers, these components should be documented.

It seems Harbor CR does not update

Reproduce steps:

install harbor core components with make sample, harbor "sample" is deployed

install full harbor with make sample-harbor-full, no more components are deployed.

expectations: the optional components like notary, chartmuseum and trivy should be deployed.

Resource dependency documentation

The operator deploys many resources. Some are required for other.
Write a documentation about resources dependency.
The goal of this documentation is to have a better overview of the components dependency (core, registry, portal, ...) to prepare the 1.0 release with more Custom Resource Definitions.

Use one unified root ca cert to protect exposed core and notary ingresses

When we enable notary (TLS must be enabled), shall we update the following customization files that are located at config/?

  • harbor-full/harbor_notary_patch.yaml
apiVersion: goharbor.io/v1alpha2
kind: Harbor
metadata:
  name: sample
spec:
  notary:
    migrationEnabled: true
  expose:
    notary:
      ingress:
        host: notary.harbor.domain
     tls:  // add tls config and share the same root cert with core?
        certificateRef: sample-public-certificate
  • harbor/https.yaml
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
  name: sample-public-certificate
spec:
  isCA: false
  issuerRef:
    name: sample-public-certificate
  secretName: sample-public-certificate
  dnsNames:
  - core.harbor.domain
  - notary.harbor.domain # add notary domain here?

Dependencies overview

Get an overview of all components & Kubernetes resources dependency.

Please make a graph (maybe with plantuml?)

Example:

  • Job service Deployment requires Core secret to be created

What helm version supported in install-with-kind-k8s.md

when I run
helm install cert-manager jetstack/cert-manager --namespace cert-manager --version v0.13.1
It return error
Error: This command needs 1 argument: chart name

I use helm v2.16.8.
The reason is that helm install only need one argument to specify chart name, any others are flags.
So I changed the command to
helm install --name cert-manager jetstack/cert-manager --namespace cert-manager --version v0.13.1
It works.

Helm chart template

Add Helm chart template files in a chart/ folder. so it is easy to package and deploy the operator.

Yaml files for deploying sample are out of date

The yaml files under config/samples/ are out of date, they're not aligned with the latest harbor CR spec.

kcustomization.yaml

resources:
  - containerregistry_v1alpha1_harbor.yaml # wrong name
  - certificate.yaml
  - requirements.tmpl

goharbor_v1alpha_harbor.yaml

# ...
registryCtl: # wrong
      image: "goharbor/harbor-registryctl:v1.10.0"
    registry:
      storageSecret: registry-storage
      cacheSecret: registry-cache
      image: goharbor/registry-photon:v2.7.1-patch-2819-2553-v1.10.0
# ...

notary:
      publicURL: 'https://{{ env.Getenv "NOTARY_DOMAIN" }}'
      notaryDBMigratorImage: jmonsinjon/notary-db-migrator:v0.6.1 # wrong
      server:
        databaseSecret: notary-server-database
        image: goharbor/notary-server-photon:v0.6.1-v1.10.0
      signer:
        databaseSecret: notary-signer-database
        image: goharbor/notary-signer-photon:v0.6.1-v1.10.0
# ...

Databases & Redis documentation

Explain how to connect databases (with a single databases instances or with multiple instances) to Harbor components.

Please use a graphical representation.

Core         --> Postgresql
Core         --> Redis
Registry     --> Redis
Portal       --> x
JobService   --> Redis
RegistryCtl  --> x
NotaryServer --> Database
...

registry deployment didn't mount registry secret.

There will create a secret which contains an environment variable, REGISTRY_HTTP_SECRET.
But not mount the secret in deployment.

func (r *Registry) GetDeployments(ctx context.Context) []*appsv1.Deployment { // nolint:funlen

Cause:

the registry log:

{"go.version":"go1.12.12","harbor":"harborcluster-sample-harbor","instance.id":"5044caa1-a913-492e-94ce-044445eef03a","level":"warning","msg":"No HTTP secret provided - generated random secret. This may cause problems with uploads if multiple registries are behind a load-balancer. To provide a shared secret, fill in http.secret in the configuration file or set the REGISTRY_HTTP_SECRET environment variable.","operator":"harbor-operator","time":"2020-07-13T12:50:29.202771793Z","version":"v2.7.1.m"}

Enhance the Harbor CRD

Expose more configuration options:

# log configurations
log:
  level: debug
  
# set proxy
proxy:
  http_proxy: 10.10.20.2
  https_proxy: 10.10.20.2
  no_proxy: 10.123.111.10
    components:
    - core
    - jobservice
    - clair

Use harbor version and a unified registry to define the images of Harbor components:

# source registry of images
imageSource:
  registry: harbor.com
  imagePullSecrets:
   - pSecret

Sometimes the registry pods will be crashed at starting

k8s describe registry-pods

Events:
  Type     Reason       Age                    From                                               Message
  ----     ------       ----                   ----                                               -------
  Normal   Scheduled    <unknown>              default-scheduler                                  Successfully assigned harbor/sz-harbor-cluster-harbor-registry-665f8c845-27b7w to ip-10-0-1-218.us-east-2.compute.internal
  Warning  FailedMount  4m39s (x3 over 4m41s)  kubelet, ip-10-0-1-218.us-east-2.compute.internal  MountVolume.SetUp failed for volume "certificate" : secret "sz-harbor-cluster-harbor-certificate" not found

It may be because the certificate is not ready when starting mount operation as creations are handled by concurrent goroutines. And then the creating order cannot be guaranteed.

check pod log:

k8s logs pod/sz-harbor-cluster-harbor-registry-665f8c845-27b7w -n harbor -c registry

configuration error: error parsing /etc/registry/config.yaml: yaml: did not find expected node content

Usage: 
  registry serve <config> [flags]
Flags:
  -h, --help=false: help for serve


Additional help topics:

we should consider support setup only one database in the example

Currently in installation guide, step make install-dependencies will install 3 databases for different components, actually we don't need so many database instance, and in customer environment they may also only buy one database with different schema, so we should also support such case.

The ingress of registry host must specify the max body size of http request

When I push a 5.6MB size image. But failed.

The push refers to repository [test.harbor.local.com/library/socat]
ddc78141088d: Layer already exists
076f4a787bf9: Pushing [==================================================>]    5.6MB/5.6MB
error parsing HTTP 413 response body: invalid character '<' looking for beginning of value: "<html>\r\n<head><title>413 Request Entity Too Large</title></head>\r\n<body>\r\n<center><h1>413 Request Entity Too Large</h1></center>\r\n<hr><center>nginx/1.19.0</center>\r\n</body>\r\n</html>\r\n"

Add nginx.ingress.kubernetes.io/proxy-body-size: 1024m annotation to ingress may resolve this issue, if you use nginx ingress controller.
This annotation value should be configurable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.