samba

by alekc

Helm chartv1.1.0App 4.22.10Apache-2.0Verified publisher

SMB file server with Apple Time Machine support, configured from values rather than a hand-written smb.conf

About this chart

samba

SMB file server with Apple Time Machine support, configured from values rather than a hand-written smb.conf

An SMB file server for Kubernetes. You describe shares and users in values.yaml; the container generates smb.conf at startup. There is no config file to mount and no smb.conf syntax to learn for the common cases.

Why this chart

Most SMB charts hand you a ConfigMap and expect you to write smb.conf yourself. This one takes structured values instead, and ships the parts that are easy to get wrong:

  • Time Machine works out of the box. The vfs_fruit options macOS needs (fruit:aapl, readdir_attr:*, fruit:metadata = stream, and the rest) are on by default, with min protocol = SMB2 so the Apple extensions are actually negotiated.
  • Secrets stay out of the ConfigMap. Put "${VAR}" in a user's password and supply it through env.full with a secretKeyRef. The image expands it at startup and fails to start if the variable is missing, rather than storing a literal placeholder as the password.
  • Values are schema validated. values.schema.json rejects typos, unknown keys, malformed file modes and mutable image tags before anything reaches the cluster.
  • Defaults that work for a file server. Recreate rather than RollingUpdate, because a single replica holding a ReadWriteOnce volume cannot be replaced in place. Both SMB ports are exposed. A startupProbe covers config generation so a slow start is not mistaken for a liveness failure.

Versions

appVersion is the samba version the chart deploys, not the container image tag. The image has its own version line, so both are stated separately:

appVersionthe samba release, currently 4.22.10
image.tagthe image release that contains it, currently v1.1.0

image.tag is therefore required and has no default fallback. An empty value would otherwise resolve to the samba version and pull a tag that does not exist; the schema rejects it instead.

Install

From the classic chart repository:

helm repo add alekc-charts https://charts.alekc.dev
helm install my-release alekc-charts/samba -f my-values.yaml

Or directly from the OCI registry, no helm repo add needed:

helm install my-release oci://charts.alekc.dev/samba --version 1.1.0 -f my-values.yaml

Nothing is served until you define at least one share and one user.

Verifying the signature

curl -sO https://charts.alekc.dev/pubring.gpg
helm pull oci://charts.alekc.dev/samba --version 1.1.0 --verify --keyring pubring.gpg

A minimal file server

config:
  global:
    workgroup: WORKGROUP
  users:
    - name: alice
      password: "${ALICE_PASSWORD}"
      id: 1000
  shares:
    - name: documents
      path: /data/documents
      comment: Shared documents
      browseable: "yes"
      writeable: "yes"
      validUsers:
        - alice

env:
  full:
    - name: ALICE_PASSWORD
      valueFrom:
        secretKeyRef:
          name: samba-passwords
          key: alice

persistence:
  enabled: true
  size: 100Gi
  additionalMounts:
    - name: share
      mountPath: /data/documents

A Time Machine target

The structured shares list has no field for vfs_fruit options, so use config.extra_config, which is injected into smb.conf verbatim. Give each Mac its own share: the size cap applies per share, so one shared destination means the machines compete for a single budget.

config:
  extra_config: |
    [tm-laptop]
    comment = Time Machine, laptop
    path = /time-machine/laptop
    fruit:time machine = yes
    fruit:time machine max size = 1T
    read only = no
    browseable = yes
    force user = timemachine
    valid users = tm-laptop

fruit:time machine max size is worth setting. Without it macOS sizes the sparse bundle to the whole volume, and it picks a band size proportional to that, so a large declared size means multi-gigabyte bands and a rewrite of several gigabytes for every small change.

Exposing it on your network

SMB clients do not go through an Ingress. Either publish the Service on an address on your LAN:

service:
  externalIp:
    enabled: true
    ips:
      - 192.168.1.50
  # Keeps the client's real address, which `hosts allow` rules and logs need
  externalTrafficPolicy: Local

or set service.type: LoadBalancer if your cluster has a controller for it.

Storage

persistence.enabled: true creates one PVC and mounts it at /share. For anything more involved, mount volumes you manage yourself and skip the built-in claim:

persistence:
  enabled: false
  additionalVolumes:
    - name: media
      persistentVolumeClaim:
        claimName: my-existing-claim
  additionalMounts:
    - name: media
      mountPath: /media
      subPath: movies

Upgrading to 1.0.0

The autoscaling values and the HorizontalPodAutoscaler template are gone. They emitted autoscaling/v2beta1, removed in Kubernetes 1.25, so the template could not apply on any supported cluster. Horizontal scaling never made sense here anyway, since replicas cannot share one ReadWriteOnce volume. Remove any autoscaling: block from your values; the schema now rejects it.

Three defaults changed. Check whether you were relying on the old behaviour:

ValueWasNowWhy
deployment.strategy.typeRollingUpdateRecreateRollingUpdate deadlocks on a ReadWriteOnce volume
image.tagpr-2v1.1.0, and now requiredthe old default was a mutable pre-release build from a closed PR
image.pullPolicyAlwaysIfNotPresentthe tag is now immutable, so re-pulling every start is wasted

appVersion now reports the samba version (4.22.10) rather than an image version, so it can no longer be used as an image tag. That is why image.tag is required.

The Service now exposes port 445 in addition to 139. If you select ports by name, note that 139 is netbios and 445 is smb.

What this chart deliberately does not have

No HorizontalPodAutoscaler or PodDisruptionBudget: replicaCount is capped at 1 by the schema (a single ReadWriteOnce volume cannot be shared across replicas), so both would either do nothing or actively block node draining. No Ingress or Gateway API HTTPRoute: SMB clients never go through an HTTP router, see "Exposing it on your network" above instead. No ServiceMonitor: samba exposes no Prometheus metrics endpoint. networkPolicy.enabled is available if you want to restrict which pods can reach the netbios/smb ports; it defaults to DNS-only egress, which is enough for a workgroup-based server, add networkPolicy.extraEgress if you join it to an Active Directory domain.

Homepage: https://gitlab.com/alexander-chernov/helm/samba

Maintainers

NameEmailUrl
alekc[email protected]https://blog.alekc.org

Source Code

Requirements

Kubernetes: >=1.23.0-0

Values

KeyTypeDefaultDescription
additionalManifestsobject{}Additional raw Kubernetes manifests to render alongside the chart's own resources. Supports any valid Kubernetes object; values are templated with tpl, so a manifest can reference .Release.Namespace and friends.
affinityobject{}Affinity rules applied to the pod.
annotations.configobject{}ConfigMap's annotations
annotations.deploymentobject{}Deployment's annotations
commonAnnotationsobject{}Annotations merged onto every resource this chart renders, in addition to each resource's own dedicated annotations field below.
commonLabelsobject{}Labels merged onto every resource this chart renders. Never reaches selector/matchLabels, safe to change without forcing a Deployment recreate.
config.global.eaSupportstring"yes"Apple extensions require support for extended attributes (xattr). Defaults to yes in Samba 4.9+.
config.global.extralist[]Any further global options appended after the settings above.
config.global.fruitslist["fruit:aapl = yes","readdir_attr:aapl_rsize = yes","readdir_attr:aapl_finder_info = yes","readdir_attr:aapl_max_access = yes","fruit:metadata = stream","fruit:model = MacSamba","fruit:veto_appledouble = no","fruit:posix_rename = yes","fruit:zero_file_id = yes","fruit:wipe_intentionally_left_blank_rfork = yes","fruit:delete_empty_adfiles = yes"]vfs_fruit options for Apple/Time Machine support. See https://www.samba.org/samba/docs/current/man-html/vfs_fruit.8.html
config.global.minProtocolstring"SMB2"Apple extensions ("AAPL") run under SMB2/3 protocol, make this the minimum. Defaults to SMB2_2 in Samba 4.11+.
config.global.serverstring"Samba Server"Equivalent of the NT Description field.
config.global.vfsObjectsstring"fruit streams_xattr"Modules to load (order is critical) and enable AAPL extensions.
config.global.workgroupstring"MyGroup"NT-Domain-Name or Workgroup-Name.
config.shareslist[]SMB shares. See the README's "A minimal file server" example for the full shape.
config.userslist[]SMB users. Prefer "${VAR}" for password and supply the value via env.full with a secretKeyRef; a literal password here lands in a ConfigMap in plain text.
deployment.strategyobject{"type":"Recreate"}Deployment strategy. Recreate is the default because a single replica holding a ReadWriteOnce volume cannot be replaced by a new pod that needs the same volume: RollingUpdate deadlocks until the old pod is deleted.
envobject{"full":[],"simple":{}}environment values
env.fulllist[]full envs, they will be rendered as written here. Useful if you need to use secrets/cm
env.simpleobject{}simple key: val based env vars
extraContainerslist[]Extra sidecar containers appended to the pod spec, templated with tpl so they can reference .Release.Namespace and friends.
fullnameOverridestring""Overrides the chart's fullname, used to name every resource it renders.
image.pullPolicystring"IfNotPresent"Image pull policy.
image.repositorystring"ghcr.io/alekc/samba-docker"Container image repository.
image.tagstring"v1.1.0"Image tag. Must be set: appVersion reports the samba version, not an image tag, so there is no sane fallback. Avoid mutable tags such as latest or pr-N.
imagePullSecretslist[]Image pull secrets, for a private registry mirror.
initContainerslist[]Extra init containers appended to the pod spec, templated with tpl.
nameOverridestring""Overrides the chart's name in the fullname template.
networkPolicy.annotationsobject{}Annotations to add to the NetworkPolicy
networkPolicy.enabledboolfalseRender a NetworkPolicy restricting ingress to the netbios and smb ports, and egress to DNS plus whatever extraEgress adds. This chart is workgroup-based (no AD domain join), so DNS-only egress is usually sufficient; add extraEgress if you point it at a domain controller.
networkPolicy.extraEgresslist[]Additional raw egress rules, appended as-is under spec.egress.
networkPolicy.extraIngresslist[]Additional raw ingress rules, appended as-is under spec.ingress.
nodeSelectorobject{}Node selector applied to the pod.
persistence.accessModestring"ReadWriteOnce"Access mode for the created PVC.
persistence.additionalMountslist[]if you need any additional volume mounts, you can define them here
persistence.additionalVolumeslist[]if you need any additional volumes, you can define them here
persistence.annotationsobject{}Annotations to add to the PersistentVolumeClaim
persistence.enabledboolfalseRender a PersistentVolumeClaim and mount it at /share.
persistence.existingClaimstring""Use an existing PVC instead of creating one.
persistence.sizestring"800Mi"Requested size for the created PVC.
persistence.storageClassstring""StorageClass for the created PVC. Empty uses the cluster default.
podAnnotationsobject{}Annotations added to the pod template.
podSecurityContextobject{}Pod-level securityContext.
probesobject{"liveness":{"enabled":true,"failureThreshold":3,"periodSeconds":10},"readiness":{"enabled":true,"failureThreshold":3,"periodSeconds":10},"startup":{"enabled":true,"failureThreshold":30,"periodSeconds":2}}Probes all target the SMB port. Config generation runs before smbd starts, so a startupProbe gives that time without a slack liveness period.
replicaCountint1Pod replica count. Capped at 1: this chart serves a single ReadWriteOnce volume, which cannot be shared across replicas. 0 scales down without uninstalling.
resourcesobject{}Container resource requests/limits.
securityContextobject{}Container-level securityContext.
service.annotationsobject{}Annotations merged onto the Service.
service.externalIpobject{"enabled":false,"ips":[]}Enables external ip
service.externalTrafficPolicystring""Cluster or Local. Local preserves the client source address, which matters for hosts allow rules and for readable audit logs.
service.portin

Deploy samba with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has samba 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 chartsamba is pinned at v1.1.0 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