# knop

> Kubernetes operators made easy

Latest version **0.2.0** (published 2020-03-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install knop
pnpm add knop
yarn add knop
bun add knop
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2020-03-05 |
| First published | 2020-02-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 42.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | kesslerdev |

## Links

- npm: https://www.npmjs.com/package/knop
- npm.io page: https://npm.io/package/knop

## Dependencies (10)

- [glob](https://npm.io/package/glob.md) ^7.1.6
- [pino](https://npm.io/package/pino.md) ^5.16.0
- [yaml](https://npm.io/package/yaml.md) ^1.7.2
- [tslib](https://npm.io/package/tslib.md) ^1.11.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [@types/glob](https://npm.io/package/@types/glob.md) ^7.1.1
- [pino-pretty](https://npm.io/package/pino-pretty.md) ^3.6.0
- [humanize-duration](https://npm.io/package/humanize-duration.md) ^3.21.0
- [kubernetes-client](https://npm.io/package/kubernetes-client.md) ^8.3.6
- [@kubernetes/client-node](https://npm.io/package/@kubernetes/client-node.md) ^0.11.1

## Recent versions

- 0.2.0 (latest) — 2020-03-05
- 0.1.1 — 2020-02-28
- 0.1.0 — 2020-02-28

## README

# Knop, Kubernetes Nodejs OPerators made easy

## Getting started

```bash
# install cli
npm install -g knop-cli

# or using knop-cli with npx
npx -p knop-cli knop

# create an operator projet into my-operator directory (package name)
npx -p knop-cli knop new operator --name MyOperator

# add a controlled crd (api)
npx -p knop-cli knop new api --api-version svc.docaposte.cloud/v1alpha1 --kind Elasticsearch

# add the corresponding crd controller (api)
npx -p knop-cli knop new crd-controller --api-version svc.docaposte.cloud/v1alpha1 --kind Elasticsearch

# run operator in dev mode
npm run dev
```

## Development

### Scripts
- `npm run dev` : start operator locally (uses `~/.kube/config` for connecting to cluster)
- `npm run dk:build` : Build docker operator image
- `npm run clean` : remove artifacts (coverage, tmp, compiled files)
- `npm run test` : run tests (jest)
- `npm run test:watch` : run tests with watching
- `npm run lint` : check code with eslint
- `npm run build` : build (compile) operator sources files
- `npm run build:watch` : build with watching

### Generators

#### Operator

Generate a new node project for an operator
```bash
knop new operator --name "MyOperator"
```

only name is required.

|parameter|value|
|-|-|
|name| Humanized operator name, (underscore + dash for package name)|
|orgName | Humanized Organization name |
|org| npm organization|
| repo | git repository |
|dockerRepo | docker repository|

#### Api (CRD)

Generate a new CRD (yaml files & types)
```bash
knop new api --api-version svc.docaposte.cloud/v1alpha1 --kind Elasticsearch
```

api-version & kind are required

|parameter|value|
|-|-|
|api-version| kubernetes api version with group (ex svc.docaposte.cloud/v1alpha1) |
|kind | kubernetes kind |

#### CRD Controller
Generate a new CRD Controller, handle CR create/update/delete with deduplication (dosent fire if CR doesn't change)
```bash
knop new crd-controller --api-version svc.docaposte.cloud/v1alpha1 --kind Elasticsearch
```

api-version & kind are required (refers to managed CRD)

|parameter|value|
|-|-|
|api-version| kubernetes api version with group (ex svc.docaposte.cloud/v1alpha1) |
|kind | kubernetes kind |

## Deployment

```bash
# In a generated application (with at least an API)
# Register CRDs first
kubectl apply -f ./deploy/crds/*_crd.yaml

# Deploy operator (need docker image)
kubectl apply -f ./deploy/*.yaml
```

### Operator runtime Env options

| Variable          | Default       | Info                                                                                 |
|-------------------|---------------|--------------------------------------------------------------------------------------|
| `NODE_ENV`        | null          |                                                                                      |
| `LOGGER_LEVEL`    | `info`        | see [pino level ](https://getpino.io/#/docs/api?id=loggerlevel-string-gettersetter ) |
| `LAST_CONFIG_ANNOTATION` | `knop.skimia.org/last-applied-configuration` | annotation used in resource for storing changes                                             |
| `WATCH_NAMESPACE` | null          | When deployed it take the namespace of pod                                           |
| `REGISTER_CRD`    | `0`           | Unused now, create CRD in kubernetes at startup (update if exists)                   |

---
_Source: https://npm.io/package/knop · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
