Installation

Installing LWS to a Kubernetes Cluster

Before you begin

Make sure the following conditions are met:

  • A Kubernetes cluster with version >= 1.26 is Required, or it will behave unexpected. Learn how to install the Kubernetes tools.
    • For any cluster with version 1.26, you need to enable the feature gate for Start Ordinal manually. For version greater than 1.26, it’s enabled by default.
    • Rolling update with max unavailable Pods, you must enable the MaxUnavailableStatefulSet feature gate, which is still in alpha since Kubernetes v1.24, see discussion here. Or lws will roll out the pods one by one.
  • Your cluster has at least 1 node with 1+ CPUs and 1G of memory available for the LeaderWorkerSet controller manager Deployment to run on. NOTE: On some cloud providers, the default node machine type will not have sufficient resources to run the LeaderWorkerSet controller manager and all the required kube-system pods, so you’ll need to use a larger machine type for your nodes.
  • The kubectl command-line tool has communication with your cluster.

Install a released version

Install by kubectl

To install a released version of LeaderWorkerSet in your cluster, run the following command:

VERSION=v0.9.0
kubectl apply --server-side -f https://github.com/kubernetes-sigs/lws/releases/download/$VERSION/manifests.yaml

To wait for LeaderWorkerSet to be fully available, run:

kubectl wait deploy/lws-controller-manager -n lws-system --for=condition=available --timeout=5m

Install by Helm

To install a released version of lws in your cluster by Helm, run the following command:

CHART_VERSION=0.9.0
helm install lws oci://registry.k8s.io/lws/charts/lws \
  --version=$CHART_VERSION \
  --namespace lws-system \
  --create-namespace \
  --wait --timeout 300s

You can also use the following command:

VERSION=v0.9.0
helm install lws https://github.com/kubernetes-sigs/lws/releases/download/$VERSION/lws-chart-$VERSION.tgz \
  --namespace lws-system \
  --create-namespace \
  --wait --timeout 300s

Upgrade by Helm

Helm only installs the chart’s CRDs during the initial helm install. It does not update or delete CRDs on helm upgrade (see the Helm documentation), so CRD schema changes and newly added CRDs do not reach the cluster through helm upgrade alone.

Apply the CRDs explicitly before upgrading, then upgrade the release in place:

CHART_VERSION=0.9.0
helm pull oci://registry.k8s.io/lws/charts/lws --version=$CHART_VERSION --untar
kubectl apply --server-side --force-conflicts -f lws/crds
helm upgrade lws oci://registry.k8s.io/lws/charts/lws \
  --version=$CHART_VERSION \
  --namespace lws-system \
  --wait --timeout 300s

Upgrading from v0.7.0 or earlier

Chart versions up to v0.7.0 rendered the LeaderWorkerSet CRD from templates/crds/, so the CRD is part of the Helm release manifest. Starting with v0.8.0 the CRD ships from the special crds/ directory and is no longer part of the release. Without preparation, the first helm upgrade across that boundary treats the CRD as removed from the release and deletes it — cascading to the deletion of every LeaderWorkerSet in the cluster (see #880).

Before the first upgrade from v0.7.0 or earlier, run this one-time step so Helm keeps the CRD when it leaves the release:

kubectl annotate crd leaderworkersets.leaderworkerset.x-k8s.io \
  helm.sh/resource-policy=keep --overwrite

Then follow the regular upgrade flow above (apply the CRDs, then helm upgrade). Subsequent upgrades no longer need the annotation step.

Uninstall

To uninstall a released version of LeaderWorkerSet from your cluster, run the following command:

VERSION=v0.9.0
kubectl delete -f https://github.com/kubernetes-sigs/lws/releases/download/$VERSION/manifests.yaml

To uninstall a released version of LeaderWorkerSet from your cluster by Helm, run the following command:

helm uninstall lws --namespace lws-system

Install the latest development version

To install the latest development version of LeaderWorkerSet in your cluster, run the following command:

kubectl apply --server-side -k github.com/kubernetes-sigs/lws/config/default?ref=main

The controller runs in the lws-system namespace.

Uninstall

To uninstall LeaderWorkerSet, run the following command:

kubectl delete -k github.com/kubernetes-sigs/lws/config/default

Build and install from source

To build LeaderWorkerSet from source and install LeaderWorkerSet in your cluster, run the following commands:

git clone https://github.com/kubernetes-sigs/lws.git
cd lws
IMAGE_REGISTRY=<registry>/<project> make image-push deploy

Uninstall

To uninstall LeaderWorkerSet, run the following command:

make undeploy

Install in a different namespace

To install the leaderWorkerSet controller in a different namespace rather than lws-system, you should first:

git clone https://github.com/kubernetes-sigs/lws.git
cd lws

Then change the kustomization.yaml namespace field as:

namespace: <your-namespace>

Optional: Use cert manager instead of internal cert

The webhooks use an internal certificate by default. However, if you wish to use cert-manager (which supports cert rotation), instead of internal cert, follow the cert manage guide.

Install with Helm chart

Please refer to the release page for helm charts.

DisaggregatedSet

Starting from v0.9.0, DisaggregatedSet is bundled with the LWS controller manager.

For kubectl and Kustomize installs, the standard v0.9.0+ manifests include the DisaggregatedSet CRD, controller permissions, and validating webhook. No separate DisaggregatedSet installation step is required.

For Helm installs, the DisaggregatedSet CRD and controller permissions are installed by default. The optional validating webhook and user-facing editor/viewer/admin ClusterRoles can be enabled by passing --set enableDisaggregatedSet=true to the Helm install command:

CHART_VERSION=0.9.0
helm install lws oci://registry.k8s.io/lws/charts/lws \
  --version=$CHART_VERSION \
  --namespace lws-system \
  --create-namespace \
  --set enableDisaggregatedSet=true \
  --wait --timeout 300s

Verify Installation

  1. Wait for the controller manager to become available:
kubectl wait deploy/lws-controller-manager -n lws-system \
  --for=condition=available --timeout=5m
  1. Confirm the DisaggregatedSet CRD is registered:
kubectl get crd disaggregatedsets.disaggregatedset.x-k8s.io
  1. (Helm with webhooks enabled) Confirm the validating webhook configuration:
kubectl get validatingwebhookconfiguration lws-validating-webhook-configuration \
  -o yaml | grep disaggregatedsets

Upgrade from an older version

Helm does not automatically install newly added CRDs during helm upgrade. If you are upgrading from a version older than v0.9.0, manually apply the CRD first:

kubectl apply --server-side \
  -f https://raw.githubusercontent.com/kubernetes-sigs/lws/main/charts/lws/crds/disaggregatedset.x-k8s.io_disaggregatedsets.yaml

helm upgrade lws oci://registry.k8s.io/lws/charts/lws \
  --namespace lws-system \
  --set enableDisaggregatedSet=true

Feedback

Was this page helpful?