samba
by alekc
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, withmin protocol = SMB2so the Apple extensions are actually negotiated. - Secrets stay out of the ConfigMap. Put
"${VAR}"in a user's password and supply it throughenv.fullwith asecretKeyRef. 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.jsonrejects typos, unknown keys, malformed file modes and mutable image tags before anything reaches the cluster. - Defaults that work for a file server.
Recreaterather thanRollingUpdate, because a single replica holding aReadWriteOncevolume cannot be replaced in place. Both SMB ports are exposed. AstartupProbecovers 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:
appVersion | the samba release, currently 4.22.10 |
image.tag | the 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:
| Value | Was | Now | Why |
|---|---|---|---|
deployment.strategy.type | RollingUpdate | Recreate | RollingUpdate deadlocks on a ReadWriteOnce volume |
image.tag | pr-2 | v1.1.0, and now required | the old default was a mutable pre-release build from a closed PR |
image.pullPolicy | Always | IfNotPresent | the 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
| Name | Url | |
|---|---|---|
| alekc | [email protected] | https://blog.alekc.org |
Source Code
Requirements
Kubernetes: >=1.23.0-0
Values
| Key | Type | Default | Description |
|---|---|---|---|
| additionalManifests | object | {} | 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. |
| affinity | object | {} | Affinity rules applied to the pod. |
| annotations.config | object | {} | ConfigMap's annotations |
| annotations.deployment | object | {} | Deployment's annotations |
| commonAnnotations | object | {} | Annotations merged onto every resource this chart renders, in addition to each resource's own dedicated annotations field below. |
| commonLabels | object | {} | Labels merged onto every resource this chart renders. Never reaches selector/matchLabels, safe to change without forcing a Deployment recreate. |
| config.global.eaSupport | string | "yes" | Apple extensions require support for extended attributes (xattr). Defaults to yes in Samba 4.9+. |
| config.global.extra | list | [] | Any further global options appended after the settings above. |
| config.global.fruits | list | ["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.minProtocol | string | "SMB2" | Apple extensions ("AAPL") run under SMB2/3 protocol, make this the minimum. Defaults to SMB2_2 in Samba 4.11+. |
| config.global.server | string | "Samba Server" | Equivalent of the NT Description field. |
| config.global.vfsObjects | string | "fruit streams_xattr" | Modules to load (order is critical) and enable AAPL extensions. |
| config.global.workgroup | string | "MyGroup" | NT-Domain-Name or Workgroup-Name. |
| config.shares | list | [] | SMB shares. See the README's "A minimal file server" example for the full shape. |
| config.users | list | [] | 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.strategy | object | {"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. |
| env | object | {"full":[],"simple":{}} | environment values |
| env.full | list | [] | full envs, they will be rendered as written here. Useful if you need to use secrets/cm |
| env.simple | object | {} | simple key: val based env vars |
| extraContainers | list | [] | Extra sidecar containers appended to the pod spec, templated with tpl so they can reference .Release.Namespace and friends. |
| fullnameOverride | string | "" | Overrides the chart's fullname, used to name every resource it renders. |
| image.pullPolicy | string | "IfNotPresent" | Image pull policy. |
| image.repository | string | "ghcr.io/alekc/samba-docker" | Container image repository. |
| image.tag | string | "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. |
| imagePullSecrets | list | [] | Image pull secrets, for a private registry mirror. |
| initContainers | list | [] | Extra init containers appended to the pod spec, templated with tpl. |
| nameOverride | string | "" | Overrides the chart's name in the fullname template. |
| networkPolicy.annotations | object | {} | Annotations to add to the NetworkPolicy |
| networkPolicy.enabled | bool | false | Render 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.extraEgress | list | [] | Additional raw egress rules, appended as-is under spec.egress. |
| networkPolicy.extraIngress | list | [] | Additional raw ingress rules, appended as-is under spec.ingress. |
| nodeSelector | object | {} | Node selector applied to the pod. |
| persistence.accessMode | string | "ReadWriteOnce" | Access mode for the created PVC. |
| persistence.additionalMounts | list | [] | if you need any additional volume mounts, you can define them here |
| persistence.additionalVolumes | list | [] | if you need any additional volumes, you can define them here |
| persistence.annotations | object | {} | Annotations to add to the PersistentVolumeClaim |
| persistence.enabled | bool | false | Render a PersistentVolumeClaim and mount it at /share. |
| persistence.existingClaim | string | "" | Use an existing PVC instead of creating one. |
| persistence.size | string | "800Mi" | Requested size for the created PVC. |
| persistence.storageClass | string | "" | StorageClass for the created PVC. Empty uses the cluster default. |
| podAnnotations | object | {} | Annotations added to the pod template. |
| podSecurityContext | object | {} | Pod-level securityContext. |
| probes | object | {"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. |
| replicaCount | int | 1 | Pod replica count. Capped at 1: this chart serves a single ReadWriteOnce volume, which cannot be shared across replicas. 0 scales down without uninstalling. |
| resources | object | {} | Container resource requests/limits. |
| securityContext | object | {} | Container-level securityContext. |
| service.annotations | object | {} | Annotations merged onto the Service. |
| service.externalIp | object | {"enabled":false,"ips":[]} | Enables external ip |
| service.externalTrafficPolicy | string | "" | Cluster or Local. Local preserves the client source address, which matters for hosts allow rules and for readable audit logs. |
| service.port | in |
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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartsamba is pinned at v1.1.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- 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