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

Fix/cleanup-readme #20

Merged
merged 7 commits into from
Apr 24, 2024
Merged
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
67 changes: 28 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Kubernetes Downscaler
Python Kubernetes Downscaler
=====================

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:
This is a fork of [hjacobs/kube-downscaler](https://codeberg.org/hjacobs/kube-downscaler) which is no longer maintained.

<!-- [![Travis CI Build Status](https://travis-ci.org/hjacobs/kube-downscaler.svg?branch=master)](https://travis-ci.org/hjacobs/kube-downscaler) -->
<!-- [![Code Coverage](https://coveralls.io/repos/github/hjacobs/kube-downscaler/badge.svg?branch=master;_=1)](https://coveralls.io/github/hjacobs/kube-downscaler?branch=master)
Expand All @@ -15,22 +15,23 @@ Scale down / "pause" Kubernetes workload (`Deployments`, `StatefulSets`, and/or
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [Concepts](#concepts)
- [Algorithm](#algorithm)
- [Minimum replicas](#minimum-replicas)
- [Specific workload](#specific-workload)
- [Example use cases](#example-use-cases)
- [Usage](#usage)
- [Deployment](#deployment)
- [Example configuration](#example-configuration)
- [Notes](#notes)
- [Configuration](#configuration)
- [Uptime / downtime spec](#uptime--downtime-spec)
- [Alternative logic, based on periods](#alternative-logic-based-on-periods)
- [Command Line Options](#command-line-options)
- [Namespace Defaults](#namespace-defaults)
- [Contributing](#contributing)
- [License](#license)
- [Python Kubernetes Downscaler](#python-kubernetes-downscaler)
- [Concepts](#concepts)
- [Algorithm](#algorithm)
- [Minimum replicas](#minimum-replicas)
- [Specific workload](#specific-workload)
- [Example use cases](#example-use-cases)
- [Usage](#usage)
- [Helm Chart](#helm-chart)
- [Example configuration](#example-configuration)
- [Notes](#notes)
- [Configuration](#configuration)
- [Uptime / downtime spec](#uptime--downtime-spec)
- [Alternative logic, based on periods](#alternative-logic-based-on-periods)
- [Command Line Options](#command-line-options)
- [Namespace Defaults](#namespace-defaults)
- [Contributing](#contributing)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand All @@ -43,7 +44,7 @@ Scale down / "pause" Kubernetes workload (`Deployments`, `StatefulSets`, and/or

### Algorithm

`Kube-downscaler` will scale down the deployment\'s replicas if all of the following
`py-kube-downscaler` will scale down the deployment\'s replicas if all of the following
conditions are met:

- **current time** is not part of the \"uptime\" schedule or is part of the \"downtime\" schedule.
Expand Down Expand Up @@ -122,21 +123,9 @@ were tested to work fine with the downscaler.

## Usage

### Deployment
### Helm Chart

Deploy the downscaler into your cluster via (also works with
[kind](https://kind.sigs.k8s.io/) or
[Minikube](https://github.com/kubernetes/minikube)):

``` {.sourceCode .bash}
$ kubectl apply -f deploy/
```

In case you are deploying `kube-downscaler` to another namespace than
`default`, for example if your context is pointing to `my-namespace`.
Make sure you change the `deploy/rbac.yaml` Service Account
configuration `namespace: default` to the destination namespace
`my-namespace`, instead of `default`.
For detailed information on deploying the `py-kube-downscaler` using our Helm chart, please refer to the [Helm Chart README](./chart/README.md#Deploy-py-kube-downscaler-using-Helm-chart) in the chart directory.


### Example configuration
Expand All @@ -146,7 +135,7 @@ prevent downscaling \-\-- remove it to enable the downscaler, e.g. by
editing the deployment:

``` {.sourceCode .bash}
$ kubectl edit deploy kube-downscaler
$ kubectl edit deploy py-kube-downscaler
```

The example deployment manifests come with a configured uptime
Expand Down Expand Up @@ -186,7 +175,7 @@ with Deployments, consider the following:
during downtime based upon the external traffic as well as maintain
a lower `minReplicas` during downtime if there is no/low traffic. **If
the Deployment is annotated instead of the HPA, it leads to a race
condition** where `kube-downscaler` scales down the Deployment and HPA
condition** where `py-kube-downscaler` scales down the Deployment and HPA
upscales it as its `minReplicas` is higher.

To enable Downscaler on HPA with `--downtime-replicas=1`,
Expand Down Expand Up @@ -276,7 +265,7 @@ Available command line options:

: Restrict the downscaler to work only in a single namespace (default:
all namespaces). This is mainly useful for deployment scenarios
where the deployer of kube-downscaler only has access to a given
where the deployer of py-kube-downscaler only has access to a given
namespace (instead of cluster access). If used simultaneously with
`--exclude-namespaces`, none is applied.

Expand Down Expand Up @@ -329,7 +318,7 @@ Available command line options:
`--exclude-deployments`

: Exclude specific deployments/statefulsets/cronjobs from downscaling
(default: kube-downscaler, downscaler), can also be configured via
(default: py-kube-downscaler, downscaler), can also be configured via
environment variable `EXCLUDE_DEPLOYMENTS`. Despite its name, this
option will match the name of any included resource type
(Deployment, StatefulSet, CronJob, ..).
Expand All @@ -351,10 +340,10 @@ Available command line options:

`--matching-labels`

: Optional: list of workload\'s labels which are covered by the kube-downscaler
: Optional: list of workload\'s labels which are covered by the py-kube-downscaler
scope. All workloads whose labels don't match any in the list are ignored.
For backwards compatibility, if this argument is not specified,
kube-downscaler will apply to all resources.
py-kube-downscaler will apply to all resources.

### Namespace Defaults

Expand Down
92 changes: 88 additions & 4 deletions chart/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,97 @@
# Kube Downscaler Helm Chart
# Python Kubernetes Downscaler - Helm Chart

This repository offers a convenience chart for the `kube-downscaler` [project](https://codeberg.org/hjacobs/kube-downscaler).
This repository offers a Helm chart for the `py-kube-downscaler`.

## Important values

| Key | Type | Example | Description |
| ------------------ | ------ | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
|--------------------|--------|-------------------------------------------------------------------------------------------------------|-------------------------------------------------|
| image.tag | string | `"23.2.0@sha256:4129e7e7551eb451ee2b43680ef818f3057304ad50888f79ec9722afab6c29ff"` | Tag of the image to use |
| arguments | list | `[--interval=60,--include-resources=deployments,statefulsets,horizontalpodautoscalers,scaledobjects]` | Arguments to pass to the kube-downscaler binary |
| excludedNamespaces | list | `["namespace-a", "namespace-b"]` | Namespaces to exclude from downscaling |

How the downscaler can be configured is described in the [kube-downscaler documentation](https://codeberg.org/hjacobs/kube-downscaler).
# Deploy py-kube-downscaler using Helm chart

This directory contains tutorial to deploy py-kube-downscaler.

## Configuring your Deployment to downscale

Please add below annotations based on timezone your deployment should run:

```
metadata:
annotations:
downscaler/uptime: "Mon-Fri 07:00-19:00 US/Eastern"
```

Note: For more configuration details please,
refer [here](https://github.com/caas-team/py-kube-downscaler?tab=readme-ov-file#configuration).

## Architecture

The diagram below depicts how a py-kube-downscaler agent controls applications.
![Alt text](images/architecture.png?raw=true "Kube py-kube-downscaler diagram")

## Quick Start

Below are instructions to quickly install and configure py-kube-downscaler.

### Installing py-kube-downscaler

1. Make sure you're connected to the right cluster:

```
kubectl config current-context
```

2. Before deploying, make sure to update *values.yaml* in py-kube-downscaler chart depending on whether you want RBAC
roles deployed or not:

```yaml
rbac:
create: false
```

Note: In case RBAC is enabled, a new service account will be created for py-kube-downscaler with certain privileges,
otherwise the 'default' one will be used.

3. Deploy py-kube-downscaler:

```
cd chart
helm install . --namespace py-kube-downscaler --name py-kube-downscaler
```

4. Check the deployed release status:

```
helm list -n py-kube-downscaler
```

```
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
py-kube-downscaler 1 Tue Sep 25 02:07:58 2018 DEPLOYED py-kube-downscaler-0.5.1 0.5.1 py-kube-downscaler

```

5. Check whether py-kube-downscaler pod is up and running:

```
kubectl get pods -n py-kube-downscaler
```

```
NAME READY STATUS RESTARTS AGE
py-kube-downscaler-py-kube-downscaler-7f58c6b5b7-rnglz 1/1 Running 0 6m
```

6. Check the Kubernetes event logs, to make sure of successful deployment of py-kube-downscaler:

```
kubectl get events -w
```

## Acknowledgments

Thanks to [Kube-downscaler](https://github.com/hjacobs/kube-downscaler) project authored
by [Henning Jacobs](https://github.com/hjacobs).
Binary file added chart/images/architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 0 additions & 7 deletions deploy/config.yaml

This file was deleted.

41 changes: 0 additions & 41 deletions deploy/deployment.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions deploy/kustomization.yaml

This file was deleted.

104 changes: 0 additions & 104 deletions deploy/rbac.yaml

This file was deleted.

Loading
Loading