Skip to content

Commit

Permalink
release: update manifest and helm charts for v0.1.0 (#39)
Browse files Browse the repository at this point in the history
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
  • Loading branch information
aramase authored Jan 14, 2022
1 parent f9c17fb commit 246c21e
Show file tree
Hide file tree
Showing 11 changed files with 857 additions and 1 deletion.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ A stand alone scheduler that wraps current scheduler and uses [scheduler framewo
The container images for the scheduler plugin is available in the github container registry.

#### Quick Install

```bash
kubectl apply -f https://raw.githubusercontent.com/Azure/placement-policy-scheduler-plugins/main/manifest_staging/deploy/kube-scheduler-configuration.yml
kubectl apply -f https://raw.githubusercontent.com/Azure/placement-policy-scheduler-plugins/main/deploy/kube-scheduler-configuration.yml
```

<details>
Expand Down Expand Up @@ -87,6 +88,20 @@ kind create cluster --config https://raw.githubusercontent.com/Azure/placement-p

>The same node selector `node: want` will be used as node label for `kind-worker` and `kind-worker2`
<details>
<summary>Node labels</summary>

```bash
➜ kubectl get nodes -o=custom-columns="NAME:.metadata.name,LABEL:.metadata.labels['node']"
NAME LABEL
kind-control-plane <none>
kind-worker want
kind-worker2 want
kind-worker3 unwant
```

</details><br/>

- Deploy a `placement policy` CRD

```sh
Expand Down
23 changes: 23 additions & 0 deletions charts/placement-policy-scheduler-plugins/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
7 changes: 7 additions & 0 deletions charts/placement-policy-scheduler-plugins/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: placement-policy-scheduler-plugins
description: A Helm chart for Kubernetes placement policy scheduler plugins
type: application
version: 0.1.0
appVersion: v0.1.0
kubeVersion: "<=1.22.2"
1 change: 1 addition & 0 deletions charts/placement-policy-scheduler-plugins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Chart to run placement policy scheduler plugins as a second scheduler in cluster.
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.7.0
creationTimestamp: null
name: placementpolicies.placement-policy.scheduling.x-k8s.io
spec:
group: placement-policy.scheduling.x-k8s.io
names:
kind: PlacementPolicy
listKind: PlacementPolicyList
plural: placementpolicies
singular: placementpolicy
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: PlacementPolicy is the Schema for the placementpolicies API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: PlacementPolicySpec defines the desired state of PlacementPolicy
properties:
enforcementMode:
description: 'enforcementMode is an enum that specifies how the policy
will be enforced during scheduler (e.g. the application of filter
vs scorer plugin). Values allowed for this field are: BestEffort
(default): the policy will be enforced as best effort (scorer mode).
Strict: the policy will be forced during scheduling. The filter
approach will be used. Note: that may yield pods unschedulable.'
type: string
nodeSelector:
description: nodeSelector selects the nodes where the placement policy
will apply on according to action
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
The requirements are ANDed.
items:
description: A label selector requirement is a selector that
contains values, a key, and an operator that relates the key
and values.
properties:
key:
description: key is the label key that the selector applies
to.
type: string
operator:
description: operator represents a key's relationship to
a set of values. Valid operators are In, NotIn, Exists
and DoesNotExist.
type: string
values:
description: values is an array of string values. If the
operator is In or NotIn, the values array must be non-empty.
If the operator is Exists or DoesNotExist, the values
array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single
{key,value} in the matchLabels map is equivalent to an element
of matchExpressions, whose key field is "key", the operator
is "In", and the values array contains only "value". The requirements
are ANDed.
type: object
type: object
podSelector:
description: podSelector identifies which pods this placement policy
will apply on
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
The requirements are ANDed.
items:
description: A label selector requirement is a selector that
contains values, a key, and an operator that relates the key
and values.
properties:
key:
description: key is the label key that the selector applies
to.
type: string
operator:
description: operator represents a key's relationship to
a set of values. Valid operators are In, NotIn, Exists
and DoesNotExist.
type: string
values:
description: values is an array of string values. If the
operator is In or NotIn, the values array must be non-empty.
If the operator is Exists or DoesNotExist, the values
array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single
{key,value} in the matchLabels map is equivalent to an element
of matchExpressions, whose key field is "key", the operator
is "In", and the values array contains only "value". The requirements
are ANDed.
type: object
type: object
policy:
description: Policy is the policy placement for target based on action
properties:
action:
description: 'The action field is policy placement action. It
is a string enum that carries the following possible values:
Must(default): based on the rule below pods must be placed on
nodes selected by node selector MustNot: based on the rule pods
must *not* be placed nodes selected by node selector'
type: string
targetSize:
anyOf:
- type: integer
- type: string
description: 'TargetSize is the number of pods that can or cannot
be placed on the node. Value can be an absolute number (ex:
5) or a percentage of desired pods (ex: 10%). Absolute number
is calculated from percentage by rounding down.'
x-kubernetes-int-or-string: true
type: object
weight:
description: The policy weight allows the engine to decide which policy
to use when pods match multiple policies. If multiple policies matched
and all share the same weight then a policy with spec.enforcementMode
== Force will be selected. If multiple policies match and +1 policy
is marked as “Force” enforcementMode then they will sorted alphabetically
/ ascending and first one will be used. The scheduler publishes
events capturing this conflict when it happens. Weight == 0-100
is reserved for future use.
format: int32
type: integer
type: object
status:
description: PlacementPolicyStatus defines the observed state of PlacementPolicy
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
63 changes: 63 additions & 0 deletions charts/placement-policy-scheduler-plugins/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "placement-policy-scheduler-plugins.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "placement-policy-scheduler-plugins.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "placement-policy-scheduler-plugins.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "placement-policy-scheduler-plugins.labels" -}}
helm.sh/chart: {{ include "placement-policy-scheduler-plugins.chart" . }}
{{ include "placement-policy-scheduler-plugins.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "placement-policy-scheduler-plugins.selectorLabels" -}}
app.kubernetes.io/name: {{ include "placement-policy-scheduler-plugins.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
component: scheduler
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "placement-policy-scheduler-plugins.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "placement-policy-scheduler-plugins.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/placement-policy-scheduler-plugins/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: pp-scheduler-config
namespace: {{ .Release.Namespace }}
data:
scheduler-config.yaml: |
apiVersion: kubescheduler.config.k8s.io/v1beta1
kind: KubeSchedulerConfiguration
leaderElection:
leaderElect: false
clientConnection:
kubeconfig: /etc/kubernetes/scheduler.conf
profiles:
- schedulerName: placement-policy-plugins-scheduler
plugins:
preScore:
enabled:
- name: placementpolicy
score:
enabled:
- name: placementpolicy
preFilter:
enabled:
- name: placementpolicy
filter:
enabled:
- name: placementpolicy
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pp-plugins-scheduler
namespace: {{ .Release.Namespace }}
labels:
{{- include "placement-policy-scheduler-plugins.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "placement-policy-scheduler-plugins.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "placement-policy-scheduler-plugins.selectorLabels" . | nindent 8 }}
spec:
serviceAccountName: pp-plugins-scheduler
containers:
- command:
- /manager
- --config=/etc/schedulerconfig/scheduler-config.yaml
- --authentication-kubeconfig=/etc/kubernetes/scheduler.conf
- --authorization-kubeconfig=/etc/kubernetes/scheduler.conf
image: {{ .Values.image }}
name: pp-plugins-scheduler
securityContext:
privileged: true
runAsUser: 0
volumeMounts:
- name: scheduler-config
mountPath: /etc/schedulerconfig
readOnly: true
- name: etckubernetes
mountPath: /etc/kubernetes
readOnly: true
hostNetwork: false
hostPID: false
volumes:
- name: scheduler-config
configMap:
name: pp-scheduler-config
- hostPath:
path: /etc/kubernetes/
type: Directory
name: etckubernetes
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
nodeSelector:
node-role.kubernetes.io/master: ""
Loading

0 comments on commit 246c21e

Please sign in to comment.