Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add helm docs #67

Open
wants to merge 23 commits into
base: feat/add-docusaurus
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pre_commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
SKIP: "no-commit-to-branch" # if not skipped, will always fail on main
- name: Push changes
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@github.com"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
if git diff-index --quiet HEAD; then
echo "No changes were made"
Expand Down
6 changes: 3 additions & 3 deletions deployments/chart/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.configMapName }}
name: {{ .Values.configMap.name }}
data:
# downscale for non-work hours
EXCLUDE_NAMESPACES: '{{- join "," .Values.excludedNamespaces }}'
{{- if .Values.extraConfig }}
{{- tpl .Values.extraConfig . | nindent 2 }}
{{- if .Values.configMap.extraConfig }}
{{- tpl .Values.configMap.extraConfig . | nindent 2 }}
{{- end }}
18 changes: 9 additions & 9 deletions deployments/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ replicaCount: 1

image:
repository: ghcr.io/caas-team/gokubedownscaler
tag: "" # Dynamically set from CI
tag: "" # Defaults to appVersion

arguments:
# - --interval=60
Expand All @@ -18,6 +18,7 @@ includedResources:
# - scaledobjects
# - stacks
# - poddisruptionbudgets
# - prometheuses

fullnameOverride: ""
nameOverride: ""
Expand Down Expand Up @@ -60,15 +61,14 @@ tolerations: []

affinity: {}

configMapName: go-kube-downscaler

excludedNamespaces:
- kube-downscaler
- kube-system

# Additional config in the configmap.
# Add configmap lines via the multiline Operator |
# e.g.:
# extraConfig: |
# DOWNSCALE_PERIOD: "Mon-Sun 19:00-20:00 Europe/Berlin"
extraConfig: ""
configMap:
name: go-kube-downscaler
# extraConfig adds lines to the configmap
# e.g.:
# extraConfig: |
# DOWNSCALE_PERIOD: "Mon-Sun 19:00-20:00 Europe/Berlin"
extraConfig: ""
50 changes: 50 additions & 0 deletions website/content/_global_md_links.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{/* Repo links */}
[contribution-manifest]: https://github.com/caas-team/GoKubeDownscaler/blob/main/CONTRIBUTING.md "Contribution Manifest"
[deployment-yaml]: https://github.com/caas-team/GoKubeDownscaler/blob/main/deployments/chart/templates/deployment.yaml "Deployment"
[serviceaccount-yaml]: https://github.com/caas-team/GoKubeDownscaler/blob/main/deployments/chart/templates/serviceaccount.yaml "Service Account"
[configmap-yaml]: https://github.com/caas-team/GoKubeDownscaler/blob/main/deployments/chart/templates/configmap.yaml "ConfigMap"
[clusterrole-yaml]: https://github.com/caas-team/GoKubeDownscaler/blob/main/deployments/chart/templates/clusterrole.yaml "Clusterrole"
[role-yaml]: https://github.com/caas-team/GoKubeDownscaler/blob/main/deployments/chart/templates/role.yaml "Role"
[github-releases]: https://github.com/caas-team/GoKubeDownscaler/releases "Github Releases"
[chart-appversion]: https://github.com/caas-team/GoKubeDownscaler/blob/main/deployments/chart/Chart.yaml#L10 "appVersion"

{/* Guides links */}
[guides-developing]: /GoKubeDownscaler/guides/developing "Developing Guide"

{/* Documentation links */}
[docs-helm-chart]: /GoKubeDownscaler/docs/helm-chart "Helm Chart Docs"
[docs-helm-values]: /GoKubeDownscaler/docs/helm-chart/Values "Helm Chart Values"
[docs-helm-components]: /GoKubeDownscaler/docs/helm-chart/components "Helm Components"
[docs-helm-permissions]: /GoKubeDownscaler/docs/helm-chart/permissions "Permissions"
{/* TODO */}
[docs-arguments]: /GoKubeDownscaler/docs/ "arguments"

{/* Helm Value links */}
[replicaCount]: /GoKubeDownscaler/docs/helm-chart/Values/replicaCount
[image]: /GoKubeDownscaler/docs/helm-chart/Values/image
[arguments]: /GoKubeDownscaler/docs/helm-chart/Values/arguments
[includedResources]: /GoKubeDownscaler/docs/helm-chart/Values/includedResources
[fullnameOverride]: /GoKubeDownscaler/docs/helm-chart/Values/fullnameOverride
[nameOverride]: /GoKubeDownscaler/docs/helm-chart/Values/nameOverride
[constrainedDownscaler]: /GoKubeDownscaler/docs/helm-chart/Values/constrainedDownscaler
[constrainedNamespaces]: /GoKubeDownscaler/docs/helm-chart/Values/constrainedNamespaces
[serviceAccount]: /GoKubeDownscaler/docs/helm-chart/Values/serviceAccount
[podSecurityContext]: /GoKubeDownscaler/docs/helm-chart/Values/podSecurityContext
[securityContext]: /GoKubeDownscaler/docs/helm-chart/Values/securityContext
[resources]: /GoKubeDownscaler/docs/helm-chart/Values/resources
[nodeSelector]: /GoKubeDownscaler/docs/helm-chart/Values/nodeSelector
[tolerations]: /GoKubeDownscaler/docs/helm-chart/Values/tolerations
[affinity]: /GoKubeDownscaler/docs/helm-chart/Values/affinity
[excludedNamespaces]: /GoKubeDownscaler/docs/helm-chart/Values/excludedNamespaces
[configMap]: /GoKubeDownscaler/docs/helm-chart/Values/configMap

{/* External links */}
[docusaurus]: https://docusaurus.io "Docusaurus"
[brew]: https://brew.sh "Brew"
[pre-commit]: https://pre-commit.com "Pre-Commit"
[pre-commit-install]: https://pre-commit.com/#install "Pre-Commit Installation"
[golangci-lint-install]: https://golangci-lint.run/welcome/install/#local-installation "GolangCi-Lint Installation"
[gofumpt-install]: https://github.com/mvdan/gofumpt "GoFumpt Installation"
[go-install]: https://go.dev/doc/install "Go Installation"
[git-install]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git "Git Installation"
[helm-intro]: https://helm.sh/docs/intro/ "Helm Intro"
28 changes: 28 additions & 0 deletions website/content/docs/helm-chart/0 - Components.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: Components
id: components
---

# Components

The following Kubernetes Objects can be created with our Helm Chart:

## Deployment

The [deployment.yaml][deployment-yaml] file creates the main Deployment of the GoKubeDownscaler with a reference to the provided ServiceAccount and ConfigMap.

## Serviceaccount

The [serviceaccount.yaml][serviceaccount-yaml] file creates a ServiceAccount that will be used by the go-kube-downscaler to interact with Kubernetes.

## Configmap

The [configmap.yaml][configmap-yaml] file creates a new ConfigMap with the provided name. It is used to store environment variables like `EXCLUDE_NAMESPACES`.

## Clusterrole

The [clusterrole.yaml][clusterrole-yaml] file creates a ClusterRole and a ClusterRoleBinding for the desired cluster if [constrainedDownscaler][constrainedDownscaler] is set to false. These allow the actions the GoKubeDownscaler needs to scale down workloads in a clusterwide context.

## Role

The [role.yaml][role-yaml] file creates a Role and a RoleBinding for every namespace listed in [constrainedNamespaces][constrainedNamespaces] if [constrainedDownscaler][constrainedDownscaler] is set to true.
123 changes: 123 additions & 0 deletions website/content/docs/helm-chart/1 - Permissions.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---
title: Permissions
id: permissions
---

# Permissions

The GoKubeDownscaler needs certain permissions to scale workloads.

If [constrainedDownscaler][constrainedDownscaler] is set to true the Helm Chart will create roles for each namespace defined in [constrainedNamespaces][constrainedNamespaces].

Otherwise it will always create a cluster role with the needed permissions.

## Default Permissions

By default the GoKubeDownscaler will always have the following permissions if it is installed via our Helm Chart:

```yaml
- apiGroups:
- ""
resources:
- pods
- namespaces
verbs:
- get
- watch
- list
- apiGroups:
- ""
resources:
- events
verbs:
- get
- create
- watch
- list
- update
- patch
```

These are necessary for the GoKubeDownscaler to work properly.

## Admission Controller Permissions

:::note
If you are using a clusterwide installation of the GoKubeDownscaler it will also have:
:::

```yaml
- apiGroups:
- constraints.gatekeeper.sh
resources:
- kubedownscalerjobsconstraint
verbs:
- get
- create
- watch
- list
- update
- patch
- delete
- apiGroups:
- kyverno.io
resources:
- policies
resourceNames:
- kube-downscaler-jobs-policy
verbs:
- get
- create
- watch
- list
- update
- patch
- delete
- apiGroups:
- kyverno.io
resources:
- policies
verbs:
- get
- create
- watch
- list
- apiGroups:
- templates.gatekeeper.sh
resources:
- constrainttemplate
verbs:
- create
- get
- list
- watch
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- create
- get
- list
- watch
```

{/* TODO Explain why these are added. */}

## Workload Permissions

The Helm Chart assigns get, watch, list, update and patch permissions for the workloads defined in [includedResources][includedResources].

These resources can be:

- Deployments
- Statefulsets
- Daemonsets
- Rollouts
- HorizontalPodAutoscalers
- Jobs
- Cronjobs
- ScaledObjects
- Stacks
- PodDisruptionBudgets
- Prometheuses
23 changes: 23 additions & 0 deletions website/content/docs/helm-chart/Values/0 - replicaCount.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: replicaCount
id: replicaCount
---

# replicaCount

`replicaCount` adjusts the number of replicas that the GoKubeDownscaler deployment will have.

:::info
The default value of `replicaCount` is:

```yaml
replicaCount: 1
```

:::

Changing this to a different integer value will result in the deployment of the provided number of pods.

:::warning
This value should not be changed because multiple instances of the GoKubeDownscaler could lead to errors if they try to scale the same workloads simultaneously.
jonathan-mayer marked this conversation as resolved.
Show resolved Hide resolved
:::
28 changes: 28 additions & 0 deletions website/content/docs/helm-chart/Values/1 - image.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: image
id: image
---

# image

`image` contains the two fields `repository` and `tag`:

- `repository` is the repository URL where the image versions of the GoKubeDownscaler are located.
- `tag` is the version tag of the image.

:::info
The default values for `image` are:

```yaml
image:
repository: ghcr.io/caas-team/gokubedownscaler
tag: ""
```

:::

Changing the value of `repository` will result in the images being pulled from another location. It is advised to leave this as is unless you want or need to pull the images from a private registry of your choice.

Changing the value of `tag` will deploy a different version of the GoKubeDownscaler. If left empty like it is by default the GoKubeDownscaler will use the [appVersion][chart-appversion] of the currently used Helm Chart.

More details to versions of the GoKubeDownscaler can be found [here][github-releases].
jonathan-mayer marked this conversation as resolved.
Show resolved Hide resolved
27 changes: 27 additions & 0 deletions website/content/docs/helm-chart/Values/10 - securityContext.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: securityContext
id: securityContext
---

# securityContext

`securityContext` defines the SecurityContext on container level.

:::info
The default values for `securityContext` are:

```yaml
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
privileged: false
capabilities:
drop:
- ALL
```

:::

In this field you can customize privilege and access control settings for the GoKubeDownscaler container.

More info on all the possible configurations can be found [here](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/).
jonathan-mayer marked this conversation as resolved.
Show resolved Hide resolved
29 changes: 29 additions & 0 deletions website/content/docs/helm-chart/Values/11 - resources.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: resources
id: resources
---

# resources

`resources` defines the CPU and memory limits and requests.

:::info
The default values for `resources` are:

```yaml
resources:
limits:
cpu: 500m
memory: 900Mi
requests:
cpu: 200m
memory: 300Mi
```

:::

Here you can adjust the minimum and maximum amounts of cpu and memory the GoKubeDownscaler Pod is allowed to use.

The requests being the minimum and the limits being the maximum.

You can read more about this [here](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/).
Loading