2 system ? builtins.currentSystem,
4 pkgs ? import ../../.. { inherit system config; },
7 with import ../../lib/testing-python.nix { inherit system pkgs; };
11 mkKubernetesBaseTest =
17 extraConfiguration ? null,
21 filter (machineName: any (role: role == "master") machines.${machineName}.roles) (
25 master = machines.${masterName};
27 ${master.ip} etcd.${domain}
28 ${master.ip} api.${domain}
29 ${concatMapStringsSep "\n" (
30 machineName: "${machines.${machineName}.ip} ${machineName}.${domain}"
31 ) (attrNames machines)}
35 runCommand "wrap-kubectl" { nativeBuildInputs = [ makeWrapper ]; } ''
37 makeWrapper ${pkgs.kubernetes}/bin/kubectl $out/bin/kubectl --set KUBECONFIG "/etc/kubernetes/cluster-admin.kubeconfig"
54 boot.postBootCommands = "rm -fr /var/lib/kubernetes/secrets /tmp/shared/*";
55 virtualisation.memorySize = mkDefault 1536;
56 virtualisation.diskSize = mkDefault 4096;
58 inherit domain extraHosts;
59 primaryIPAddress = mkForce machine.ip;
65 trustedInterfaces = [ "mynet" ];
67 extraCommands = concatMapStrings (node: ''
68 iptables -A INPUT -s ${node.networking.primaryIPAddress} -j ACCEPT
69 '') (attrValues nodes);
72 programs.bash.completion.enable = true;
73 environment.systemPackages = [ wrapKubectl ];
74 services.flannel.iface = "eth1";
75 services.kubernetes = {
76 proxy.hostname = "${masterName}.${domain}";
79 inherit (machine) roles;
82 advertiseAddress = master.ip;
84 # NOTE: what featureGates are useful for testing might change in
85 # the future, see link below to find new ones
86 # https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/
88 AnonymousAuthConfigurableEndpoints = true;
89 ConsistentListFromCache = false;
91 masterAddress = "${masterName}.${config.networking.domain}";
94 (optionalAttrs (any (role: role == "master") machine.roles) {
95 networking.firewall.allowedTCPPorts = [
96 443 # kubernetes apiserver
99 (optionalAttrs (machine ? extraConfiguration) (
100 machine.extraConfiguration {
109 (optionalAttrs (extraConfiguration != null) (extraConfiguration {
127 mkKubernetesMultiNodeTest =
129 mkKubernetesBaseTest (
133 roles = [ "master" ];
144 name = "kubernetes-${attrs.name}-multinode";
148 mkKubernetesSingleNodeTest =
150 mkKubernetesBaseTest (
164 name = "kubernetes-${attrs.name}-singlenode";
169 inherit mkKubernetesBaseTest mkKubernetesSingleNodeTest mkKubernetesMultiNodeTest;