Add service account.

This commit is contained in:
Tom Alexander
2025-12-14 13:37:46 -05:00
parent 41f9847262
commit 51feef1582
7 changed files with 83 additions and 3 deletions

View File

@@ -8,5 +8,6 @@ symlinkJoin {
paths = [
k8s.kubernetes
k8s.ca
k8s.service_account
];
}

View File

@@ -16,7 +16,7 @@
...
}:
stdenv.mkDerivation (finalAttrs: {
name = "k8s-keys";
name = "k8s-kubernetes";
nativeBuildInputs = [ cfssl ];
buildInputs = [ ];

View File

@@ -0,0 +1,13 @@
{
"signing": {
"default": {
"expiry": "8760h"
},
"profiles": {
"kubernetes": {
"usages": ["signing", "key encipherment", "server auth", "client auth"],
"expiry": "8760h"
}
}
}
}

View File

@@ -0,0 +1,16 @@
{
"CN": "service-accounts",
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "US",
"L": "Portland",
"O": "Kubernetes",
"OU": "Kubernetes The Hard Way",
"ST": "Oregon"
}
]
}

View File

@@ -0,0 +1,35 @@
# unpackPhase
# patchPhase
# configurePhase
# buildPhase
# checkPhase
# installPhase
# fixupPhase
# installCheckPhase
# distPhase
{
stdenv,
sqlite,
cfssl,
k8s,
all_hostnames,
...
}:
stdenv.mkDerivation (finalAttrs: {
name = "k8s-service-account";
nativeBuildInputs = [ cfssl ];
buildInputs = [ ];
unpackPhase = "true";
installPhase = ''
mkdir -p "$out"
cd "$out"
cfssl gencert \
-ca=${k8s.ca}/ca.pem \
-ca-key=${k8s.ca}/ca-key.pem \
-config=${./files/ca-config.json} \
-profile=kubernetes \
${./files/service-account-csr.json} | cfssljson -bare service-account
'';
})