mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-08-27 21:43:57 +02:00
security: restrict k3s kubeconfig file mode to 600
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
{
|
||||
lib,
|
||||
outputs,
|
||||
}:
|
||||
lib.genAttrs (builtins.attrNames outputs.nixosConfigurations) (name: {
|
||||
# Only the control-plane (master) nodes write the admin kubeconfig; agents
|
||||
# (workers) connect to the master and have no --write-kubeconfig-* flags.
|
||||
mode600 = lib.hasInfix "-master-" name;
|
||||
mode644 = false;
|
||||
})
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
lib,
|
||||
outputs,
|
||||
}:
|
||||
lib.genAttrs (builtins.attrNames outputs.nixosConfigurations) (
|
||||
name:
|
||||
let
|
||||
isK3s = lib.hasPrefix "k3s" name;
|
||||
flags = if isK3s then outputs.nixosConfigurations.${name}.config.services.k3s.extraFlags else "";
|
||||
in
|
||||
{
|
||||
mode600 = lib.hasInfix "--write-kubeconfig-mode=600" flags;
|
||||
mode644 = lib.hasInfix "--write-kubeconfig-mode=644" flags;
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user