Giter Site home page Giter Site logo

shelahli / kruise Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openkruise/kruise

0.0 1.0 0.0 39.55 MB

Automate application workloads management on Kubernetes

Home Page: https://openkruise.io

License: Apache License 2.0

Dockerfile 0.06% Makefile 0.20% Go 99.69% Shell 0.05%

kruise's Introduction

OpenKruise/Kruise

License Go Report Card codecov CII Best Practices

Kruise is at the core of the OpenKruise project. It is a set of controllers which extends and complements Kubernetes core controllers on application workload management.

Today, Kruise offers three application workload controllers:

  • Advanced StatefulSet: An enhanced version of default StatefulSet with extra functionalities such as inplace-update, sharding by namespace.

  • BroadcastJob: A job that runs pods to completion across all the nodes in the cluster.

  • SidecarSet: A controller that injects sidecar container into the pod spec based on selectors.

Please see documents for more technical information.

Several tutorials are provided to demonstrate how to use the workload controllers.

Getting started

Install with YAML files

Install CRDs
kubectl apply -f https://raw.githubusercontent.com/kruiseio/kruise/master/config/crds/apps_v1alpha1_broadcastjob.yaml
kubectl apply -f https://raw.githubusercontent.com/kruiseio/kruise/master/config/crds/apps_v1alpha1_sidecarset.yaml
kubectl apply -f https://raw.githubusercontent.com/kruiseio/kruise/master/config/crds/apps_v1alpha1_statefulset.yaml

Note that ALL three CRDs need to be installed for kruise-controller to run properly.

Install kruise-controller-manager

kubectl apply -f https://raw.githubusercontent.com/kruiseio/kruise/master/config/manager/all_in_one.yaml

Or run from the repo root directory:

kustomize build config/default | kubectl apply -f -

To Install Kustomize, check kustomize website.

Note that use Kustomize 1.0.11. Version 2.0.3 has compatibility issues with kube-builder

The official kruise-controller-manager image is hosted under docker hub.

Usage examples

Advanced StatefulSet

apiVersion: apps.kruise.io/v1alpha1
kind: StatefulSet
metadata:
  name: sample
spec:
  replicas: 3
  serviceName: fake-service
  selector:
    matchLabels:
      app: sample
  template:
    metadata:
      labels:
        app: sample
    spec:
      readinessGates:
        # A new condition must be added to ensure the pod remain at NotReady state while the in-place update is happening
      - conditionType: InPlaceUpdateReady 
      containers:
      - name: main
        image: nginx:alpine
  podManagementPolicy: Parallel  # allow parallel updates, works together with maxUnavailable
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      # Do in-place update if possible, currently only image update is supported for in-place update
      podUpdatePolicy: InPlaceIfPossible
      # Allow parallel updates with max number of unavailable instances equals to 2
      maxUnavailable: 2

Broadcast Job

Run a BroadcastJob that each Pod computes pi, with ttlSecondsAfterFinished set to 30. The job will be deleted in 30 seconds after the job is finished.

apiVersion: apps.kruise.io/v1alpha1
kind: BroadcastJob
metadata:
  name: broadcastjob-ttl
spec:
  template:
    spec:
      containers:
        - name: pi
          image: perl
          command: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]
      restartPolicy: Never
  completionPolicy:
    type: Always
    ttlSecondsAfterFinished: 30

SidecarSet

The yaml file below describes a SidecarSet that contains a sidecar container named sidecar1

# sidecarset.yaml
apiVersion: apps.kruise.io/v1alpha1
kind: SidecarSet
metadata:
  name: test-sidecarset
spec:
  selector: # select the pods to be injected with sidecar containers
    matchLabels:
      app: nginx
  containers:
  - name: sidecar1
    image: centos:7
    command: ["sleep", "999d"] # do nothing at all 

Developer Guide

There's a Makefile in the root folder which describes the options to build and install. Here are some common ones:

Build the controller manager binary

make manager

Run the tests

make test

Build the docker image, by default the image name is openkruise/kruise-manager:v1alpha1

export IMG=<your_image_name> && make docker-build

Push the image

export IMG=<your_image_name> && make docker-push or just docker push <your_image_name>

Generate manifests e.g. CRD, RBAC etc.

make manifests

Community

If you have any questions or want to contribute, you are welcome to join our slack channel

Mailing List: todo

Copyright

Certain implementation relies on existing code from Kubernetes and the credit goes to original Kubernetes authors.

kruise's People

Contributors

jian-he avatar fillzpp avatar resouer avatar xiang90 avatar allencloud avatar wonderflow avatar fei-guo avatar bswang avatar technosophos avatar coldtea214 avatar

Watchers

James Cloos avatar

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.