diff --git a/inventory/sample/group_vars/k8s_cluster/addons.yml b/inventory/sample/group_vars/k8s_cluster/addons.yml index 73e4dfe12b28c232bc71a9e0a6d45d72296449d9..9abf3a79407bcada6c492e7a19cca497591a4b7d 100644 --- a/inventory/sample/group_vars/k8s_cluster/addons.yml +++ b/inventory/sample/group_vars/k8s_cluster/addons.yml @@ -19,6 +19,7 @@ metrics_server_enabled: false # metrics_server_metric_resolution: 15s # metrics_server_kubelet_preferred_address_types: "InternalIP,ExternalIP,Hostname" # metrics_server_host_network: false +# metrics_server_replicas: 1 # Rancher Local Path Provisioner local_path_provisioner_enabled: false diff --git a/roles/kubernetes-apps/metrics_server/defaults/main.yml b/roles/kubernetes-apps/metrics_server/defaults/main.yml index a682b25cbdca07c36fd42997d1337f8642724d2d..4e247a166b9ac0dc08abaa9c452054eac1c421f2 100644 --- a/roles/kubernetes-apps/metrics_server/defaults/main.yml +++ b/roles/kubernetes-apps/metrics_server/defaults/main.yml @@ -8,3 +8,4 @@ metrics_server_limits_memory: 200Mi metrics_server_requests_cpu: 100m metrics_server_requests_memory: 200Mi metrics_server_host_network: false +metrics_server_replicas: 1 \ No newline at end of file diff --git a/roles/kubernetes-apps/metrics_server/templates/metrics-server-deployment.yaml.j2 b/roles/kubernetes-apps/metrics_server/templates/metrics-server-deployment.yaml.j2 index d30b443c19e1b349592d192e54d713e7f8b41ecf..86247b9e144313d7c31dfc8193a2c7c1be283baa 100644 --- a/roles/kubernetes-apps/metrics_server/templates/metrics-server-deployment.yaml.j2 +++ b/roles/kubernetes-apps/metrics_server/templates/metrics-server-deployment.yaml.j2 @@ -9,6 +9,7 @@ metadata: addonmanager.kubernetes.io/mode: Reconcile version: {{ metrics_server_version }} spec: + replicas: {{ metrics_server_replicas }} selector: matchLabels: app.kubernetes.io/name: metrics-server @@ -91,12 +92,16 @@ spec: effect: NoSchedule {% endif %} affinity: - nodeAffinity: + podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 - preference: - matchExpressions: - - key: node-role.kubernetes.io/control-plane - operator: In - values: - - "" + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - metrics-server + topologyKey: kubernetes.io/hostname + namespaces: + - kube-system \ No newline at end of file