Generic secrets for ssh keys.
This commit is contained in:
parent
df4260a35a
commit
8c70d4e829
@ -27,15 +27,19 @@ let
|
|||||||
echo "Bootstrap finished"
|
echo "Bootstrap finished"
|
||||||
'');
|
'');
|
||||||
manifests = (
|
manifests = (
|
||||||
lib.concatMapStringsSep "," lib.escapeShellArg [
|
lib.concatMapStringsSep "," lib.escapeShellArg (
|
||||||
|
[
|
||||||
./files/manifests/initial_clusterrole.yaml
|
./files/manifests/initial_clusterrole.yaml
|
||||||
./files/manifests/cilium.yaml
|
./files/manifests/cilium.yaml
|
||||||
./files/manifests/coredns.yaml
|
./files/manifests/coredns.yaml
|
||||||
./files/manifests/flux_namespace.yaml
|
./files/manifests/flux_namespace.yaml
|
||||||
./files/manifests/flux.yaml
|
./files/manifests/flux.yaml
|
||||||
./files/manifests/flux_instance.yaml
|
./files/manifests/flux_instance.yaml
|
||||||
"${k8s.k8s-ssh-secrets.kubernetes-deploy-key}/kubernetes-deploy-key.yaml"
|
|
||||||
]
|
]
|
||||||
|
++ (lib.attrsets.mapAttrsToList (
|
||||||
|
secret_name: secret_value: "${secret_value}/${secret_name}.yaml"
|
||||||
|
) k8s.k8s-secrets-generic)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
apply_manifests = "kubectl --kubeconfig=${k8s.client-configs.admin}/admin.kubeconfig apply --server-side --force-conflicts -f ${manifests}";
|
apply_manifests = "kubectl --kubeconfig=${k8s.client-configs.admin}/admin.kubeconfig apply --server-side --force-conflicts -f ${manifests}";
|
||||||
in
|
in
|
||||||
|
|||||||
@ -13,6 +13,5 @@ symlinkJoin {
|
|||||||
++ (builtins.attrValues k8s.client-configs)
|
++ (builtins.attrValues k8s.client-configs)
|
||||||
++ (builtins.attrValues k8s.ssh-keys)
|
++ (builtins.attrValues k8s.ssh-keys)
|
||||||
++ (builtins.attrValues k8s.pgp-keys)
|
++ (builtins.attrValues k8s.pgp-keys)
|
||||||
++ (builtins.attrValues k8s.k8s-ssh-secrets)
|
|
||||||
++ (builtins.attrValues k8s.k8s-secrets-generic);
|
++ (builtins.attrValues k8s.k8s-secrets-generic);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,8 +43,6 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
|
|
||||||
unpackPhase = "true";
|
unpackPhase = "true";
|
||||||
|
|
||||||
# lib.attrsets.mapAttrsToList
|
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir "$out"
|
mkdir "$out"
|
||||||
cp "${yaml_file}" "$out/${secret_name}.yaml"
|
cp "${yaml_file}" "$out/${secret_name}.yaml"
|
||||||
|
|||||||
@ -1,39 +0,0 @@
|
|||||||
# unpackPhase
|
|
||||||
# patchPhase
|
|
||||||
# configurePhase
|
|
||||||
# buildPhase
|
|
||||||
# checkPhase
|
|
||||||
# installPhase
|
|
||||||
# fixupPhase
|
|
||||||
# installCheckPhase
|
|
||||||
# distPhase
|
|
||||||
{
|
|
||||||
stdenv,
|
|
||||||
k8s,
|
|
||||||
kubectl,
|
|
||||||
secret_name,
|
|
||||||
secret_namespace,
|
|
||||||
ssh_key_name,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
|
||||||
name = "k8s-secret-ssh-${secret_name}";
|
|
||||||
nativeBuildInputs = [ kubectl ];
|
|
||||||
buildInputs = [ ];
|
|
||||||
|
|
||||||
unpackPhase = "true";
|
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
kubectl create secret generic ${secret_name} \
|
|
||||||
--namespace ${secret_namespace} \
|
|
||||||
--from-file=identity=${k8s.ssh-keys."${ssh_key_name}"}/${ssh_key_name} \
|
|
||||||
--from-file=identity.pub=${k8s.ssh-keys."${ssh_key_name}"}/${ssh_key_name}.pub \
|
|
||||||
--dry-run=client -o yaml > ${secret_name}.yaml
|
|
||||||
'';
|
|
||||||
# --from-file=known_hosts=$(OUT)/known_hosts \
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir "$out"
|
|
||||||
cp "${secret_name}.yaml" $out/
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
@ -114,21 +114,6 @@ makeScope newScope (
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
k8s-ssh-secrets = (
|
|
||||||
builtins.mapAttrs
|
|
||||||
(
|
|
||||||
secret_name: secret_config:
|
|
||||||
(callPackage ./package/k8s-secret-ssh/package.nix (
|
|
||||||
additional_vars // { inherit secret_name; } // secret_config
|
|
||||||
))
|
|
||||||
)
|
|
||||||
{
|
|
||||||
"kubernetes-deploy-key" = {
|
|
||||||
secret_namespace = "flux-system";
|
|
||||||
ssh_key_name = "flux_ssh_key";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
k8s-secrets-generic = (
|
k8s-secrets-generic = (
|
||||||
builtins.mapAttrs
|
builtins.mapAttrs
|
||||||
(
|
(
|
||||||
@ -144,6 +129,13 @@ makeScope newScope (
|
|||||||
"sops.asc" = (builtins.readFile "${self.pgp-keys.flux_gpg}/flux_gpg_private_key.asc");
|
"sops.asc" = (builtins.readFile "${self.pgp-keys.flux_gpg}/flux_gpg_private_key.asc");
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
"kubernetes-deploy-key" = {
|
||||||
|
secret_namespace = "flux-system";
|
||||||
|
secret_values = {
|
||||||
|
"identity" = builtins.readFile "${self.ssh-keys.flux_ssh_key}/flux_ssh_key";
|
||||||
|
"identity.pub" = builtins.readFile "${self.ssh-keys.flux_ssh_key}/flux_ssh_key.pub";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
client-configs = (
|
client-configs = (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user