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 all 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
105 changes: 10 additions & 95 deletions deployments/chart/README.md
Original file line number Diff line number Diff line change
@@ -1,114 +1,29 @@
# Go Kubernetes Downscaler - Helm Chart

This repository provides a Helm chart for the `go-kube-downscaler`.\
Here you can find a brief overview of the charts components and a quick installation guide.
This is the official Helm Chart for the `GoKubeDownscaler`.

- [Components](#components)
- [Deployment](#deployment)
- [Serviceaccount](#serviceaccount)
- [Configmap](#configmap)
- [Clusterrole](#clusterrole)
- [Role](#role)
- [Values](#values)
- [replicaCount](#replicaCount)
- [image](#image)
- [arguments](#arguments)
- [includedResources](#includedResources)
- [nameOverride](#nameOverride)
- [fullnameOverride](#fullnameOverride)
- [constrainedDownscaler](#constrainedDownscaler)
- [constrainedNamespaces](#constrainedNamespaces)
- [podSecurityContext](#podSecurityContext)
- [securityContext](#securityContext)
- [Installation](#installation)
- [Prerequisits](#prerequisits)
- [Install the Chart](#install-the-chart)
- [Configure scaling for specific Workloads](#configure-scaling-for-specific-workloads)

## Components

### Deployment

The deployment.yaml file creates the main Deployment of the go-kube-downscaler with a reference to the provided ServiceAccount and ConfigMap.

### Serviceaccount

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

### Configmap

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

### Clusterrole

If [constrainedDownscaler](#constrainedDownscaler) is set to false the clusterrole.yaml file creates a ClusterRole and a ClusterRoleBinding which allow the actions the go-kube-downscaler needs to scale down workloads in a clusterwide context.

### Role

If [constrainedDownscaler](#constrainedDownscaler) is set to true the role.yaml file creates a Role and a RoleBinding for every namespace listed in [constrainedNamespaces](#constrainedNamespaces) in order to allow the necessary actions to scale down workloads.

## Values

Here is a brief overview of all the values contained in this chart:

<!-- It's recommended to disable word wrap to view/edit this table -->

| **Key** | **Description** |
| ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="replicaCount">replicaCount</a> | Adjusts the number of replicas that the go-kube-downscaler deployment will have. |
| <a id="image">image</a> | Contains the repository URL and the image tag for the image you want to use. |
| <a id="arguments">arguments</a> | Defines command line arguments for the container. |
| <a id="includedResources">includedResources</a> | Defines all the resources that the go-kube-downscaler is supposed to be able to handle. |
| <a id="fullnameOverride">fullnameOverride</a> | Overrides the full names of the created Kubernetes resources with the provided name if set. |
| <a id="nameOverride">nameOverride</a> | Overrides the chart name for the created Kubernetes resources. |
| <a id="constrainedDownscaler">constrainedDownscaler</a> | Sets the go-kube-downscaler to a constrained state if true, meaning that it does not run clusterwide but restricted to a list of namespaces. These namespaces are listed in [constrainedNamespaces](#constrainedNamespaces). |
| <a id="constrainedNamespaces">constrainedNamespaces</a> | A list of namespaces the go-kube-downscaler is going to operate on when constrained. |
| <a id="serviceAccount">serviceAccount</a> | Specifies whether a new ServiceAccount is supposed to be created and if not, what the name of the ServiceAccount to use is. |
| <a id="podSecurityContext">podSecurityContext</a> | Defines the SecurityContext on pod level. (More info [here](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)) |
| <a id="securityContext">securityContext</a> | Defines the SecurityContext on container level. (More info [here](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)) |
| <a id="resources">resources</a> | Defines the CPU and memory limits and requests. |
| <a id="nodeSelector">nodeSelector</a> | Defines labels of nodes that you want the deployment to schedule them on. |
| <a id="tolerations">tolerations</a> | Adds tolerations to the pods of the deployment to be able to be scheduled on nodes with matching taints. (More info [here](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)) |
| <a id="affinity">affinity</a> | Defines rules for node affinity and pod affinity/anti-affinity. (More info [here](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/)) |
| <a id="configMapName">configMapName</a> | The name of the configmap for the go-kube-downscaler. |
| <a id="excludedNamespaces">excludedNamespaces</a> | A list of namespaces that are supposed to be excluded from the downscaling process of the go-kube-downscaler. |
| <a id="extraConfig">extraConfig</a> | Adds additional specified environment variables to the ConfigMap. |

The default values can be found [here](./values.yaml).
In order to installing the GoKubeDownscaler using our Helm Chart you only need to have Helm installed on a system and have access to a Kubernetes cluster in some kind of way.

## Installation

### Prerequisits

In order to get started installing the go-kube-downscaler using our helm chart you only need to have helm installed on your system and have access to a Kubernetes cluster in some kind of way.

You can find out how to install helm [here](https://helm.sh/docs/intro/install/).
The installation is quite simple.

Also make sure you are on the right cluster and namespace where you want to deploy the go-kube-downscaler.

### Install the chart

There are two ways to install this helm chart:

You can either add our chart repository and deploy it by running:
First you have to add our chart repository by running:

```bash
helm repo add caas-team https://caas-team.github.io/helm-charts/

helm install go-kube-downscaler caas-team/go-kube-downscaler
```

**OR**
This will add all of our published Helm Charts to a local Helm repo named caas-team.

You can alternatively clone this repository, change the current directory to the GoKubeDownscaler repository and run:
After that you just need to run the following command:

```bash
helm install go-kube-downscaler ./deployments/chart
helm install go-kube-downscaler caas-team/go-kube-downscaler
```

**Make sure to adjust the values.yaml as needed or use a custom values.yaml file.**
## Customizing your installation

## Configure scaling for specific Workloads
You can change a lot about your installation of the GoKubeDownscaler.

Now all that is left to do is annotate the workloads you want to scale.
You can find out how to do that [in the main readme](../../README.md#configuration).
You can find information on how to do that on our [documentation page](https://caas-team.github.io/GoKubeDownscaler/).
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: ""
59 changes: 59 additions & 0 deletions website/content/_global_md_links.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{/* 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"
[values-yaml]: https://github.com/caas-team/GoKubeDownscaler/blob/main/deployments/chart/values.yaml "Values File"
[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"
[docs-environment-variables]: /GoKubeDownscaler/docs/ "Environment Variables"
[docs-layer-values]: /GoKubeDownscaler/docs/ "Layer Values"

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

{/* K8s Pages */}
[kubernetes-security-context]: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ "Kubernetes Security Context"
[kubernetes-resource-management]: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ "Kubernetes Resource Management"
[kubernetes-taints-and-tolerations]: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/ "Kubernetes Taints and Tolerations"
[kubernetes-affinity]: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity "Kubernetes Affinity"
28 changes: 28 additions & 0 deletions website/content/docs/0 - 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.
Loading