From 1931bd6c1a1b5eb9d44a96694fdc285edb77770b Mon Sep 17 00:00:00 2001 From: Christian van der Leeden Date: Thu, 1 Aug 2019 11:50:35 +0200 Subject: [PATCH 1/2] created example yaml files out of the readme instructions with a reference to the 0.9.0 docker image. Modified the readme so the make will work since it expects a certain file structure --- README.md | 8 ++++++ examples/descheduler-job.yaml | 28 ++++++++++++++++++++ examples/descheduler.yaml | 50 +++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 examples/descheduler-job.yaml create mode 100644 examples/descheduler.yaml diff --git a/README.md b/README.md index 8898b10d0..4237509b7 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ but relies on the default scheduler for that. ## Build and Run +- Checkout the repo into your $GOPATH directory under src/github.com/kubernetes-incubator/descheduler + Build descheduler: ```sh @@ -38,6 +40,8 @@ and run descheduler: $ ./_output/bin/descheduler --kubeconfig --policy-config-file ``` +If you want more information about what descheduler is doing add `-v 1` to the command line + For more information about available options run: ``` $ ./_output/bin/descheduler --help @@ -155,6 +159,10 @@ the policy `policy-file` is mounted as a volume from the config map. $ kubectl create -f descheduler-job.yaml ``` +### Examples + +See [descheduler.yaml](examples/descheduler.yaml) and [descheduler-job.yaml](examples/descheduler-job.yaml) for a combined yaml file of the above steps. + ## Policy and Strategies Descheduler's policy is configurable and includes strategies to be enabled or disabled. diff --git a/examples/descheduler-job.yaml b/examples/descheduler-job.yaml new file mode 100644 index 000000000..dfd049f62 --- /dev/null +++ b/examples/descheduler-job.yaml @@ -0,0 +1,28 @@ +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: descheduler-job + namespace: kube-system +spec: + parallelism: 1 + completions: 1 + template: + metadata: + name: descheduler-pod + annotations: + scheduler.alpha.kubernetes.io/critical-pod: "" + spec: + containers: + - name: descheduler + image: docker.io/aveshagarwal/descheduler:0.9.0 + volumeMounts: + - mountPath: /policy-dir + name: policy-volume + command: ["/bin/descheduler", "--policy-config-file", "/policy-dir/policy.yaml", "-v", "1"] + restartPolicy: "Never" + serviceAccountName: descheduler-sa + volumes: + - name: policy-volume + configMap: + name: descheduler-policy-configmap \ No newline at end of file diff --git a/examples/descheduler.yaml b/examples/descheduler.yaml new file mode 100644 index 000000000..008937b8b --- /dev/null +++ b/examples/descheduler.yaml @@ -0,0 +1,50 @@ +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: descheduler-cluster-role +rules: + - apiGroups: [""] + resources: ["nodes"] + verbs: ["get", "watch", "list"] + - apiGroups: [""] + resources: ["pods"] + verbs: ["get", "watch", "list", "delete"] + - apiGroups: [""] + resources: ["pods/eviction"] + verbs: ["create"] +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: descheduler-sa + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + name: descheduler-user +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: descheduler-cluster-role +subjects: + - kind: ServiceAccount + name: descheduler-sa + namespace: kube-system +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: descheduler-policy-configmap + namespace: kube-system +data: + policy.yaml: | + apiVersion: "descheduler/v1alpha1" + kind: "DeschedulerPolicy" + strategies: + "RemovePodsViolatingNodeAffinity": + enabled: true + params: + nodeAffinityType: + - "requiredDuringSchedulingIgnoredDuringExecution" From 68a106aed015ee9719fe664d507a72966cd84d67 Mon Sep 17 00:00:00 2001 From: Christian van der Leeden Date: Sat, 3 Aug 2019 11:41:52 +0200 Subject: [PATCH 2/2] changed policy, RemoveDuplicates is not automatically turned on, so used the policy.yaml file from the examples --- examples/descheduler.yaml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/examples/descheduler.yaml b/examples/descheduler.yaml index 008937b8b..3a27cdb46 100644 --- a/examples/descheduler.yaml +++ b/examples/descheduler.yaml @@ -43,8 +43,19 @@ data: apiVersion: "descheduler/v1alpha1" kind: "DeschedulerPolicy" strategies: - "RemovePodsViolatingNodeAffinity": + "RemoveDuplicates": + enabled: true + "RemovePodsViolatingInterPodAntiAffinity": + enabled: true + "LowNodeUtilization": enabled: true params: - nodeAffinityType: - - "requiredDuringSchedulingIgnoredDuringExecution" + nodeResourceUtilizationThresholds: + thresholds: + "cpu" : 20 + "memory": 20 + "pods": 20 + targetThresholds: + "cpu" : 50 + "memory": 50 + "pods": 50 \ No newline at end of file