Skip to content

Commit

Permalink
v0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DaemonDude23 committed Jul 28, 2022
1 parent b34afa1 commit ab7d53a
Show file tree
Hide file tree
Showing 24 changed files with 656 additions and 224 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ repos:
- id: check-ast
repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: v4.3.0
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.8.2
hooks:
- id: reorder-python-imports
args: [--application-directories, '.:src', --py36-plus]
- hooks:
- id: black
language_version: python3.9
Expand Down
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{
"args": [
"--debug",
"--no-sort-keys",
"./examples/commonAnnotations/helmizer.yaml"
],
"console": "integratedTerminal",
Expand Down Expand Up @@ -180,6 +181,18 @@
"request": "launch",
"type": "python"
},
{
"args": [
"--debug",
"./examples/secretGenerator/helmizer.yaml"
],
"console": "integratedTerminal",
"cwd": "${workspaceFolder}",
"name": "Example - secretGenerator",
"program": "${workspaceFolder}/src/helmizer.py",
"request": "launch",
"type": "python"
},
{
"args": [
"--debug",
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

- [Changelog](#changelog)
- [v0.12.0](#v0120)
- [v0.11.0](#v0110)
- [v0.10.0](#v0100)
- [v0.9.1](#v091)
Expand All @@ -16,6 +17,26 @@

---

## [v0.12.0](https://github.com/DaemonDude23/helmizer/releases/tag/v0.12.0)

July 27 2022

**Bugfixes**

- Fixed missing support for `secretGenerator` despite having something in [`secretGenerator` examples](./examples/secretGenerator/).
- Don't crash if `helmizer.version` and/or `helmizer.sort-keys` are not defined in the `helmizer.yaml` config... or practically anything. Omit the `helmizer` section of the config if you wish.

**Enhancements**

- Added `--no-sort-keys` CLI flag to disable key sorting of _all_ keys output kustomization.yaml on the CLI.

**Housekeeping**

- Added READMEs to example folders that didn't have them, and fixed other example READMEs.
- Bumped to latest versions in `requirements.txt` for no particular reason.
- Updated each relevant line with _type hinting_ for future experimentation.
- `pre-commit` config updates.

## [v0.11.0](https://github.com/DaemonDude23/helmizer/releases/tag/v0.11.0)

April 11 2022
Expand Down
72 changes: 33 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
# Helmizer

- [Helmizer](#helmizer)
- [About](#about)
- [Usage](#usage)
- [Configuration](#configuration)
- [Installation](#installation)
- [Putting it in your `$PATH`](#putting-it-in-your-path)
- [Linux (Simplest Option)](#linux-simplest-option)
- [virtualenv with pip](#virtualenv-with-pip)
- [Run](#run)
- [Local Python](#local-python)
- [~~Docker~~](#docker)
- [Examples](#examples)
- [Kustomize Options](#kustomize-options)
**Helmizer**

- [About](#about)
- [Usage](#usage)
- [Configuration](#configuration)
- [Installation](#installation)
- [Putting it in your `$PATH`](#putting-it-in-your-path)
- [Linux (Simplest Option)](#linux-simplest-option)
- [virtualenv with pip](#virtualenv-with-pip)
- [Run](#run)
- [Local Python](#local-python)
- [~~Docker~~](#docker)
- [Examples](#examples)
- [Kustomize Options](#kustomize-options)

---

## About
# About

**TLDR**

Generates a `kustomization.yaml` file, optionally providing the ability to run commands (e.g. `helm template`) on your OS prior to generating a kustomization, and will compose the kustomization fields that deal with file paths (e.g. `resources`) with glob-like features, as well as pass-through all other kustomization configuration properties. No need to explicitly enumerate every file to be kustomized individually.
Generates a `kustomization.yaml` file, optionally providing the ability to run commands (e.g. `helm template`) on your OS prior to generating a kustomization, and will compose the kustomization fields that deal with file paths (e.g. `resources`) with glob-like features, as well as pass-through all other kustomization configuration properties. No need to explicitly enumerate every file to be 'kustomized' individually.

It takes a config file as input, telling **Helmizer** if you want to run any commands. Then if you give it one or more directories for `resources`, for example, it will recursively lookup all of those files and render them into your kustomization.yaml. Want to skip including one file like `templates/secret.yaml`? Just add the relative path to `helmizer.ignore` to `helmizer.yaml`.

Expand All @@ -34,10 +33,10 @@ Instead of manually entering the paths to [`resources`](https://kubectl.docs.kub

I began transitioning my `helm` charts to local manifests via [`helm template`](https://helm.sh/docs/helm/helm_template/), which were then applied to the cluster separately via [Kustomize](https://kustomize.io/). I didn't enjoy having to manually manage the relative paths to files in the **kustomization**. I wanted a repeatable process to generate **Kubernetes** manifests from a helm chart, _and_ tack on any patches or related resources later with a single command. Thus, **helmizer**. **But [Helm](https://helm.sh/) is in no way required to make this tool useful** - have it walk your raw manifests as well. This is just a wrapper that allows combining steps, and glob-like behavior, to managing `kustomization.yaml` files.

## Usage
# Usage

```
usage: helmizer [-h] [--debug] [--dry-run] [--skip-commands] [--quiet] [--version] helmizer_config
usage: helmizer [-h] [--debug] [--dry-run] [--skip-commands] [--no-sort-keys] [--quiet] [--version] helmizer_config
Helmizer
Expand All @@ -47,12 +46,13 @@ optional arguments:
--debug enable debug logging (default: False)
--dry-run do not write to a file system (default: False)
--skip-commands skip executing commandSequence, just generate kustomization file (default: False)
--no-sort-keys disables alphabetical sorting of keys in output kustomization file (default: False)
--quiet, -q quiet output from subprocesses (default: False)
--version show program's version number and exit
--version, -v show program's version number and exit
helmizer_config path to helmizer config file
```

## Configuration
# Configuration

- Example `helmizer.yaml` config file. The `helm` command is invoked before the content for `kustomization.yaml` is generated. Any number of commands can be added here.
```yaml
Expand Down Expand Up @@ -156,18 +156,18 @@ kustomize: # this is essentially an overlay for your eventual kustomization.yam

</details>

### Installation
## Installation

For local installation/use of the raw script, I use a local virtual environment to isolate dependencies:

```bash
git clone https://github.com/DaemonDude23/helmizer.git -b v0.11.0
git clone https://github.com/DaemonDude23/helmizer.git -b v0.12.0
cd helmizer
```

### Putting it in your `$PATH`
## Putting it in your `$PATH`

#### Linux (Simplest Option)
### Linux (Simplest Option)

1. Create symlink:
```bash
Expand All @@ -182,16 +182,15 @@ pip3 install -U -r ./src/requirements.txt
pip3 install -U -r ./src/requirements-old.txt
```

### virtualenv with pip
## virtualenv with pip

1. Update pip:
```bash
python3 -m pip install --upgrade pip
./venv/bin/python -m pip install --upgrade pip
```
2. Install `virtualenv` for your user:
```bash
./venv/bin/pip3 install virtualenv==20.4.2
pip3 install -U virtualenv==20.16.2
```
3. Setup relative virtual environment:
```bash
Expand All @@ -212,11 +211,11 @@ If you need to reset the virtual environment for whatever reason:
virtualenv --clear ./venv/
```

### Run
## Run

**For greater detail on running from examples (they assumes you've ran [helm template](https://helm.sh/docs/helm/helm_template/), see the [resource example](examples/resources/README.md))**

#### Local Python
### Local Python

Input file:
```yaml
Expand All @@ -235,11 +234,6 @@ helmizer:
- --version
- '1.12.2'
- stable/sealed-secrets
dry-run: false
kustomization-directory: .
kustomization-file-name: kustomization.yaml
sort-keys: true
version: '0.1.0'
kustomize:
namespace: sealed-secrets
resources:
Expand Down Expand Up @@ -267,7 +261,7 @@ resources:
- sealed-secrets/templates/role.yaml
```

#### ~~Docker~~
### ~~Docker~~

**You may need a custom docker image depending on if you need certain apps when running commands within helmizer**
**I'm not maintaining the docker image anymore, but you could build it easily from the included Dockerfile**
Expand All @@ -278,11 +272,11 @@ In this example (*Nix OS), we're redirecting program output to the (e.g. `kustom
docker run --name helmizer \
--rm \
-v "$PWD"/examples:/tmp/helmizer -w /tmp/helmizer \
docker.pkg.github.com/DaemonDude23/helmizer/helmizer:v0.11.0 /usr/src/app/helmizer.py \
docker.pkg.github.com/DaemonDude23/helmizer/helmizer:v0.12.0 /usr/src/app/helmizer.py \
./resources/ > ./examples/resources/kustomization.yaml
```

### Examples
## Examples

_With [vscode](https://code.visualstudio.com/) you can utilize the included [launch.json](.vscode/launch.json) to test these more quickly, or reference for your configuration._
The `sealed-secrets` **Helm** chart is used for examples for its small scope. Here's another.
Expand Down Expand Up @@ -396,7 +390,7 @@ resources:
- templates/prometheus/servicemonitor.yaml
```

## Kustomize Options
# Kustomize Options

- [Kustomize Docs](https://kubectl.docs.kubernetes.io/references/kustomize/)

Expand Down
8 changes: 0 additions & 8 deletions examples/commonAnnotations/helmizer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ helmizer:
- --version
- '1.12.2'
- stable/sealed-secrets
dry-run: false
kustomization-directory: .
kustomization-file-name: kustomization.yaml
sort-keys: false
version: '0.1.0'
ignore:
- sealed-secrets/templates/helmizer.yaml
kustomize:
namespace: sealed-secrets
resources:
Expand All @@ -29,4 +22,3 @@ kustomize:
commonAnnotations:
app.kubernetes.io/annotation: yeah
linkerd.io/inject: enabled
commonLabels: {}
8 changes: 4 additions & 4 deletions examples/commonAnnotations/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ commonAnnotations:
kind: Kustomization
namespace: sealed-secrets
resources:
- sealed-secrets/templates/cluster-role-binding.yaml
- sealed-secrets/templates/cluster-role.yaml
- sealed-secrets/templates/cluster-role-binding.yaml
- sealed-secrets/templates/service.yaml
- sealed-secrets/templates/deployment.yaml
- sealed-secrets/templates/role-binding.yaml
- sealed-secrets/templates/role.yaml
- sealed-secrets/templates/sealedsecret-crd.yaml
- sealed-secrets/templates/service-account.yaml
- sealed-secrets/templates/service.yaml
- sealed-secrets/templates/role.yaml
- sealed-secrets/templates/role-binding.yaml
15 changes: 3 additions & 12 deletions examples/configMapGenerator/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# resources
# configMapGenerator

- [resources](#resources)
- [configMapGenerator](#configmapgenerator)
- [Generating the Helm Template](#generating-the-helm-template)
- [Generate Kustomization](#generate-kustomization)
- [Local Python](#local-python)
Expand All @@ -20,23 +20,14 @@ helm -n sealed-secrets template \
stable/sealed-secrets
```

```bash
helm -n cert-manager template \
cert-manager \
--output-dir . \
--skip-tests \
--version 1.1.0 \
jetstack/cert-manager
```

## Generate Kustomization

_These assumes you're in the root directory of this repository_

### Local Python

```bash
python3 ./src/helmizer.py ./examples/resources/helmizer.yaml
python3 ./src/helmizer.py ./examples/configMapGenerator/helmizer.yaml
```

## Validate
Expand Down
37 changes: 37 additions & 0 deletions examples/generatorOptions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# generatorOptions

- [generatorOptions](#generatoroptions)
- [Generating the Helm Template](#generating-the-helm-template)
- [Generate Kustomization](#generate-kustomization)
- [Local Python](#local-python)
- [Validate](#validate)

---

## Generating the Helm Template

```bash
helm -n sealed-secrets template \
sealed-secrets \
--output-dir . \
--include-crds \
--skip-tests \
--version 1.12.2 \
stable/sealed-secrets
```

## Generate Kustomization

_These assumes you're in the root directory of this repository_

### Local Python

```bash
python3 ./src/helmizer.py ./examples/generatorOptions/helmizer.yaml
```

## Validate

```bash
kubectl kustomize .
```
4 changes: 0 additions & 4 deletions examples/generatorOptions/helmizer.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
helmizer:
dry-run: false
kustomization-directory: .
kustomization-file-name: kustomization.yaml
sort-keys: true
version: '0.1.0'
kustomize:
generatorOptions:
labels:
Expand Down

0 comments on commit ab7d53a

Please sign in to comment.