Skip to content

Commit ec676e7

Browse files
committed
feat(k8s/amour): descheduler
1 parent 79ec80a commit ec676e7

17 files changed

+354
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
load("@com_github_tnarg_rules_cue//cue:cue.bzl", "cue_library")
2+
3+
cue_library(
4+
name = "cue_v1alpha2_library",
5+
srcs = [
6+
"register_go_gen.cue",
7+
"types_go_gen.cue",
8+
],
9+
importpath = "sigs.k8s.io/descheduler/pkg/api/v1alpha2",
10+
visibility = ["//visibility:public"],
11+
deps = [
12+
"//cue.mod/gen/k8s.io/apimachinery/pkg/apis/meta/v1:cue_v1_library",
13+
"//cue.mod/gen/k8s.io/apimachinery/pkg/runtime:cue_runtime_library",
14+
],
15+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Code generated by cue get go. DO NOT EDIT.
2+
3+
//cue:generate cue get go sigs.k8s.io/descheduler/pkg/api/v1alpha2
4+
5+
package v1alpha2
6+
7+
#GroupName: "descheduler"
8+
#GroupVersion: "v1alpha2"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Code generated by cue get go. DO NOT EDIT.
2+
3+
//cue:generate cue get go sigs.k8s.io/descheduler/pkg/api/v1alpha2
4+
5+
package v1alpha2
6+
7+
import (
8+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
9+
"k8s.io/apimachinery/pkg/runtime"
10+
)
11+
12+
#DeschedulerPolicy: {
13+
metav1.#TypeMeta
14+
15+
// Profiles
16+
profiles?: [...#DeschedulerProfile] @go(Profiles,[]DeschedulerProfile)
17+
18+
// NodeSelector for a set of nodes to operate over
19+
nodeSelector?: null | string @go(NodeSelector,*string)
20+
21+
// MaxNoOfPodsToEvictPerNode restricts maximum of pods to be evicted per node.
22+
maxNoOfPodsToEvictPerNode?: null | uint @go(MaxNoOfPodsToEvictPerNode,*uint)
23+
24+
// MaxNoOfPodsToEvictPerNamespace restricts maximum of pods to be evicted per namespace.
25+
maxNoOfPodsToEvictPerNamespace?: null | uint @go(MaxNoOfPodsToEvictPerNamespace,*uint)
26+
}
27+
28+
#DeschedulerProfile: {
29+
name: string @go(Name)
30+
pluginConfig: [...#PluginConfig] @go(PluginConfigs,[]PluginConfig)
31+
plugins: #Plugins @go(Plugins)
32+
}
33+
34+
#Plugins: {
35+
presort: #PluginSet @go(PreSort)
36+
sort: #PluginSet @go(Sort)
37+
deschedule: #PluginSet @go(Deschedule)
38+
balance: #PluginSet @go(Balance)
39+
filter: #PluginSet @go(Filter)
40+
preevictionfilter: #PluginSet @go(PreEvictionFilter)
41+
}
42+
43+
#PluginConfig: {
44+
name: string @go(Name)
45+
args: runtime.#RawExtension @go(Args)
46+
}
47+
48+
#PluginSet: {
49+
enabled: [...string] @go(Enabled,[]string)
50+
disabled: [...string] @go(Disabled,[]string)
51+
}

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ require (
1919
k8s.io/client-go v12.0.0+incompatible
2020
k8s.io/kube-aggregator v0.29.1
2121
k8s.io/kubernetes v1.29.1
22+
sigs.k8s.io/descheduler v0.29.0
2223
)
2324

2425
require (

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -3003,6 +3003,8 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0/go.mod h1:VHVDI/
30033003
sigs.k8s.io/controller-runtime v0.2.2/go.mod h1:9dyohw3ZtoXQuV1e766PHUn+cmrRCIcBh6XIMFNMZ+I=
30043004
sigs.k8s.io/controller-runtime v0.16.3 h1:2TuvuokmfXvDUamSx1SuAOO3eTyye+47mJCigwG62c4=
30053005
sigs.k8s.io/controller-runtime v0.16.3/go.mod h1:j7bialYoSn142nv9sCOJmQgDXQXxnroFU4VnX/brVJ0=
3006+
sigs.k8s.io/descheduler v0.29.0 h1:C61QOM1LkJbvkQgnXFoSTr5jjnJ1avEPKWnSIIX6GIA=
3007+
sigs.k8s.io/descheduler v0.29.0/go.mod h1:MHwUysQzb/TdaS4ycwBbDY02SxpUjFKTG95iUQJolZc=
30063008
sigs.k8s.io/gateway-api v0.8.0 h1:isQQ3Jx2qFP7vaA3ls0846F0Amp9Eq14P08xbSwVbQg=
30073009
sigs.k8s.io/gateway-api v0.8.0/go.mod h1:okOnjPNBFbIS/Rw9kAhuIUaIkLhTKEu+ARIuXk2dgaM=
30083010
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=

k8s/amour/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ cue_export(
2727
"//k8s/amour/cert_manager_csi_driver:cue_cert_manager_csi_driver_library",
2828
"//k8s/amour/cilium:cue_cilium_library",
2929
"//k8s/amour/dcgm_exporter:cue_dcgm_exporter_library",
30+
"//k8s/amour/descheduler:cue_descheduler_library",
3031
"//k8s/amour/external_secrets:cue_external_secrets_library",
3132
"//k8s/amour/grafana:cue_grafana_library",
3233
"//k8s/amour/home_assistant:cue_home_assistant_library",

k8s/amour/descheduler/BUILD.bazel

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
load("@com_github_tnarg_rules_cue//cue:cue.bzl", "cue_library")
2+
3+
cue_library(
4+
name = "cue_descheduler_library",
5+
srcs = [
6+
"cluster_role_binding_list.cue",
7+
"cluster_role_list.cue",
8+
"config_map_list.cue",
9+
"cron_job_list.cue",
10+
"list.cue",
11+
"namespace_list.cue",
12+
"service_account_list.cue",
13+
],
14+
importpath = "github.com/uhthomas/automata/k8s/amour/descheduler",
15+
visibility = ["//visibility:public"],
16+
deps = [
17+
"//cue.mod/gen/k8s.io/api/batch/v1:cue_v1_library",
18+
"//cue.mod/gen/k8s.io/api/core/v1:cue_v1_library",
19+
"//cue.mod/gen/k8s.io/api/rbac/v1:cue_v1_library",
20+
"//cue.mod/gen/sigs.k8s.io/descheduler/pkg/api/v1alpha2:cue_v1alpha2_library",
21+
],
22+
)

k8s/amour/descheduler/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Descheduler
2+
3+
[https://github.com/kubernetes-sigs/descheduler](https://github.com/kubernetes-sigs/descheduler)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package descheduler
2+
3+
import rbacv1 "k8s.io/api/rbac/v1"
4+
5+
#ClusterRoleBindingList: rbacv1.#ClusterRoleBindingList & {
6+
apiVersion: "rbac.authorization.k8s.io/v1"
7+
kind: "ClusterRoleBindingList"
8+
items: [...{
9+
apiVersion: "rbac.authorization.k8s.io/v1"
10+
kind: "ClusterRoleBinding"
11+
}]
12+
}
13+
14+
#ClusterRoleBindingList: items: [{
15+
subjects: [{
16+
kind: rbacv1.#ServiceAccountKind
17+
name: #Name
18+
namespace: #Namespace
19+
}]
20+
roleRef: {
21+
apiGroup: rbacv1.#GroupName
22+
kind: "ClusterRole"
23+
name: #Name
24+
}
25+
}]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package descheduler
2+
3+
import (
4+
"k8s.io/api/core/v1"
5+
rbacv1 "k8s.io/api/rbac/v1"
6+
)
7+
8+
#ClusterRoleList: rbacv1.#ClusterRoleList & {
9+
apiVersion: "rbac.authorization.k8s.io/v1"
10+
kind: "ClusterRoleList"
11+
items: [...{
12+
apiVersion: "rbac.authorization.k8s.io/v1"
13+
kind: "ClusterRole"
14+
}]
15+
}
16+
17+
#ClusterRoleList: items: [{
18+
rules: [{
19+
apiGroups: ["events.k8s.io"]
20+
resources: ["events"]
21+
verbs: ["create", "update"]
22+
}, {
23+
apiGroups: [v1.#GroupName]
24+
resources: ["nodes"]
25+
verbs: ["get", "watch", "list"]
26+
}, {
27+
apiGroups: [v1.#GroupName]
28+
resources: ["namespaces"]
29+
verbs: ["get", "watch", "list"]
30+
}, {
31+
apiGroups: [v1.#GroupName]
32+
resources: ["pods"]
33+
verbs: ["get", "watch", "list", "delete"]
34+
}, {
35+
apiGroups: [v1.#GroupName]
36+
resources: ["pods/eviction"]
37+
verbs: ["create"]
38+
}, {
39+
apiGroups: ["scheduling.k8s.io"]
40+
resources: ["priorityclasses"]
41+
verbs: ["get", "watch", "list"]
42+
}, {
43+
apiGroups: ["coordination.k8s.io"]
44+
resources: ["leases"]
45+
verbs: ["create"]
46+
}, {
47+
apiGroups: ["coordination.k8s.io"]
48+
resources: ["leases"]
49+
resourceNames: ["descheduler"]
50+
verbs: ["get", "patch", "delete"]
51+
}]
52+
}]
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package descheduler
2+
3+
import (
4+
"encoding/yaml"
5+
6+
"k8s.io/api/core/v1"
7+
deschedulerv1alpha2 "sigs.k8s.io/descheduler/pkg/api/v1alpha2"
8+
)
9+
10+
#ConfigMapList: v1.#ConfigMapList & {
11+
apiVersion: "v1"
12+
kind: "ConfigMapList"
13+
items: [...{
14+
apiVersion: "v1"
15+
kind: "ConfigMap"
16+
}]
17+
}
18+
19+
#ConfigMapList: items: [{
20+
data: "policy.yaml": yaml.Marshal(deschedulerv1alpha2.#DeschedulerPolicy & {
21+
apiVersion: "descheduler/v1alpha2"
22+
kind: "DeschedulerPolicy"
23+
profiles: [{
24+
name: "Main"
25+
plugins: deschedule: enabled: ["RemoveFailedPods"]
26+
}]
27+
})
28+
}]
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package descheduler
2+
3+
import (
4+
"k8s.io/api/core/v1"
5+
batchv1 "k8s.io/api/batch/v1"
6+
)
7+
8+
#CronJobList: batchv1.#CronJobList & {
9+
apiVersion: "batch/v1"
10+
kind: "CronJobList"
11+
items: [...{
12+
apiVersion: "batch/v1"
13+
kind: "CronJob"
14+
}]
15+
}
16+
17+
#CronJobList: items: [{
18+
spec: {
19+
schedule: "*/2 * * * *" // At every second minute.
20+
concurrencyPolicy: batchv1.#ForbidConcurrent
21+
jobTemplate: spec: template: spec: {
22+
volumes: [{
23+
name: "policy"
24+
configMap: name: #Name
25+
}]
26+
containers: [{
27+
name: "descheduler"
28+
image: "registry.k8s.io/descheduler/descheduler:v\(#Version)"
29+
command: ["/bin/descheduler"]
30+
args: [
31+
"--policy-config-file=/var/descheduler/policy.yaml",
32+
"--v=3",
33+
]
34+
ports: [{
35+
name: "https"
36+
containerPort: 10258
37+
}]
38+
resources: limits: {
39+
cpu: "500m"
40+
memory: "256Mi"
41+
}
42+
livenessProbe: {
43+
httpGet: {
44+
path: "/healthz"
45+
port: "https"
46+
scheme: v1.#URISchemeHTTPS
47+
}
48+
initialDelaySeconds: 3
49+
periodSeconds: 10
50+
failureThreshold: 3
51+
}
52+
volumeMounts: [{
53+
name: "policy"
54+
mountPath: "/var/descheduler/policy.yaml"
55+
subPath: "policy.yaml"
56+
}]
57+
imagePullPolicy: v1.#PullIfNotPresent
58+
securityContext: {
59+
capabilities: drop: ["ALL"]
60+
readOnlyRootFilesystem: true
61+
allowPrivilegeEscalation: false
62+
}
63+
}]
64+
restartPolicy: v1.#RestartPolicyNever
65+
serviceAccountName: #Name
66+
securityContext: {
67+
runAsUser: 1000
68+
runAsGroup: 3000
69+
runAsNonRoot: true
70+
fsGroup: 2000
71+
seccompProfile: type: v1.#SeccompProfileTypeRuntimeDefault
72+
}
73+
priorityClassName: "system-cluster-critical"
74+
}
75+
}
76+
}]

k8s/amour/descheduler/list.cue

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package descheduler
2+
3+
import (
4+
"list"
5+
6+
"k8s.io/api/core/v1"
7+
)
8+
9+
#Name: "descheduler"
10+
#Namespace: #Name
11+
12+
// renovate: datasource=github-releases depName=kubernetes-sigs/descheduler extractVersion=^v(?<version>.*)$
13+
#Version: "0.29.0"
14+
15+
#List: v1.#List & {
16+
apiVersion: "v1"
17+
kind: "List"
18+
items: [...{
19+
metadata: {
20+
name: #Name
21+
namespace: #Namespace
22+
labels: {
23+
"app.kubernetes.io/name": #Name
24+
"app.kubernetes.io/version": #Version
25+
}
26+
}
27+
}]
28+
}
29+
30+
#List: items: list.Concat(_items)
31+
32+
_items: [
33+
#ClusterRoleBindingList.items,
34+
#ClusterRoleList.items,
35+
#ConfigMapList.items,
36+
#CronJobList.items,
37+
#NamespaceList.items,
38+
#ServiceAccountList.items,
39+
]
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package descheduler
2+
3+
import "k8s.io/api/core/v1"
4+
5+
#NamespaceList: v1.#NamespaceList & {
6+
apiVersion: "v1"
7+
kind: "NamespaceList"
8+
items: [...{
9+
apiVersion: "v1"
10+
kind: "Namespace"
11+
}]
12+
}
13+
14+
#NamespaceList: items: [{}]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package descheduler
2+
3+
import "k8s.io/api/core/v1"
4+
5+
#ServiceAccountList: v1.#ServiceAccountList & {
6+
apiVersion: "v1"
7+
kind: "ServiceAccountList"
8+
items: [...{
9+
apiVersion: "v1"
10+
kind: "ServiceAccount"
11+
}]
12+
}
13+
14+
#ServiceAccountList: items: [{}]

k8s/amour/list.cue

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/uhthomas/automata/k8s/amour/cert_manager"
88
"github.com/uhthomas/automata/k8s/amour/cilium"
99
"github.com/uhthomas/automata/k8s/amour/dcgm_exporter"
10+
"github.com/uhthomas/automata/k8s/amour/descheduler"
1011
"github.com/uhthomas/automata/k8s/amour/external_secrets"
1112
"github.com/uhthomas/automata/k8s/amour/grafana"
1213
"github.com/uhthomas/automata/k8s/amour/home_assistant"
@@ -64,6 +65,7 @@ _items: [
6465
cert_manager.#List.items,
6566
cilium.#List.items,
6667
dcgm_exporter.#List.items,
68+
descheduler.#List.items,
6769
external_secrets.#List.items,
6870
grafana.#List.items,
6971
home_assistant.#List.items,

0 commit comments

Comments
 (0)