feat(hosts/k8s): kubevirt - set cpu-manager's policy to static

This commit is contained in:
Ryan Yin
2024-04-01 22:17:05 +08:00
parent 34e7e9b2cd
commit 4775cc2742
2 changed files with 13 additions and 3 deletions
+8 -1
View File
@@ -1,5 +1,5 @@
{ {
config, lib,
pkgs, pkgs,
mylib, mylib,
myvars, myvars,
@@ -22,6 +22,13 @@
# use my own domain & kube-vip's virtual IP for the API server # use my own domain & kube-vip's virtual IP for the API server
# so that the API server can always be accessed even if some nodes are down # so that the API server can always be accessed even if some nodes are down
masterHost = "kubevirt-cluster-1.writefor.fun"; masterHost = "kubevirt-cluster-1.writefor.fun";
kubeletExtraArgs = [
"--cpu-manager-policy=static"
# https://kubernetes.io/docs/tasks/administer-cluster/reserve-compute-resources/
# we have to reserve some resources for for system daemons running as pods
# when cpu-manager's static policy is enabled
"--system-reserved=cpu=1,memory=1Gi,ephemeral-storage=2Gi"
];
nodeLabels = [ nodeLabels = [
"node-purpose=kubevirt" "node-purpose=kubevirt"
]; ];
+5 -2
View File
@@ -10,11 +10,13 @@
# this can be a domain name or an IP address(such as kube-vip's virtual IP) # this can be a domain name or an IP address(such as kube-vip's virtual IP)
masterHost, masterHost,
clusterInit ? false, clusterInit ? false,
kubeletExtraArgs ? [],
nodeLabels ? [], nodeLabels ? [],
nodeTaints ? [], nodeTaints ? [],
disableFlannel ? true, disableFlannel ? true,
... ...
}: let }: let
lib = pkgs.lib;
package = pkgs.k3s_1_29; package = pkgs.k3s_1_29;
in { in {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
@@ -59,9 +61,10 @@ in {
] ]
++ (map (label: "--node-label=${label}") nodeLabels) ++ (map (label: "--node-label=${label}") nodeLabels)
++ (map (taint: "--node-taint=${taint}") nodeTaints) ++ (map (taint: "--node-taint=${taint}") nodeTaints)
++ (pkgs.lib.optionals disableFlannel ["--flannel-backend=none"]); ++ (map (arg: "--kubelet-arg=${arg}") kubeletExtraArgs)
++ (lib.optionals disableFlannel ["--flannel-backend=none"]);
in in
pkgs.lib.concatStringsSep " " flagList; lib.concatStringsSep " " flagList;
}; };
# create symlinks to link k3s's cni directory to the one used by almost all CNI plugins # create symlinks to link k3s's cni directory to the one used by almost all CNI plugins