Skip to content

Commit 07472e5

Browse files
committed
Rename to Another Autoscaler
1 parent b203e1b commit 07472e5

File tree

5 files changed

+48
-50
lines changed

5 files changed

+48
-50
lines changed

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ FROM python:3.9.5-alpine3.13
22

33
ENV PYTHONUNBUFFERED=0
44

5-
#RUN apk --no-cache add build-base openldap-dev libffi-dev
65
COPY files/requirements.txt /tmp/requirements.txt
76
RUN pip install -r /tmp/requirements.txt --no-cache-dir
87

98
# Run as non-root
10-
ENV USER scheduler
9+
ENV USER autoscaler
1110
ENV UID 10001
12-
ENV GROUP scheduler
11+
ENV GROUP autoscaler
1312
ENV GID 10001
1413
ENV HOME /home/$USER
1514
RUN addgroup -g $GID -S $GROUP && adduser -u $UID -S $USER -G $GROUP
@@ -18,7 +17,6 @@ RUN addgroup -g $GID -S $GROUP && adduser -u $UID -S $USER -G $GROUP
1817
COPY files/* $HOME/
1918
RUN chown -R $USER:$GROUP $HOME
2019

21-
#EXPOSE 9000
2220
USER $UID:$GID
2321
WORKDIR $HOME
2422
CMD ["python3", "-u", "main.py"]

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Another Scheduler
2-
Another Scheduler is a Kubernetes controller that automatically starts, stops, or restarts pods from a deployment at a specified time using a cron syntax.
1+
# Another Autoscaler
2+
Another Autoscaler is a Kubernetes controller that automatically starts, stops, or restarts pods from a deployment at a specified time using a cron syntax.
33

4-
Another Scheduler read the annotation of each deployment and performs an increase or decrease in the number of replicas.
4+
Another Autoscaler read the annotation of each deployment and performs an increase or decrease in the number of replicas.
55

6-
[![Docker image](https://img.shields.io/badge/Docker-image-blue.svg)](https://hub.docker.com/r/dignajar/another-scheduler)
7-
[![Kubernetes YAML manifests](https://img.shields.io/badge/Kubernetes-manifests-blue.svg)](https://github.com/dignajar/another-scheduler/tree/master/kubernetes)
8-
[![codebeat badge](https://codebeat.co/badges/f57de995-ca62-49e5-b309-82ed60570324)](https://codebeat.co/projects/github-com-dignajar-another-scheduler-master)
9-
[![release](https://img.shields.io/github/v/release/dignajar/another-scheduler.svg)](https://github.com/dignajar/another-scheduler/releases)
10-
[![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/dignajar/another-scheduler/blob/master/LICENSE)
6+
[![Docker image](https://img.shields.io/badge/Docker-image-blue.svg)](https://hub.docker.com/r/dignajar/another-autoscaler)
7+
[![Kubernetes YAML manifests](https://img.shields.io/badge/Kubernetes-manifests-blue.svg)](https://github.com/dignajar/another-autoscaler/tree/master/kubernetes)
8+
[![codebeat badge](https://codebeat.co/badges/f57de995-ca62-49e5-b309-82ed60570324)](https://codebeat.co/projects/github-com-dignajar-another-autoscaler-master)
9+
[![release](https://img.shields.io/github/v/release/dignajar/another-autoscaler.svg)](https://github.com/dignajar/another-autoscaler/releases)
10+
[![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/dignajar/another-autoscaler/blob/master/LICENSE)
1111

1212
> The date and time must be in UTC.
1313
@@ -17,43 +17,43 @@ Another Scheduler read the annotation of each deployment and performs an increas
1717
- Deployments with GPU, stop them after working hours.
1818
- Stop deployments that are not needed on the weekend.
1919
- Save some money in your Kubernetes cluster after working hours or weekends.
20-
- Another Scheduler is a perfect combination with Cluster Autoscaler.
20+
- Another Autoscaler is a perfect combination with Cluster Autoscaler.
2121
## Install
2222
```
23-
# Deploy Another Scheduler into Kubernetes on default namespace
24-
kubectl apply -f https://raw.githubusercontent.com/dignajar/another-scheduler/master/kubernetes/full.yaml
23+
# Deploy Another Autoscaler into Kubernetes on default namespace
24+
kubectl apply -f https://raw.githubusercontent.com/dignajar/another-autoscaler/master/kubernetes/full.yaml
2525
```
2626
## Annotations
2727
Stop pods at 6pm every day:
2828
```
29-
another-scheduler.io/stop-time: "00 18 * * *"
29+
another-autoscaler.io/stop-time: "00 18 * * *"
3030
```
3131

3232
Start pods at 1pm every day:
3333
```
34-
another-scheduler.io/start-time: "00 13 * * *"
34+
another-autoscaler.io/start-time: "00 13 * * *"
3535
```
3636

3737
Start 3 pods at 2:30pm every day:
3838
```
39-
another-scheduler.io/start-time: "30 14 * * *"
40-
another-scheduler.io/start-replicas: "3"
39+
another-autoscaler.io/start-time: "30 14 * * *"
40+
another-autoscaler.io/start-replicas: "3"
4141
```
4242

4343
Restart pods at 9:15am every day:
4444
```
45-
another-scheduler.io/restart-time: "15 09 * * *"
45+
another-autoscaler.io/restart-time: "15 09 * * *"
4646
```
4747

4848
Restart pods at 2:30am, only on Saturday and Sunday:
4949
```
50-
another-scheduler.io/restart-time: "00 02 * * 0,6"
50+
another-autoscaler.io/restart-time: "00 02 * * 0,6"
5151
```
5252

5353
## Example: How to start pods at 2pm and stop them at 3pm every day
5454
The following example start `5` replicas in total at `2pm` and stop `4` of them at `3pm` every day, the deployment start with `0` replicas.
5555

56-
The `start-replicas` is not incremental, the value is the number of replicas will be setup by Another Scheduler at the defined time by `start-time`.
56+
The `start-replicas` is not incremental, the value is the number of replicas will be setup by Another Autoscaler at the defined time by `start-time`.
5757

5858
> The date and time must be in UTC.
5959
@@ -65,10 +65,10 @@ metadata:
6565
labels:
6666
app: nginx
6767
annotations:
68-
another-scheduler.io/start-time: "00 14 * * *"
69-
another-scheduler.io/start-replicas: "5"
70-
another-scheduler.io/stop-time: "00 15 * * *"
71-
another-scheduler.io/stop-replicas: "1"
68+
another-autoscaler.io/start-time: "00 14 * * *"
69+
another-autoscaler.io/start-replicas: "5"
70+
another-autoscaler.io/stop-time: "00 15 * * *"
71+
another-autoscaler.io/stop-replicas: "1"
7272
spec:
7373
replicas: 0
7474
selector:
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from logs import Logs
66
from k8s import K8s
77

8-
class AScheduler:
8+
class AAutoscaler:
99

1010
def __init__(self):
1111
self.logs = Logs(self.__class__.__name__)
@@ -33,7 +33,7 @@ def __start__(self, namespace:str, deploy:dict, currentTime:datetime):
3333
deployAnnotations = deploy.metadata.annotations
3434
deployReplicas = deploy.spec.replicas
3535

36-
startAnnotation = 'another-scheduler.io/start-time'
36+
startAnnotation = 'another-autoscaler.io/start-time'
3737
if startAnnotation in deployAnnotations:
3838
self.logs.debug({'message': 'Start time detected.', 'namespace': namespace, 'deployment': deployName})
3939
startTime = deployAnnotations[startAnnotation]
@@ -43,7 +43,7 @@ def __start__(self, namespace:str, deploy:dict, currentTime:datetime):
4343

4444
# start-replicas
4545
startReplicas = 1
46-
startReplicasAnnotation = 'another-scheduler.io/start-replicas'
46+
startReplicasAnnotation = 'another-autoscaler.io/start-replicas'
4747
if startReplicasAnnotation in deployAnnotations:
4848
self.logs.debug({'message': 'Replicas defined by the user for start.', 'namespace': namespace, 'deployment': deployName, 'startReplicas': deployAnnotations[startReplicasAnnotation]})
4949
startReplicas = int(deployAnnotations[startReplicasAnnotation])
@@ -63,7 +63,7 @@ def __stop__(self, namespace:str, deploy:dict, currentTime:datetime):
6363
deployAnnotations = deploy.metadata.annotations
6464
deployReplicas = deploy.spec.replicas
6565

66-
stopAnnotation = 'another-scheduler.io/stop-time'
66+
stopAnnotation = 'another-autoscaler.io/stop-time'
6767
if stopAnnotation in deployAnnotations:
6868
self.logs.debug({'message': 'Stop time detected.', 'namespace': namespace, 'deployment': deployName})
6969
stopTime = deployAnnotations[stopAnnotation]
@@ -73,7 +73,7 @@ def __stop__(self, namespace:str, deploy:dict, currentTime:datetime):
7373

7474
# stop-replicas
7575
stopReplicas = 0
76-
stopReplicasAnnotation = 'another-scheduler.io/stop-replicas'
76+
stopReplicasAnnotation = 'another-autoscaler.io/stop-replicas'
7777
if stopReplicasAnnotation in deployAnnotations:
7878
self.logs.debug({'message': 'Replicas defined by the user for stop.', 'namespace': namespace, 'deployment': deployName, 'stopReplicas': deployAnnotations[stopReplicasAnnotation]})
7979
stopReplicas = int(deployAnnotations[stopReplicasAnnotation])
@@ -92,7 +92,7 @@ def __restart__(self, namespace:str, deploy:dict, currentTime:datetime):
9292
deployName = deploy.metadata.name
9393
deployAnnotations = deploy.metadata.annotations
9494

95-
restartAnnotation = 'another-scheduler.io/restart-time'
95+
restartAnnotation = 'another-autoscaler.io/restart-time'
9696
if restartAnnotation in deployAnnotations:
9797
self.logs.debug({'message': 'Restart time detected.', 'namespace': namespace, 'deployment': deployName})
9898
restartTime = deployAnnotations[restartAnnotation]

files/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import os
22
import schedule
33
import time
4-
from ascheduler import AScheduler
4+
from aautoscaler import AAutoscaler
55

66
checkEvery = 5 # Check annotations every 5 seconds by default
77
if 'CHECK_EVERY' in os.environ:
88
checkEvery = int(os.environ['CHECK_EVERY'])
99

10-
ascheduler = AScheduler()
11-
schedule.every(checkEvery).seconds.do(ascheduler.execute)
10+
aautoscaler = AAutoscaler()
11+
schedule.every(checkEvery).seconds.do(aautoscaler.execute)
1212
while True:
1313
schedule.run_pending()
1414
time.sleep(1)

kubernetes/full.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
apiVersion: v1
33
kind: ServiceAccount
44
metadata:
5-
name: another-scheduler
5+
name: another-autoscaler
66
namespace: default
77

88
---
99
kind: ClusterRole
1010
apiVersion: rbac.authorization.k8s.io/v1
1111
metadata:
12-
name: cr-another-scheduler
12+
name: another-autoscaler
1313
rules:
1414
- apiGroups: [""]
1515
resources: ["namespaces"]
@@ -20,23 +20,23 @@ rules:
2020

2121
---
2222
kind: ClusterRoleBinding
23-
apiVersion: rbac.authorization.k8s.io/v1beta1
23+
apiVersion: rbac.authorization.k8s.io/v1
2424
metadata:
25-
name: crb-another-scheduler
25+
name: another-autoscaler
2626
roleRef:
2727
kind: ClusterRole
28-
name: cr-another-scheduler
28+
name: another-autoscaler
2929
apiGroup: rbac.authorization.k8s.io
3030
subjects:
3131
- kind: ServiceAccount
32-
name: another-scheduler
32+
name: another-autoscaler
3333
namespace: default
3434

3535
---
3636
apiVersion: v1
3737
kind: ConfigMap
3838
metadata:
39-
name: another-scheduler
39+
name: another-autoscaler
4040
namespace: default
4141
data:
4242
LOG_LEVEL: "DEBUG"
@@ -47,28 +47,28 @@ data:
4747
apiVersion: apps/v1
4848
kind: Deployment
4949
metadata:
50-
name: another-scheduler
50+
name: another-autoscaler
5151
namespace: default
5252
labels:
53-
app: another-scheduler
53+
app: another-autoscaler
5454
spec:
5555
replicas: 1
5656
selector:
5757
matchLabels:
58-
app: another-scheduler
58+
app: another-autoscaler
5959
template:
6060
metadata:
6161
labels:
62-
app: another-scheduler
62+
app: another-autoscaler
6363
spec:
64-
serviceAccountName: another-scheduler
64+
serviceAccountName: another-autoscaler
6565
containers:
66-
- name: another-scheduler
67-
image: dignajar/another-scheduler:latest # Change the tag for the latest stable version
66+
- name: another-autoscaler
67+
image: dignajar/another-autoscaler:latest # Change the tag for the latest stable version
6868
imagePullPolicy: Always
6969
envFrom:
7070
- configMapRef:
71-
name: another-scheduler
71+
name: another-autoscaler
7272
securityContext:
7373
runAsNonRoot: true
7474
allowPrivilegeEscalation: false

0 commit comments

Comments
 (0)