Skip to content

K3s

services.k3s.charts

Packaged Helm charts that are linked to {file}/var/lib/rancher/k3s/server/static/charts before k3s starts. The attribute name will be used as the link target (relative to {file}/var/lib/rancher/k3s/server/static/charts). The specified charts will only be placed on the file system and made available to the Kubernetes APIServer from within the cluster, you may use the k3s Helm controller to deploy the charts. This option only makes sense on server nodes (role = server).

Type: attribute set of (path or package)

Default

{ }

Example

nginx = ../charts/my-nginx-chart.tgz;redis = ../charts/my-redis-chart.tgz;

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.clusterInit

Initialize HA cluster using an embedded etcd datastore.

If this option is false and role is server

On a server that was using the default embedded sqlite backend, enabling this option will migrate to an embedded etcd DB.

If an HA cluster using the embedded etcd datastore was already initialized, this option has no effect.

This option only makes sense in a server that is not connecting to another server.

If you are configuring an HA cluster with an embedded etcd, the 1st server must have clusterInit = true and other servers must connect to it using serverAddr.

Type: boolean

Default

false

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.configPath

File path containing the k3s YAML config. This is useful when the config is generated (for example on boot). Type: null or path

Default

null

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.disableAgent

Only run the server. This option only makes sense for a server. Type: boolean

Default

false

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.enable

Whether to enable k3s. Type: boolean

Default

false

Example

true

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.environmentFile

File path containing environment variables for configuring the k3s service in the format of an EnvironmentFile. See systemd.exec(5).

Type: null or path

Default

null

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.extraFlags

Extra flags to pass to the k3s command. Type: string or list of string

Default

[ ]

Example

["--no-deploy traefik""--cluster-cidr 10.24.0.0/16"]

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.images

List of derivations that provide container images. All images are linked to {file}/var/lib/rancher/k3s/agent/images before k3s starts and consequently imported by the k3s agent. This option only makes sense on nodes with an enabled agent.

Type: list of package

Default

[ ]

Example

[(pkgs.dockerTools.pullImage {imageName = "docker.io/bitnami/keycloak";imageDigest = "sha256:714dfadc66a8e3adea6609bda350345bd3711657b7ef3cf2e8015b526bac2d6b";sha256 = "0imblp0kw9vkcr7sp962jmj20fpmb3hvd3hmf4cs4x04klnq3k90";finalImageTag = "21.1.2-debian-11-r0";})]

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.manifests

Auto-deploying manifests that are linked to {file}/var/lib/rancher/k3s/server/manifests before k3s starts. Note that deleting manifest files will not remove or otherwise modify the resources it created. Please use the the --disable flag or .skip files to delete/disable AddOns, as mentioned in the docs. This option only makes sense on server nodes (role = server). Read the auto-deploying manifests docs for further information.

Type: attribute set of (submodule)

Default

{ }

Example

`#!nix deployment.source = ../manifests/deployment.yaml; my-service = { enable = false; target = "app-service.yaml"; content = { apiVersion = "v1"; kind = "Service"; metadata = { name = "app-service"; }; spec = { selector = { "app.kubernetes.io/name" = "MyApp"; }; ports = [ { name = "name-of-service-port"; protocol = "TCP"; port = 80; targetPort = "http-web-svc"; } ]; }; } };

nginx.content = [ { apiVersion = "v1"; kind = "Pod"; metadata = { name = "nginx"; labels = { "app.kubernetes.io/name" = "MyApp"; }; }; spec = { containers = [ { name = "nginx"; image = "nginx:1.14.2"; ports = [ { containerPort = 80; name = "http-web-svc"; } ]; } ]; }; } { apiVersion = "v1"; kind = "Service"; metadata = { name = "nginx-service"; }; spec = { selector = { "app.kubernetes.io/name" = "MyApp"; }; ports = [ { name = "name-of-service-port"; protocol = "TCP"; port = 80; targetPort = "http-web-svc"; } ]; }; } ]; `

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.manifests.<name>.content

Content of the manifest file. A single attribute set will generate a single document YAML file. A list of attribute sets will generate multiple documents separated by --- in a single YAML file.

Type: null or (attribute set) or list of (attribute set)

Default

null

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.manifests.<name>.enable

Whether this manifest file should be generated. Type: boolean

Default

true

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.manifests.<name>.source

Path of the source .yaml file.

Type: path

Example

./manifests/app.yaml

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.manifests.<name>.target

Name of the symlink (relative to {file}/var/lib/rancher/k3s/server/manifests). Defaults to the attribute name.

Type: non-empty string

Example

manifest.yaml

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.package

The k3s package to use. Type: package

Default

pkgs.k3s

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.role

Whether k3s should run as a server or agent.

If it's a server:

  • By default it also runs workloads as an agent.
  • Starts by default as a standalone server using an embedded sqlite datastore.
  • Configure clusterInit = true to switch over to embedded etcd datastore and enable HA mode.
  • Configure serverAddr to join an already-initialized HA cluster.

If it's an agent:

  • serverAddr is required.

Type: one of "server", "agent"

Default

"server"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.serverAddr

The k3s server to connect to.

Servers and agents need to communicate each other. Read the networking docs to know how to configure the firewall.

Type: string

Default

""

Example

"https://10.0.0.10:6443"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.token

The k3s token to use when connecting to a server.

WARNING: This option will expose store your token unencrypted world-readable in the nix store. If this is undesired use the tokenFile option instead.

Type: string

Default

""

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix

services.k3s.tokenFile

File path containing k3s token to use when connecting to the server. Type: null or path

Default

null

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/cluster/k3s/default.nix