This feature is available in the vCluster Pro tier. Contact us for more details and to start a trial.
Native sleep mode
Native sleep mode is intended for pre-production use cases only, and comes with some limitations and caveats and should not be enabled on virtual clusters that are using the current sleep mode configuration found in external.platform.
Not all workloads need to run all the time, and scaling them down saves time and money. With vCluster-native sleep mode you can scale down workloads based on a set schedule, or activity from users and ingress.
Enable native sleep mode​
To enable vCluster-native sleep mode, use the following configuration inside your vcluster.yaml
:
experimental:
sleepMode:
enabled: true
autoSleep:
afterInactivity: 1h
How it works​
Sleep mode operations​
Sleep mode performs two main operations:
Sleeping Deletes bare pods and scales down the following resources:
- Deployments
- ReplicaSets
- ReplicationControllers
- DaemonSets
Waking
- Scales resources back to their original state
- Cannot restore previously deleted bare pods
Resource exemption​
Resources can be exempted from sleep mode using either:
- Adding the annotation
sleepmode.loft.sh/exclude: true
- Configuring
sleepMode
with specific labels - Adding configured labels to workloads that should keep running
Detecting activity​
To wake a sleeping cluster or to update the last active time, native sleep mode captures the following:
- Access of cluster resources through API calls (e.g.,
kubectl get <resource>
) - Attempts to contact Ingress endpoints (NGINX only)
Ingress activity detection is only available for NGINX ingress controllers, making use of the mirror-target annotation. This has the effect of overwriting any previously set mirror-target annotation.
Ingress configuration​
Sync to host​
If you install your ingress controllers in the vCluster you'll need to exempt the controller from sleeping so it remains
active for requests that would wake the vCluster. If you install the Ingress
controller in the host cluster, you'll need to
enable syncing ingresses to the host.
sync:
toHost:
ingresses:
enabled: true
Reachability​
For proper ingress activity detection:
- The vCluster pod must be discoverable by the ingress controller
- DNS lookup for
<vcluster-namespace>.<vcluster-svc-name>.svc.cluster.local
must resolve - Proper
dnsPolicy
configuration in the ingress controller Helm installation
Examples​
The below examples demonstrate how to configure sleep mode in a virtual cluster. Please make sure to install the necessary prerequisites before proceeding.
Prerequisites​
-
Administrator access to a Kubernetes cluster: See Accessing Clusters with kubectl for more information. Run the command
kubectl auth can-i create clusterrole -A
to verify that your current kube-context has administrative privileges.infoTo obtain a kube-context with admin access, ensure you have the necessary credentials and permissions for your Kubernetes cluster. This typically involves using
kubectl config
commands or authenticating through your cloud provider's CLI tools. -
helm
: Helm v3.10 is required for deploying the platform. Refer to the Helm Installation Guide if you need to install it. -
kubectl
: Kubernetes command-line tool for interacting with the cluster. See Install and Set Up kubectl for installation instructions.
vCluster
: vCluster command-line tool to provision and manage virtual clusters.- Homebrew
- Mac (Intel/AMD)
- Mac (Silicon/ARM)
- Linux (AMD)
- Linux (ARM)
- Download Binary
- Windows Powershell
brew install loft-sh/tap/vcluster
The binaries in the tap are signed using the Sigstore framework for enhanced security.
curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/latest/download/vcluster-darwin-amd64" && sudo install -c -m 0755 vcluster /usr/local/bin && rm -f vcluster
curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/latest/download/vcluster-darwin-arm64" && sudo install -c -m 0755 vcluster /usr/local/bin && rm -f vcluster
curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/latest/download/vcluster-linux-amd64" && sudo install -c -m 0755 vcluster /usr/local/bin && rm -f vcluster
curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/latest/download/vcluster-linux-arm64" && sudo install -c -m 0755 vcluster /usr/local/bin && rm -f vcluster
Download the binary for your platform from the GitHub Releases page and add this binary to your $PATH.
md -Force "$Env:APPDATA\vcluster"; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12';
Invoke-WebRequest -URI "https://github.com/loft-sh/vcluster/releases/latest/download/vcluster-windows-amd64.exe" -o $Env:APPDATA\vcluster\vcluster.exe;
$env:Path += ";" + $Env:APPDATA + "\vcluster";
[Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::User);Reboot RequiredYou may need to reboot your computer to use the CLI due to changes to the PATH variable (see below).
Check Environment Variable $PATHLine 4 of this install script adds the install directory
%APPDATA%\vcluster
to the$PATH
environment variable. This is only effective for the current Powershell session, i.e. when opening a new terminal window,vcluster
may not be found.Make sure to add the folder
%APPDATA%\vcluster
to thePATH
environment variable after installing vcluster CLI via Powershell. Afterward, a reboot might be necessary.Confirm that you've installed the correct version of the vCluster CLI.
vcluster --version
docker
: Container runtime installation guide.kind
: Kubernetes in Docker installation guide.curl
: Command-line tool for transferring data (pre-installed on most systems, see installation guide if needed)