There are many comparable solutions for creating c4k deployments like `helm` or `kustomize`.
`kustomize` is great to manage your k8s manifests by splitting huge files into handy parts.
`helm` is great because of its large community.
Why do we need another one? Why do you continue the reading here?
We combine the simplicity of `kustomize` with the ability for doing real programming as software developers would do.
Following the principle
"Use programming language for programming"
we are clearly enjoy writing kubernetes manifests with clojure. In comparison with helms templating, things such as business logic, conventions, input validation, versions, dependencies and reuse are much easier and much more reliable to implement.
By the way, c4k means "convention for kubernetes".
c4k-common provides the foundation for all our c4k modules.
### Features
It is now possible to generate a working prometheus monitoring file in yaml format.
c4k-common supports the following use cases:
Your config.edn and your auth.edn should at least contain the following fields:
config.edn - minimal example
#### Target Cli and Web Frontend
Set up your cli as follows
```clojure
```clojure
{:k3s-cluster-name "your-cluster-name"
(defn -main [& cmd-args]
:k3s-cluster-stage :prod
(uberjar/main-common
:grafana-cloud-url "your-url"}
"c4k-forgejo" ;; name of your app
core/config? ;; schema for config validation
core/auth? ;; schema for credential validation
core/config-defaults ;; want to set default values?
core/k8s-objects ;; the function generate the k8s manifest
cmd-args ;; command line arguments given
))
```
```
auth.edn - minimal example
The full example can be found here: https://repo.prod.meissa.de/meissa/c4k-forgejo/src/branch/main/src/main/clj/dda/c4k_forgejo/uberjar.clj
```clojure
{:grafana-cloud-user "user"
You can create your manifest as web-application also (using page local js without server interaction)
c4k-common supports all its resources, input and output as yaml and as edn.
The following command line will work also:
There are many comparable solutions for creating c4k deployments like helm or kustomize. Why do we need another one?
```bash
* We like the simplicity of kustomize. Yaml in, yaml out, the ability to lint the result and the option to split large yaml files into objects. But a simple overwriting per environment may not be enough ...
* We like helm packages. A package encapsulates the setup for an application. On the one hand, but on the other hand we don't like the idea of having to program and debug in a template language. We can program much better in real programming languages.
```
Our convention 4 kubernetes c4k-* tools combine the advantages of both approaches:
#### Inline k8s resources for versioning & dependencies
* Packages for one application
* Programming in clojure
* yaml / edn as input and output, no more magic
* good validation, integration as api, cli or in the browser
## Usage
We inline all resources used in our libraries & applications. You can generate k8s manifests everywhere without additional external dependencies.
c4k-common provides the basic functionality for our c4k-modules.
In case of
* java: Resources are included in the jar-file out of the box (see https://repo.prod.meissa.de/meissa/c4k-forgejo/src/branch/main/project.clj#L13).
* js: With a slim macro call we inline resources to the resulting js file (see https://repo.prod.meissa.de/meissa/c4k-forgejo/src/branch/main/src/main/cljc/dda/c4k_forgejo/forgejo.cljc#L72-L74)
* native: On native builds we inline resources also (see https://repo.prod.meissa.de/meissa/c4k-forgejo/src/branch/main/build.py#L126)
## Refactoring & Module Overview
#### Work on structured Data instead flat Templating
To keep things simple, we do also templating. But we convert given k8s resources to structured data.
This allows us to have more control and do unit tests: