Skip to content

Commit 7350a3e

Browse files
last commit
1 parent 5b1916a commit 7350a3e

File tree

8 files changed

+74
-8
lines changed

8 files changed

+74
-8
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
# simple-python-scheduler
2+
3+
# Deploymet: #
4+
```
5+
cd deployment/simple-python-scheduler
6+
helm upgrade --install --namespace NAMSPACE_NAME --create-namespace simple-python-scheduler . -f values.yaml
7+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: simple-python-scheduler
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.16.0"

deployment/simple-python-scheduler-deployment.yaml renamed to deployment/simple-python-scheduler/templates/deployment.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: simple-python-scheduler
5+
namespace: {{ .Release.Namespace }}
56
spec:
67
replicas: 1
78
selector:
@@ -14,4 +15,7 @@ spec:
1415
spec:
1516
containers:
1617
- name: simple-python-scheduler
17-
image: simple-python-scheduler:latest
18+
image: {{ .Values.image }}
19+
env:
20+
- name: NAMESPACE
21+
value: {{ .Values.monitoredNamespace }}

deployment/rbac.yml renamed to deployment/simple-python-scheduler/templates/rbac.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ metadata:
1818
subjects:
1919
- kind: ServiceAccount
2020
name: default
21-
namespace: simple-python-scheduler
21+
namespace: {{ .Release.Namespace }}
2222
roleRef:
2323
kind: ClusterRole
2424
name: simple-python-scheduler
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Default values for simple-python-scheduler.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
5+
replicaCount: 1
6+
7+
image: ghcr.io/dotanalon/simple-python-scheduler:latest
8+
monitoredNamespace: test-ns

src/main.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22

3-
from os import name
3+
from nt import environ
4+
import os
45
import time
56
import random
67
import json
@@ -12,7 +13,7 @@
1213
batch1 = client.BatchV1Api()
1314

1415
scheduler_name = "simple-python-scheduler"
15-
NAMESPACE = "test-ns"
16+
NAMESPACE = os.environ.get("NAMESPACE", "test-ns")
1617

1718

1819
def nodes_available():
@@ -47,14 +48,14 @@ def preemption(priority):
4748

4849

4950
def get_free_slots(priority):
50-
slots = 0
51+
slots = len(nodes_available())
5152
for pod in get_running_pods():
5253
try:
5354
pod_priority = pod.metadata.annotations["priority"]
5455
except:
55-
slots += 1
56+
pass
5657
if int(pod_priority) < int(priority):
57-
slots += 1
58+
slots -= 1
5859
return slots
5960

6061

src/resources/example-job.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ spec:
1515
image: perl:5.34.0
1616
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
1717
restartPolicy: Never
18-
parallelism: 4
18+
parallelism: 3
1919
backoffLimit: 4

0 commit comments

Comments
 (0)