Giter VIP home page Giter VIP logo

controllermesh's Introduction

ControllerMesh

ControllerMesh is a solution that helps developers manage their controllers/operators better.

Key Features

  1. Canary update: the controllers can be updated in canary progress instead of one time replace.
  2. Fault injection: it helps developers to verify their reconcile logic in some fault scenarios.
  3. Flexible isolation: limits resources of which namespaces can be queried by a controller.
  4. Client-side rate-limit and blown.

Implementation Constraints

Generally, a ctrlmesh-proxy container will be injected into each operator Pod that has configured in ControllerMesh. This proxy container will intercept and handle the connection by between API Server and controllers/webhooks in the Pod.

The ctrlmesh-manager dispatches rules to the proxies, so that they can route requests according to the rules.

A core CRD in ControllerMesh is VirtualApp. It contains all rules for user's controller and webhook:

apiVersion: ctrlmesh.kruise.io/v1alpha1
kind: VirtualApp
metadata:
  name: test-operator
  # ...
spec:
  selector:
    matchLabels:
      component: test-operator
  configuration:
    controller:
      leaderElectionName: test-operator
    webhook:
      certDir: /tmp/webhook-certs
      port: 9443
  route:
    globalLimits:
    - namespaceSelector:
        matchExpressions:
        - key: ns-type
          operator: NotIn
          values:
          - system
    subRules:
    - name: canary-rule
      match:
      - namespaceSelector:
          matchLabels:
            ns-type: canary-1
      - namespaceRegex: "^canary.*"
  subsets:
  - name: v2
    labels:
      version: v2
    routeRules:
    - canary-rule
  • selector: for all pods of the test-operator
  • configuration:
    • controller: configuration for controller, including leader election name
    • webhook: configuration for webhook, including certDir and port of this webhook
  • route:
    • globalLimits: limit rules that enable to all pods of test-operator
    • subRules: multiple rules that can define to be used in subsets
  • subsets: multiple groups of the pods, each subset has specific labels and its route rules

Flow control

ControllerMesh will firstly support Hard Limit type of flow control, which means the ctrlmesh-proxy will filter unmatched requests/responses between API Server and local controller/webhook.

Controller:

Webhook:

Risks and Mitigations

  1. The controller/webhook can not get any requests if ctrlmesh-proxy container crashes.
  2. Developers can not change the flow rules of their operators if kruise-manager is not working.
  3. The performance of controller/webhook will be a little worse.
  4. Pod of the operator requires a few more resources because of a ctrlmesh-proxy container injected into it.

License

ControllerMesh is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

controllermesh's People

Contributors

eikykun avatar fillzpp 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

controllermesh's Issues

[BUG] Should we restart all pods to resync cache after vapp was updated ?

What happened:
If vapp specHash changed, the proxy container will block leader election to restart main container.
But only leader pod restarted, other proxy container always wait for main container to restart.

Why it happened:
In controller-runtime LeaderElector, it has 2 loops to run the leader election:

  1. acquire() lock
  2. renew() lock

Only 2 will panic after catch an error.
Leader pod in loop 2, but other pods in loop 1.

What you expected to happen:
My expectation is to restart all pods after vapp specHash changed...

Add LabelSelector in MatchLimitSelector, and inject ListOptions before the proxy forward httpReq

What would you like to be added:

  • Inject ListOptions before forwarding httpReq. Select rule will be defined in crd.
  • Modify CRD. Add LabelSelector in MatchLimitSelector, it defined injection rules.

More details to be discussed. cc @FillZpp

Why is this needed:

In proxy router, the source httpReq was forwarded directly to apiserver. Then the apiserver still needs to process(List/Watch) all the resources with no limits, e.g. list all pods. For clusters with huge resources, apiserver will be under tremendous pressure when processing multiple shards, and operator also warm up with long time.

BUG REPORT: leader-election hander bug

BUG REPORT

On controller-mesh/proxy/leaderelection/election_handler.go L150 and L168,

	r.URL.Path = strings.Replace(r.URL.Path, h.lockName, name, -1)
        ...
	r.URL.Path = strings.Replace(r.URL.Path, h.lockName, setSubsetIntoName(h.lockName, h.routeSnapshot.Route.Subset), -1)

If a leader-election name appears more than once in URL.Path, It'll be replaced entirely.
Especially one leader-election resource name is same with namespace.

e.g.
For: /api/v1/namespaces/cafeextcontroller/configmaps/cafeextcontroller
expect : /api/v1/namespaces/cafeextcontroller/configmaps/cafeextcontroller---ctrlmeshtest
but real : /api/v1/namespaces/cafeextcontroller---ctrlmeshtest/configmaps/cafeextcontroller---ctrlmeshtest

further development

Why hasn't there been any development on a project that seems to have great potential for almost 2 years?

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.