GithubHelp home page GithubHelp logo

szlabs / harbor-automation-4k8s Goto Github PK

View Code? Open in Web Editor NEW
13.0 13.0 3.0 843 KB

Provide related capabilities to automate Harbor usage and improve its usabilities.

License: Apache License 2.0

Dockerfile 0.92% Makefile 3.71% Go 95.37%

harbor-automation-4k8s's People

Contributors

cnmcavoy avatar hanlins avatar lubronzhan avatar steven-zou avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

harbor-automation-4k8s's Issues

Support image path auto rewriting

a webhook:

image pulling path of the deploying workloads in the specified namespace can be rewritten to the harbor project linked with the k8s namespace

for example:

k8s namespace: my-space
annotations: goharbor.io/project: mypro
goharbor.io/secret-issuer: myharbor

Make project and robot as required in PSB

The current reconciliation logic is confusing and might cause confusion. Among the 4 possible combinations of robot and project annotation existence, which are:

  1. robot not exist, project not exist
  2. robot not exist, project exist
  3. robot exist, project not exist
  4. robot exist, project exist

Case 2, 3 are invalid. For case 1, we need to automatically create harbor project and robot account, and for case 4, we need check whether these information are valid in harbor. It's overly complicated for PSB as it should be solely focusing on secret binding.

Proposing to move the annotation validation logic to namespace controller and making robot and project required field for PSB object. Namespace controller should validate or create corresponding resources, and create PSB with validated configurations. For PSB, it should always assume that the project and robot in its spec exists in harbor.

Set robot account expiration and recreate it when account is removed

For a robot account, from a security standpoint, we should set an expiration for that account or at least rotate its credentials. As currently, we can't rotate robots' credentials/tokens in harbor itself, we should set an expiration date in the operator when creating the robot account as a future improvement. And by the nature of controller reconciliation logic, a new robot account should be created after the old one expires.

If mutation webhook created before controller, controller pod will fail to be created

Context

  Warning  FailedCreate      3s (x12 over 15s)  replicaset-controller  Error creating: Internal error occurred: failed calling webhook "mimg.kb.io": Post "https://harbor-automation-4k8s-webhook-service.harbor-day2-op.svc:443/mutate-image-path?timeout=30s": dial tcp 100.68.145.242:443: connect: connection refused

This is because once the mutationWebhookConfiguration is deployed, our api server will check all pods creation, including our controller pod. API server will call our webhook server. But since our controller pod contains the webhooks server, so it needs to come up first before apiserver could trigger webhook. This will becomes a deadlock if we deploy our controller after the mutationWebhookConfiguration.

Related issue kubernetes-sigs/kustomize#821

Reproduce steps

make deploy

Possible solution

  1. Add labels our namespace, so webhook controller could skip namespaces with those labels
    Drawback: k8s related or other system level namespaces needs labels as well, there could be potential issue
  2. Webhook controller only checks namespaces with specific labels
    Drawback: we will need to modify namespaces labels, except the annotations on them.

Harbor self-signed certificate auto-injection

If customer use self-signed certificate, the container runtime of K8s cluster needs to trust the certifcate.
In the future, k8s will be using containerd as primary runtime.
But currently containerd doesn't support hosts-dir folder as docker to inject cert in runtime.
Once this PR is in containerd/containerd#4978 new containerd and used by K8s, we should be able to inject cert without restarting containerd

Add a global Harbor Server Configuration

The harbor server configuration CRD should be extended to support a global default use-case, that if present, applies annotations to namespaces missing the harbor operator annotations.

I think the most straightforward implementation would be to add an additional field on the CRD, default bool. When a harbor server configuration CRD default is set to true, the operator will treat existing and new namespaces lacking the operator annotations as if they were annotated to use the default CRD. Submissions of multiple CRDs with the default: true in the spec will be rejected by the operator, to ensure only 1 CRD exists with default: true.

Support image pulling secret auto injection

bind the harbor robot account (k8s secret format) to the specified service account under the k8s namespace.

  • CR needs to be defined
  • a reconcile ctrl should be implemented

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.