Kubernetes

Running LocalStack on Kubernetes

Introduction

Kubernetes is an open-source container orchestration platform that simplifies the deployment, scaling, and management of containerized applications. LocalStack can be deployed on Kubernetes using the LocalStack Helm chart.

Getting started

To deploy LocalStack in your Kubernetes cluster, you can use Helm.

Prerequisites

  • Kubernetes 1.19+
  • Helm 3.2.0+

Setup a Kubernetes cluster

For setting up Kubernetes refer to the Kubernetes getting started guide.

Install Helm

Helm is a tool for managing Kubernetes charts. Charts are packages of pre-configured Kubernetes resources.

To install Helm, refer to the Helm install guide and ensure that the helm binary is in the PATH of your shell.

Add repository

The following command allows you to download and install all the charts from this repository:

$ helm repo add localstack https://localstack.github.io/helm-charts

Using Helm

After you have installed the Helm client, you can deploy a Helm chart into a Kubernetes cluster.

Please refer to the Quick Start guide if you wish to get running in just a few commands, otherwise the Using Helm guide provides detailed instructions on how to use the Helm client to manage packages on your Kubernetes cluster.

Some useful Helm client commands are:

  • View available charts: helm search repo
  • Install a chart: helm install <name> localstack/<chart>
  • Upgrade your application: helm upgrade
  • Uninstall or delete a release: helm uninstall <name>

LocalStack Pro

You can use this chart with LocalStack Pro by:

  1. Changing the image to localstack/localstack-pro.
  2. Providing your Auth Token as an environment variable.

You can set these values in a YAML file (in this example pro-values.yaml):

image:
  repository: localstack/localstack-pro

extraEnvVars:
  - name: LOCALSTACK_AUTH_TOKEN
    value: "<your auth token>"

If you have the LocalStack Auth Token in a secret, you can also reference it directly with extraEnvVars:

extraEnvVars:
- name: LOCALSTACK_AUTH_TOKEN
  valueFrom:
    secretKeyRef:
      name: <name of the secret>
      key: <name of the key in the secret containing the API key>

And you can use these values when installing the chart in your cluster:

$ helm repo add localstack-charts https://localstack.github.io/helm-charts
$ helm install my-release localstack-charts/localstack -f pro-values.yaml

Parameters

Common parameters

ParameterDescriptionDefault
nameOverrideString to partially override common.names.fullnamenil
fullnameOverrideString to fully override common.names.fullnamenil
extraDeployExtra objects to deploy (value evaluated as a template)[]

Localstack common parameters

ParameterDescriptionDefault
image.repositoryLocalstack image namelocalstack/localstack
image.tagLocalstack image taglatest
image.pullPolicyLocalstack image pull policyIfNotPresent
image.pullSecretsSpecify docker-registry secret names as an array[]
podLabelsAdditional pod labels for Localstack secondary pods{}
podAnnotationsAdditional pod annotations for Localstack secondary pods{}
podSecurityContextEnable security context for Localstack pods{}
extraDeployExtra objects to deploy (value evaluated as a template){}
extraAnnotationsAdd additional annotations to every resource (value evaluated as a template){}
extraLabelsAdd additional labels to every resource (value evaluated as a template){}
securityContextLocalstack container securityContext{}

Localstack parameters

ParameterDescriptionDefault
debugSpecify if debug logs should be enabledfalse
kinesisErrorProbabilitySpecify to randomly inject ProvisionedThroughputExceededException errors into Kinesis API responsesnil (Localstack Default)
startServicesComma-separated list of AWS CLI service names which should be loaded right when starting LocalStack. If not set, each service is loaded and started on the first request for that service.nil (Localstack Default)
lambdaExecutorSpecify Method to use for executing Lambda functions (partially supported)docker
extraEnvVarsExtra environment variables to be set on Localstack primary containersnil (Localstack Default)
enableStartupScriptsMount /etc/localstack/init/ready.d to run startup scripts with {{ template "localstack.fullname" . }}-init-scripts-config configMapfalse
startupScriptContentStartup script content when enableStartupScripts is true. Note: You will need to add a shebang as your first line such as !#/bin/sh in order to ensure the startup script is not malformed.nil (Localstack Default)

Deployment parameters

ParameterDescriptionDefault
replicaCountNumber of Localstack pods1
updateStrategy.typeUpdate strategy typeRollingUpdate
nodeSelectorNode labels for pod assignment{}
tolerationsTolerations for pod assignment[]
affinityAffinity for pod assignment{}
resources.limitsThe resources limits for Localstack containers{}
resources.requestsThe requested resources for Localstack containers{}
livenessProbeLiveness probe configuration for Localstack containersSame with Kubernetes defaults
readinessProbeReadiness probe configuration for Localstack containersSame with Kubernetes defaults
mountDind.enabledSpecify the mount of Docker daemon into Pod to enable some AWS services that got runtime dependencies such as Lambdas on GoLangfalse
mountDind.forceTLSSpecify TLS enforcement on Docker daemon communicationstrue
mountDind.imageSpecify DinD image tagdocker:20.10-dind
volumesExtra volumes to mount[]
volumeMountsExtra volumes to mount[]

RBAC parameters

ParameterDescriptionDefault
serviceAccount.createEnable the creation of a ServiceAccount for Localstack podstrue
serviceAccount.nameName of the created ServiceAccountGenerated using the common.names.fullname template
serviceAccount.annotationsAnnotations for Localstack Service Account{}

Exposure parameters

ParameterDescriptionDefault
service.typeKubernetes Service typeNodePort
service.edgeService.targetPortPort number for Localstack edge service4566
service.externalServicePorts.startStart of the external service port range (included). service4510
service.externalServicePorts.endEnd of the external service port range (excluded). service4560
service.loadBalancerIPloadBalancerIP if Localstack service type is LoadBalancernil
service.dnsServiceExpose the Service and Deployment’s DNS port for TCP and UDP DNS traffic""
service.clusterIPSet a static clusterIP for the service. Useful for DNS delegation to the Localstack Service""
ingress.enabledEnable the use of the ingress controller to access Localstack servicefalse
ingress.annotationsAnnotations for the Localstack Ingress{}
ingress.hosts[0].hostHostname to your Localstack Ingressnil
ingress.hosts[0].pathsPath within the url structure[]
ingress.tlsExisting TLS certificates for ingress[]

Persistence Parameters

NameDescriptionValue
persistence.enabledEnable persistence using Persistent Volume Claimsfalse
persistence.storageClassPersistent Volume storage class""
persistence.accessModesPersistent Volume access modes[]
persistence.sizePersistent Volume size8Gi
persistence.dataSourceCustom PVC data source{}
persistence.existingClaimThe name of an existing PVC to use for persistence""