Skip to content

Commit 0c0553b

Browse files
authored
Merge pull request #1 from Fovty/fix/repo-transfer
Fix/repo transfer
2 parents c9b88e8 + aa9f67f commit 0c0553b

27 files changed

+348
-532
lines changed

.github/workflows/docker-build.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Build Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Build Docker image
16+
run: docker build . --file Dockerfile --tag my-image-name:$(git rev-parse --short HEAD)
17+
# Publish to DockerHUB. Necessary?
18+
# - name: Log in to DockerHub
19+
# uses: docker/login-action@v1
20+
# with:
21+
# username: ${{ secrets.DOCKER_USERNAME }}
22+
# password: ${{ secrets.DOCKER_PASSWORD }}
23+
# - name: Push Docker image
24+
# run: docker push my-image-name:$(git rev-parse --short HEAD)

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
Kubernetes Downscaler
22
=====================
33

4-
[![Travis CI Build Status](https://travis-ci.org/hjacobs/kube-downscaler.svg?branch=master)](https://travis-ci.org/hjacobs/kube-downscaler)
5-
[![Code Coverage](https://coveralls.io/repos/github/hjacobs/kube-downscaler/badge.svg?branch=master;_=1)](https://coveralls.io/github/hjacobs/kube-downscaler?branch=master)
4+
This is a fork of [hjacobs/kube-downscaler](https://codeberg.org/hjacobs/kube-downscaler) which is no longer maintained. Here the original text of the kube-downscaler README:
5+
6+
<!-- [![Travis CI Build Status](https://travis-ci.org/hjacobs/kube-downscaler.svg?branch=master)](https://travis-ci.org/hjacobs/kube-downscaler) -->
7+
<!-- [![Code Coverage](https://coveralls.io/repos/github/hjacobs/kube-downscaler/badge.svg?branch=master;_=1)](https://coveralls.io/github/hjacobs/kube-downscaler?branch=master)
68
[![Docker pulls](https://img.shields.io/docker/pulls/hjacobs/kube-downscaler.svg)](https://hub.docker.com/r/hjacobs/kube-downscaler)
7-
[![CalVer](https://img.shields.io/badge/calver-YY.MM.MICRO-22bfda.svg)](http://calver.org/)
9+
[![CalVer](https://img.shields.io/badge/calver-YY.MM.MICRO-22bfda.svg)](http://calver.org/) -->
810

911
Scale down / "pause" Kubernetes workload (`Deployments`, `StatefulSets`, and/or
1012
`HorizontalPodAutoscalers` and `CronJobs` too !) during non-work hours.

chart/.helmignore

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/

chart/Chart.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v2
2+
name: kube-downscaler
3+
description: A Helm chart for deploying kube-downscaler
4+
5+
type: application
6+
version: 0.1.0
7+
appVersion: "23.2.0"

chart/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Kube Downscaler Helm Chart
2+
3+
This repository offers a convenience chart for the `kube-downscaler` [project](https://codeberg.org/hjacobs/kube-downscaler).
4+
5+
## Important values
6+
7+
| Key | Type | Example | Description |
8+
| ------------------ | ------ | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
9+
| image.tag | string | `"23.2.0@sha256:4129e7e7551eb451ee2b43680ef818f3057304ad50888f79ec9722afab6c29ff"` | Tag of the image to use |
10+
| arguments | list | `[--interval=60,--include-resources=deployments,statefulsets,horizontalpodautoscalers,scaledobjects]` | Arguments to pass to the kube-downscaler binary |
11+
| excludedNamespaces | list | `["namespace-a", "namespace-b"]` | Namespaces to exclude from downscaling |
12+
13+
How the downscaler can be configured is described in the [kube-downscaler documentation](https://codeberg.org/hjacobs/kube-downscaler).

chart/templates/_helpers.tpl

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "kube-downscaler.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "kube-downscaler.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "kube-downscaler.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "kube-downscaler.labels" -}}
37+
application: {{ include "kube-downscaler.name" . }}
38+
{{- end }}
39+
40+
{{/*
41+
Selector labels
42+
*/}}
43+
{{- define "kube-downscaler.selectorLabels" -}}
44+
application: {{ include "kube-downscaler.name" . }}
45+
{{- end }}
46+
47+
{{/*
48+
Create the name of the service account to use
49+
*/}}
50+
{{- define "kube-downscaler.serviceAccountName" -}}
51+
{{- if .Values.serviceAccount.create }}
52+
{{- default (include "kube-downscaler.fullname" .) .Values.serviceAccount.name }}
53+
{{- else }}
54+
{{- default "default" .Values.serviceAccount.name }}
55+
{{- end }}
56+
{{- end }}

chart/templates/configmap.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "kube-downscaler.name" . }}
5+
data:
6+
# downscale for non-work hours
7+
EXCLUDE_NAMESPACES: "{{- join ", " .Values.excludedNamespaces }}"

chart/templates/deployment.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
{{- include "kube-downscaler.labels" . | nindent 4 }}
6+
name: {{ include "kube-downscaler.name" . }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "kube-downscaler.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
labels:
17+
{{- include "kube-downscaler.selectorLabels" . | nindent 8 }}
18+
spec:
19+
serviceAccountName: {{ include "kube-downscaler.serviceAccountName" . }}
20+
containers:
21+
- name: {{ .Chart.Name }}
22+
image: {{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}
23+
args:
24+
{{- toYaml .Values.arguments | nindent 8 }}
25+
envFrom:
26+
- configMapRef:
27+
name: {{ .Values.configMapName }}
28+
optional: true
29+
resources:
30+
{{- toYaml .Values.resources | nindent 10 }}
31+
securityContext:
32+
{{- toYaml .Values.securityContext | nindent 10 }}
33+
securityContext:
34+
{{- toYaml .Values.podSecurityContext | nindent 8 }}

chart/templates/rbac.yaml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: {{ include "kube-downscaler.name" . }}
5+
---
6+
apiVersion: rbac.authorization.k8s.io/v1
7+
kind: ClusterRole
8+
metadata:
9+
name: {{ include "kube-downscaler.name" . }}
10+
rules:
11+
- apiGroups:
12+
- ""
13+
resources:
14+
- pods
15+
- namespaces
16+
verbs:
17+
- get
18+
- watch
19+
- list
20+
- apiGroups:
21+
- apps
22+
resources:
23+
- deployments
24+
- statefulsets
25+
verbs:
26+
- get
27+
- watch
28+
- list
29+
- update
30+
- patch
31+
- apiGroups:
32+
- argoproj.io
33+
resources:
34+
- rollouts
35+
verbs:
36+
- get
37+
- watch
38+
- list
39+
- update
40+
- patch
41+
- apiGroups:
42+
- autoscaling
43+
resources:
44+
- horizontalpodautoscalers
45+
verbs:
46+
- get
47+
- watch
48+
- list
49+
- update
50+
- patch
51+
- apiGroups:
52+
- batch
53+
resources:
54+
- cronjobs
55+
verbs:
56+
- get
57+
- watch
58+
- list
59+
- update
60+
- patch
61+
- apiGroups:
62+
- keda.sh
63+
resources:
64+
- scaledobjects
65+
verbs:
66+
- get
67+
- watch
68+
- list
69+
- update
70+
- patch
71+
- apiGroups:
72+
- zalando.org
73+
resources:
74+
- stacks
75+
verbs:
76+
- get
77+
- watch
78+
- list
79+
- update
80+
- patch
81+
- apiGroups:
82+
- ""
83+
resources:
84+
- events
85+
verbs:
86+
- get
87+
- create
88+
- watch
89+
- list
90+
- update
91+
- patch
92+
---
93+
apiVersion: rbac.authorization.k8s.io/v1
94+
kind: ClusterRoleBinding
95+
metadata:
96+
name: {{ include "kube-downscaler.name" . }}
97+
roleRef:
98+
apiGroup: rbac.authorization.k8s.io
99+
kind: ClusterRole
100+
name: {{ include "kube-downscaler.name" . }}
101+
subjects:
102+
- kind: ServiceAccount
103+
name: {{ include "kube-downscaler.name" . }}
104+
namespace: {{ include "kube-downscaler.name" . }}

chart/values.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
replicaCount: 1
2+
3+
image:
4+
# see https://github.com/hjacobs/kube-downscaler/releases
5+
repository: mtr.devops.telekom.de/caas/kube-downscaler
6+
pullPolicy: IfNotPresent
7+
# Overrides the image tag whose default is the chart appVersion.
8+
tag: "23.2.0@sha256:4129e7e7551eb451ee2b43680ef818f3057304ad50888f79ec9722afab6c29ff"
9+
10+
arguments:
11+
- --interval=60
12+
- --include-resources=deployments,statefulsets,horizontalpodautoscalers,scaledobjects
13+
14+
imagePullSecrets: []
15+
nameOverride: ""
16+
fullnameOverride: ""
17+
18+
serviceAccount:
19+
# Specifies whether a service account should be created
20+
create: true
21+
# Annotations to add to the service account
22+
annotations: {}
23+
# The name of the service account to use.
24+
# If not set and create is true, a name is generated using the fullname template
25+
name: ""
26+
27+
podAnnotations: {}
28+
29+
podSecurityContext:
30+
runAsGroup: 1000
31+
runAsNonRoot: true
32+
runAsUser: 1000
33+
fsGroup: 1000
34+
supplementalGroups: [1000]
35+
36+
securityContext:
37+
readOnlyRootFilesystem: true
38+
allowPrivilegeEscalation: false
39+
privileged: false
40+
capabilities:
41+
drop:
42+
- ALL
43+
44+
service:
45+
type: ClusterIP
46+
port: 80
47+
48+
resources:
49+
limits:
50+
cpu: 500m
51+
memory: 900Mi
52+
requests:
53+
cpu: 200m
54+
memory: 300Mi
55+
56+
autoscaling:
57+
enabled: false
58+
minReplicas: 1
59+
maxReplicas: 100
60+
targetCPUUtilizationPercentage: 80
61+
62+
nodeSelector: {}
63+
64+
tolerations: []
65+
66+
affinity: {}
67+
68+
# Used to configure the env
69+
configMapName: kube-downscaler
70+
71+
# Namespaces being excluded from the 'downscale for non-work hours'
72+
# DEFAULT_UPTIME: "Mon-Fri 07:30-20:30 CET"
73+
excludedNamespaces:
74+
- kube-downscaler
75+
- kube-system

0 commit comments

Comments
 (0)