Architecture

The overall architecture of OpenKruise is shown as below:

alt

API

All features provided by OpenKruise are following Kubernetes API, including:

  • CRD definition, such as
  1. $ kubectl get crd | grep kruise.io
  2. advancedcronjobs.apps.kruise.io 2021-09-16T06:02:36Z
  3. broadcastjobs.apps.kruise.io 2021-09-16T06:02:36Z
  4. clonesets.apps.kruise.io 2021-09-16T06:02:36Z
  5. containerrecreaterequests.apps.kruise.io 2021-09-16T06:02:36Z
  6. daemonsets.apps.kruise.io 2021-09-16T06:02:36Z
  7. imagepulljobs.apps.kruise.io 2021-09-16T06:02:36Z
  8. nodeimages.apps.kruise.io 2021-09-16T06:02:36Z
  9. podunavailablebudgets.policy.kruise.io 2021-09-16T06:02:36Z
  10. resourcedistributions.apps.kruise.io 2021-09-16T06:02:36Z
  11. sidecarsets.apps.kruise.io 2021-09-16T06:02:36Z
  12. statefulsets.apps.kruise.io 2021-09-16T06:02:36Z
  13. uniteddeployments.apps.kruise.io 2021-09-16T06:02:37Z
  14. workloadspreads.apps.kruise.io 2021-09-16T06:02:37Z
  15. # ...
  • Specific identities (e.g. labels, annotations, envs) in resources, such as
  1. apiVersion: v1
  2. kind: Namespace
  3. metadata:
  4. labels:
  5. # To protect pods in this namespace from cascading deletion.
  6. policy.kruise.io/delete-protection: Cascading

Manager

Kruise-manager is a control plane component that runs controllers and webhooks, it is deployed by a Deployment in kruise-system namespace.

  1. $ kubectl get deploy -n kruise-system
  2. NAME READY UP-TO-DATE AVAILABLE AGE
  3. kruise-controller-manager 2/2 2 2 4h6m
  4. $ kubectl get pod -n kruise-system -l control-plane=controller-manager
  5. NAME READY STATUS RESTARTS AGE
  6. kruise-controller-manager-68dc6d87cc-k9vg8 1/1 Running 0 4h6m
  7. kruise-controller-manager-68dc6d87cc-w7x82 1/1 Running 0 4h6m

Logically, each controller like cloneset-controller or sidecarset-controller is a separate process, but to reduce complexity, they are all compiled into a single binary and run in the kruise-controller-manager-xxx single Pod.

Besides controllers, this Pod also contains the admission webhooks for Kruise CRDs and Pod. It creates webhook configurations to configure which resources should be handled, and provides a Service for kube-apiserver calling.

  1. $ kubectl get svc -n kruise-system
  2. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  3. kruise-webhook-service ClusterIP 172.24.9.234 <none> 443/TCP 4h9m

The kruise-webhook-service is much important for kube-apiserver calling.

Daemon

This is a new daemon component released since Kruise v0.8.0 version.

It is deployed by DaemonSet, runs on every node and manages things like image pre-download, container restarting.

  1. $ kubectl get pod -n kruise-system -l control-plane=daemon
  2. NAME READY STATUS RESTARTS AGE
  3. kruise-daemon-6hw6d 1/1 Running 0 4h7m
  4. kruise-daemon-d7xr4 1/1 Running 0 4h7m
  5. kruise-daemon-dqp8z 1/1 Running 0 4h7m
  6. kruise-daemon-dv96r 1/1 Running 0 4h7m
  7. kruise-daemon-q7594 1/1 Running 0 4h7m
  8. kruise-daemon-vnsbw 1/1 Running 0 4h7m