k3s-fleet

by loafoe

Helm chartv0.1.48App 0.78.3

Fleet API for k3s-on-ec2 clusters - HTTP API (OIDC) and Pulumi job workers, backed by PostgreSQL (CloudNativePG)

About this chart

k3s-fleet

Fleet API for k3s-on-ec2 clusters - HTTP API (OIDC) and Pulumi job workers, backed by PostgreSQL (CloudNativePG)

The fleet API from loafoe/k3s-on-ec2 (docs/FLEET_API.md there): create, update, preview and destroy k3s-on-ec2 clusters and onboard AWS accounts, as asynchronous jobs over HTTP.

  • api (ghcr.io/loafoe/k3s-fleet-api): OIDC-authenticated HTTP API. Never runs Pulumi, needs no AWS access.
  • worker (ghcr.io/loafoe/k3s-fleet-worker): claims jobs from the database and runs them with the pulumi CLI and baked-in provider plugins. Needs AWS credentials (IRSA).
  • database: a CloudNativePG Cluster, or an existing PostgreSQL 13+ via database.existingSecret. Jobs, cluster specs and every stack's Pulumi config live here; pods are stateless.

Prerequisites

  • The CloudNativePG operator (unless database.cnpg.enabled=false).
  • An OIDC issuer for callers (oidc.issuerUrl, oidc.audience). For fleetctl, the CLI (k3s-on-ec2 cmd/fleetctl), the audience is a public client allowed the device code grant: fleetctl login --server <url> reads the issuer and client ID from the API's /auth/config.
  • An IAM role for the workers, bound to <release>-k3s-fleet-worker via IRSA (worker.serviceAccount.annotations), allowed to sts:AssumeRole the per-account k3s-fleet-deployer roles and to use the Pulumi state backend. Set the same role as trustedPrincipal.arn: it is what the deployer roles trust.

Example

oidc:
  issuerUrl: https://login.example.com
  audience: k3s-fleet-api
  adminGroups: [k3s-fleet-admins]
pulumi:
  backendUrl: s3://ops-tools-pulumi-state?region=eu-west-2
  secretsProvider: awskms://alias/pulumi-k3s-fleet?region=eu-west-2
aws:
  region: eu-west-2
trustedPrincipal:
  arn: arn:aws:iam::633162132188:role/k3s-fleet-worker
worker:
  serviceAccount:
    annotations:
      eks.amazonaws.com/role-arn: arn:aws:iam::633162132188:role/k3s-fleet-worker
httpRoute:
  enabled: true
  parentRefs: [{name: platform, namespace: kube-system}]
  hostnames: [fleet.dip-ops-tools-k3s-eu.hsp.philips.com]

Workers get worker.terminationGracePeriodSeconds (31 minutes by default) to finish running jobs on shutdown: interrupting Pulumi mid-update can leave a stack locked.

Values

KeyTypeDefaultDescription
api.affinityobject{}
api.nodeSelectorobject{}
api.podAnnotationsobject{}
api.podDisruptionBudget.enabledbooltrue
api.podDisruptionBudget.minAvailableint1
api.podLabelsobject{}
api.replicasint2API replicas
api.resources.limits.memorystring"256Mi"
api.resources.requests.cpustring"50m"
api.resources.requests.memorystring"64Mi"
api.service.portint80
api.service.typestring"ClusterIP"
api.serviceAccount.annotationsobject{}
api.serviceAccount.createbooltrue
api.serviceAccount.namestring""Defaults to -api
api.tolerationslist[]
aws.regionstring""AWS region for the workers' SDK calls
database.cnpg.enabledbooltrueCreate a CloudNativePG Cluster (the CNPG operator must be installed)
database.cnpg.imageCatalogRefobject{}Use an image catalog instead of imageName, e.g. where a policy enforces one: {apiGroup: postgresql.cnpg.io, kind: ClusterImageCatalog, name: default, major: 18}
database.cnpg.imageNamestring"ghcr.io/cloudnative-pg/postgresql:17"PostgreSQL image (13+)
database.cnpg.instancesint2
database.cnpg.resources.limits.memorystring"1Gi"
database.cnpg.resources.requests.cpustring"100m"
database.cnpg.resources.requests.memorystring"256Mi"
database.cnpg.storage.sizestring"5Gi"
database.cnpg.storage.storageClassstring""Empty uses the default StorageClass
database.existingSecretobject{"key":"uri","name":""}Use an existing database instead (when cnpg.enabled is false): a Secret holding a PostgreSQL URL
fullnameOverridestring""
httpRoute.annotationsobject{}
httpRoute.enabledboolfalseExpose the API through a Gateway API HTTPRoute
httpRoute.hostnameslist[]
httpRoute.parentRefslist[]e.g. [{name: platform, namespace: kube-system}]
image.api.repositorystring"loafoe/k3s-fleet-api"API image
image.api.tagstring""Defaults to the chart appVersion
image.pullPolicystring"IfNotPresent"Image pull policy
image.registrystring"ghcr.io"Registry for both images
image.worker.repositorystring"loafoe/k3s-fleet-worker"Worker image (pulumi CLI + provider plugins)
image.worker.tagstring""Defaults to the chart appVersion
imagePullSecretslist[]Image pull secrets (the ghcr.io images are public)
nameOverridestring""
oidc.adminGroupslist[]Groups granted the admin role (fleet.clusters.create/destroy/secrets, accounts.manage, the sealed admin kubeconfig). Fail-closed with the other two: if all three are empty, every caller is refused.
oidc.allowedConnectorslist[]Dex only: connector IDs the identity must come through (federated_claims.connector_id, federated:id scope). Groups are plain strings, so with several connectors any of them that can produce a required group's name would pass; e.g. [github]. Empty skips the check.
oidc.audiencerequired""Expected token audience ("aud"), typically the client ID
oidc.groupsClaimstring"groups"Claim holding the caller's groups
oidc.issuerUrlrequired""OIDC issuer URL; discovery runs at API start
oidc.operatorGroupslist[]Groups granted the operator role (preview/up, bootstrap, deletion-protection, the public half of kubeconfig, zones checks), plus everything viewerGroups grants.
oidc.viewerGroupslist[]Groups granted the viewer role (read-only).
podSecurityContext.fsGroupint65532
podSecurityContext.runAsGroupint65532
podSecurityContext.runAsNonRootbooltrue
podSecurityContext.runAsUserint65532
podSecurityContext.seccompProfile.typestring"RuntimeDefault"
pulumi.accessTokenSecret.keystring"token"
pulumi.accessTokenSecret.namestring""Secret with a Pulumi Cloud access token (only for the Pulumi Cloud backend)
pulumi.backendUrlstring""State backend, e.g. s3://bucket?region=eu-west-2. Empty means Pulumi Cloud (set accessTokenSecret).
pulumi.secretsProviderstring""Secrets provider for new stacks, e.g. awskms://alias/pulumi-fleet?region=eu-west-2
securityContext.allowPrivilegeEscalationboolfalse
securityContext.capabilities.drop[0]string"ALL"
securityContext.readOnlyRootFilesystembooltrue
trustedPrincipalobject{"arn":"","arnPattern":""}What the per-account k3s-fleet-deployer roles trust: the workers' own AWS identity (their IRSA role) and/or, as an ARN pattern, admins who also run make up (e.g. SSO roles, which IAM Identity Center recreates). Set one or both to allow onboarding.
worker.affinityobject{}
worker.concurrencyint2Jobs per worker pod (each runs a pulumi CLI plus providers: ~1Gi memory per job)
worker.nodeSelectorobject{}
worker.podAnnotationsobject{}
worker.podDisruptionBudget.enabledbooltrue
worker.podDisruptionBudget.maxUnavailableint1Drains evict one worker at a time; each gets shutdownGrace to finish its jobs
worker.podLabelsobject{}
worker.readyTimeoutstring"45m"How long an up waits for the new master to report ready
worker.replicasint1Worker replicas; jobs are spread over them through the database
worker.resources.limits.memorystring"3Gi"
worker.resources.requests.cpustring"250m"
worker.resources.requests.memorystring"1Gi"
worker.serviceAccount.annotationsobject{}Put the IRSA role here: eks.amazonaws.com/role-arn: arn:aws:iam:::role/
worker.serviceAccount.createbooltrue
worker.serviceAccount.namestring""Defaults to -worker
worker.shutdownGracestring"30m"On SIGTERM, how long running jobs may finish before they are interrupted
worker.terminationGracePeriodSecondsint1860Must exceed shutdownGrace, or Kubernetes kills jobs mid-update (stack stays locked)
worker.tmpSizeLimitstring"4Gi"Scratch space for PULUMI_HOME and job work dirs
worker.tolerationslist[]

Autogenerated from chart metadata using helm-docs v1.14.2

Deploy k3s-fleet with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has k3s-fleet on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartk3s-fleet is pinned at v0.1.48 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply