2022-09-29 14:22:08 +00:00
# convention 4 kubernetes: c4k-website
2022-11-11 13:01:08 +00:00
2022-11-08 15:23:10 +00:00
[![Clojars Project ](https://img.shields.io/clojars/v/org.domaindrivenarchitecture/c4k-website.svg )](https://clojars.org/org.domaindrivenarchitecture/c4k-website) [![pipeline status ](https://gitlab.com/domaindrivenarchitecture/c4k-website/badges/master/pipeline.svg )](https://gitlab.com/domaindrivenarchitecture/c4k-website/-/commits/main)
2022-07-27 07:14:01 +00:00
2022-09-29 14:22:08 +00:00
[<img src="https://domaindrivenarchitecture.org/img/delta-chat.svg" width=20 alt="DeltaChat"> chat over e-mail ](mailto:buero@meissa-gmbh.de?subject=community-chat ) | [<img src="https://meissa-gmbh.de/img/community/Mastodon_Logotype.svg" width=20 alt="team@social.meissa-gmbh.de"> team@social.meissa-gmbh.de ](https://social.meissa-gmbh.de/@team ) | [Website & Blog ](https://domaindrivenarchitecture.org )
2022-07-27 07:14:01 +00:00
2022-09-29 14:22:08 +00:00
## Purpose
2022-07-27 07:14:01 +00:00
2022-09-29 14:22:08 +00:00
Delivering cryogen generated static sites with the push of a few buttons.
2022-07-27 07:14:01 +00:00
2022-11-10 12:13:55 +00:00
c4k-website generates configuration files for multiple nginx webservers, and
2022-11-11 13:01:08 +00:00
corresponding cryogen static site generator build containers. This automatically downloads a `<branch>.zip` from a specified gitea API url. You need an authorization token to access the specified gitea user account. The build container is based on clojure:lein.
2022-07-27 07:14:01 +00:00
2022-11-10 12:13:55 +00:00
Following the example in valid-config.edn and valid-auth.edn you can add as many websites as you like (provided you have the DNS Routes set up). One set of configmaps, deployment, services etc will be created for each element in the :websites and :auth list.
2022-10-21 14:09:02 +00:00
2022-11-10 12:13:55 +00:00
Configs generated by c4k-website consists of the following parts:
2022-11-23 11:06:43 +00:00
* nginx deployment + configmap + service + ingress + certificate definitions
* nginx deployment has init container, building the website at startup time
2022-11-10 12:13:55 +00:00
* cron job for building and build secret for storing auth data
2022-11-23 11:06:43 +00:00
* respective volume claims
2022-07-27 07:14:01 +00:00
2024-02-21 07:40:39 +00:00
c4k-website is an example how to create efficient k8s one shot deployments with https://repo.prod.meissa.de/meissa/c4k-common.
2022-12-28 18:52:54 +00:00
## Status
Stable - we use this setup on production.
2022-09-29 14:22:08 +00:00
## Try out
2022-07-27 07:14:01 +00:00
2022-11-23 11:06:43 +00:00
Click on the image to try out in your browser:
2022-07-27 07:14:01 +00:00
2022-09-29 14:22:08 +00:00
[![Try it out ](doc/tryItOut.png "Try out yourself" )](https://domaindrivenarchitecture.org/pages/dda-provision/c4k-website/)
2022-09-08 12:12:19 +00:00
2022-09-29 14:22:08 +00:00
Your input will stay in your browser. No server interaction is required.
2022-09-08 12:12:19 +00:00
2022-12-28 18:52:54 +00:00
You will also be able to try out on cli:
```
target/graalvm/c4k-website src/test/resources/website-test/valid-config.yaml src/test/resources/website-test/valid-auth.yaml | kubeval -
target/graalvm/c4k-website src/test/resources/website-test/valid-config.yaml src/test/resources/website-test/valid-auth.yaml | kubectl apply -f -
```
2022-11-11 13:01:08 +00:00
## Usage
2022-07-27 07:14:01 +00:00
2022-09-29 14:22:08 +00:00
You need:
2022-07-27 07:14:01 +00:00
2022-10-21 14:09:02 +00:00
* DNS routes matching the fqdns in the lists
2022-09-29 14:22:08 +00:00
* cryogen as a static site generator
* a cryogen project ready to build
2022-11-23 11:06:43 +00:00
* a gitea account which holds the buildable project
* an authorization token for that account
* and a kubernetes cluster provisioned by [provs]
2022-07-27 07:14:01 +00:00
2022-11-23 11:06:43 +00:00
Add a unique identifier for each website to config.edn and auth.edn (e.g. domain-name).
Add the list of fqdns, your gitea host, name of the website repo and the respective branch name (usually "main") to config.edn.
Add auth token and gitea user with access to the website repo to auth.edn.
Let c4k-website generate your .yaml file.
Apply this file on your cluster with `kubectl apply -f yourApp.yaml` .
Done.
2022-07-27 07:12:32 +00:00
2022-11-11 13:01:08 +00:00
### Script Execution
2022-11-23 11:06:43 +00:00
Optionally you can specify a trusted script in your config.edn.
2022-11-11 13:01:08 +00:00
2022-11-23 11:06:43 +00:00
1. `sha256sum` "/path/to/your/script/file"
2. copy the output of this command
3. add the :sha256-output "hash-of-file file.name" :key value pair to the respective collection in :websites.
2022-11-11 13:01:08 +00:00
2022-11-23 11:06:43 +00:00
Also, see the example in valid-config.edn. The script file needs to exist in the `<branch>.zip` and path specification to the script file should be relative to the root of the unzipped folder. Scripts can be of any type - as long as an according shebang exists in the first line.
2022-11-11 13:01:08 +00:00
```bash
sha256sum your-script-file # use output of this call
sha256sum scripts/your-script-file # or this
sha256sum scripts/foo/bar/your-script-file # or this
```
2022-12-01 14:26:17 +00:00
### resource requests and limits
2022-12-01 14:40:22 +00:00
You may want to adjust the resource requests and limits of the build and init containers to your specific scenario.
2022-12-01 14:26:17 +00:00
2023-05-30 13:11:19 +00:00
## Development & mirrors
Development happens at: https://repo.prod.meissa.de/meissa/c4k-website
Mirrors are:
* https://gitlab.com/domaindrivenarchitecture/c4k-website (issues and PR, CI)
2023-07-28 12:03:34 +00:00
* https://github.com/DomainDrivenArchitecture/c4k-website
2023-05-30 13:11:19 +00:00
For more details about our repository model see: https://repo.prod.meissa.de/meissa/federate-your-repos
2022-07-27 07:12:32 +00:00
## License
2024-02-21 07:40:39 +00:00
Copyright © 2022, 2023, 2024 meissa GmbH
2022-09-29 14:22:08 +00:00
Licensed under the [Apache License, Version 2.0 ](LICENSE ) (the "License")
Pls. find licenses of our subcomponents [here ](doc/SUBCOMPONENT_LICENSE )
2022-11-10 12:08:09 +00:00
2022-11-10 12:13:55 +00:00
[provs]: https://gitlab.com/domaindrivenarchitecture/provs/