Boost Kubernetes Deployments with OpenKruise’s Advanced StatefulSet
This article explains the challenges of traditional Deployment and StatefulSet IDs, introduces OpenKruise and its five enhanced controllers, details the installation process via Helm, and demonstrates how Advanced StatefulSet enables parallel pod startup and in‑place updates for faster, more reliable workloads.
Background
When deploying applications with Deployment, pod IDs change frequently, making monitoring and ID‑bound services difficult. Using StatefulSet solves the ID issue but introduces a new problem: pods start sequentially, causing long startup times for large‑scale workloads.
OpenKruise Overview
OpenKruise (https://github.com/openkruise/kruise) extends Kubernetes with five improved controllers:
CloneSet – manages stateless applications with features such as in‑place update, configurable priority, and pre/post‑update hooks.
Advanced StatefulSet – adds in‑place update strategies (InPlaceIfPossible, InPlaceOnly) and supports parallel pod startup.
SidecarSet – injects and upgrades sidecar containers based on selectors.
UnitedDeployment – manages pods across multiple fault domains using multiple workloads.
BroadcastJob – runs a job on every node in the cluster.
Advanced StatefulSet extends the native StatefulSet by supporting both recreate and rolling‑update strategies, with two rolling‑update modes: InPlaceIfPossible (updates only the container image) and InPlaceOnly (forces in‑place updates, rejecting non‑image changes). It also allows parallel pod startup.
Deploying OpenKruise
The official installation guide is available at the project’s documentation. Below are the essential steps:
<code>wget https://github.com/openkruise/kruise/releases/download/v0.4.0/kruise-chart.tgz
tar xf kruise-chart.tgz
cd kruise
helm install openkruise ./ -n kube-system</code>OpenKruise is now at version v0.5.0 and can also be installed via Alibaba Cloud’s application catalog.
Detailed installation:
Obtain the Helm chart:
<code>helm repo add incubator http://aliacs-k8s-cn-beijing.oss-cn-beijing.aliyuncs.com/app/charts-incubator/
helm search repo ack-kruise
helm fetch incubator/ack-kruise
tar xf ack-kruise-0.5.0.tgz
cd ack-kruise</code>Modify
values.ymlto use a private image repository and enable only the Advanced StatefulSet resource:
<code># Default values for kruise.
revisionHistoryLimit: 3
manager:
log:
level: "4"
image:
repository: hub.example.com/library/kruise-manager
tag: v0.5.0
resources:
limits:
cpu: 500m
memory: 1Gi
requests:
cpu: 500m
memory: 1Gi
metrics:
addr: localhost
port: 8080
custom_resource_enable: StatefulSet</code>Only the image repository and
custom_resource_enablefields are changed.
Install the chart:
<code>helm install ack-kruise -n kube-system ./</code>After installation, five CRDs are created:
<code># kubectl get crds | grep kruise
broadcastjobs.apps.kruise.io
clonesets.apps.kruise.io
sidecarsets.apps.kruise.io
statefulsets.apps.kruise.io
uniteddeployments.apps.kruise.io</code>A
kruise-systemnamespace is created with a controller manager pod:
<code># kubectl get pods -n kruise-system
NAME READY STATUS RESTARTS AGE
kruise-controller-manager-0 1/1 Running 0 55m</code>Verify that the StatefulSet webhook is created and that unrelated mutating webhooks are disabled.
These webhooks are part of Kubernetes admission control; if they malfunction, requests can fail or be delayed.
Usage Example
Below is a sample manifest for an OpenKruise Advanced StatefulSet:
<code>apiVersion: apps.kruise.io/v1alpha1
kind: StatefulSet
metadata:
name: demo-v1-guestbook-kruise
labels:
app.kubernetes.io/name: guestbook-kruise
app.kubernetes.io/instance: demo-v1
spec:
replicas: 3
serviceName: demo-v1-guestbook-kruise
selector:
matchLabels:
app.kubernetes.io/name: guestbook-kruise
app.kubernetes.io/instance: demo-v1
template:
metadata:
labels:
app.kubernetes.io/name: guestbook-kruise
app.kubernetes.io/instance: demo-v1
spec:
readinessGates:
- conditionType: InPlaceUpdateReady
containers:
- name: guestbook-kruise
image: openkruise/guestbook:v1
imagePullPolicy: Always
ports:
- name: http-server
containerPort: 3000
podManagementPolicy: Parallel
updateStrategy:
type: RollingUpdate
rollingUpdate:
podUpdatePolicy: InPlaceIfPossible
maxUnavailable: 3</code>Deploying this manifest results in three running pods:
<code># kubectl get pods | grep demo-v1
demo-v1-guestbook-kruise-0 1/1 Running 0 62s
demo-v1-guestbook-kruise-1 1/1 Running 0 62s
demo-v1-guestbook-kruise-2 1/1 Running 0 62s</code>Check the resource status:
<code># kubectl get sts.apps.kruise.io
NAME DESIRED CURRENT UPDATED READY AGE
demo-v1-guestbook-kruise 3 3 3 3 56s</code>OpenKruise’s StatefulSet resource is identified as sts.apps.kruise.io .
For more details, refer to the official documentation links for Advanced StatefulSet and UnitedDeployment.
Efficient Ops
This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.