helm-common
by Code Factory
A Helm chart template for creating helm charts
About this chart
helm-common
A Helm chart template for creating helm charts
Homepage: https://github.com/codefactoryhu/helm-common
Code Factory's helm-common is a developer friendly DevOps solution to deploy any application or service into Kubernetes. It's based on inidustrial standards and contains many years of experience developing and shipping real life services. It highly supports microservice architecture and semantic versioning. The template system of helm-common is a really powerfool tool, which allows you to ship your products even faster.
Code Factory's helm-common is a very good place to start your jurney with Kubernetes and Helm, or if you want to have a standardized deployment solution.
If you have any question about this tool, or if you have any suggestion how to improve it, open a new issue or PR, and let's discuss it!
Happy helming!
Usage
Create a new project
To use helm-common you need a separate project for managing your micro services with helm. Let's call it helm.
In order to maximize the power of helm-common we recommend to use a similar folder structure like this.
project_name/
charts/
ms1/
templates/
deployment.yaml
...
Chart.yaml
values.yaml
ms2/
...
templates/
ingress.yaml
secret.yaml
...
Chart.yaml
values.yaml
.gitignore
.releaserc.yaml
.gitlab-ci.yaml
values-dev.yaml
values-test.yaml
values-prod.yaml
Set as dependency for a new or an existing chart:
# project_name/Chart.yaml
...
dependencies:
- name: "helm-common"
version: 0.0.1
repository: "@arti_internal" # or "https://domain.tld/artifactory/helm-virtual"
...
@arti_internal should be added as a helm repo:
helm repo add @arti_internal https://domain.tld/artifactory/helm-virtual
Now you can include the following templates in your template yaml files and configure their behaviour with the values.yaml:
configmap.yaml
{{- template "common.app-env-configmap" . -}}
# configmap for environment variables in your deployment
deployment.yaml
{{- template "common.deployment" . -}}
# deployment for your microservice
ingress.yaml
{{- template "common.ingress" . -}}
# ingress for your services
secret.yaml
{{- template "common.app-env-secret" . --}}
# secret for environment variables in your deployment
service.yaml
{{- template "common.service" . -}}
# service for your deployment
cronjob.yaml
{{- template "common.cronjob" . -}}
# cronjob for your microservice
Roles of the files
- root level values-*.yaml files contain the envionment specific values, like evironment variables, ingress config, etc.
- project_name/Chart.yaml contains the ubrella chart info about the project.
apiVersion: v2
appVersion: 1.0.1
description: Some description
name: project_name
type: application
version: 1.0.1
dependencies:
- name: helm-common
version: 1.0.0
repository: "@arti_internal"
- name: ms1
version: ">=0.0.0-0"
- name: ms2
version: ">=0.0.0-0"
project_name/values.yamlcontains the project related values, like ingress config, resource allocations, imagePullSecrets, stb.project_name/templatesfolder contains yaml files, which useshelm-commontemplates. See above.project_name/chartsfolder contains the micro service configurationsproject_name/charts/templatessimilar toproject_name/templatesproject_name/chart/values.yamlcontains the values to a specific microservice, eg. resource allocation, secret name, environment variables, images name, version, liveness/readiness settings, etc.project_name/chart/Chart.yamlcontains the chart data of a specific microservice.
apiVersion: v2
appVersion: 1.0.0
description: Some description
name: ms1
type: application
version: 1.0.0
dependencies:
- name: "helm-common"
version: 1.0.0
repository: "@arti_internal"
Values
| Key | Type | Default | Description |
|---|---|---|---|
| affinity | object | {} | Configure affinity |
| annotations | object | {} | Configure annotations for the deployment and service |
| appEnvConfigMap | object | {"annotations":{},"name":"app-env-config-map"} | Configure configmap for env vars See env.configMap for more |
| appEnvSecret.name | string | "app-env-secret" | Name of the secret for sensitive env vars (It will be removed in future versions.) See env.secret for more |
| application.args | string | nil | Set args for the application container https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes |
| application.command | string | nil | Set command for the application container https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes |
| application.lifecycle | string | nil | Set postStart and preStop hook for the application container https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/#define-poststart-and-prestop-handlers |
| application.liveness | object | {"command":null,"enabled":true,"failureThreshold":3,"host":null,"httpHeaders":null,"initialDelaySeconds":0,"path":"/health","periodSeconds":20,"port":9000,"scheme":"HTTP","timeoutSeconds":1,"type":"httpGet"} | Configure the health check for the application |
| application.liveness.command | string | nil | Liveness check http headers (used only probe type exec) |
| application.liveness.enabled | bool | true | Set false to disable liveness probe |
| application.liveness.failureThreshold | int | 3 | Liveness check failureThreshold |
| application.liveness.host | string | nil | Liveness check host (used only probe type httpGet and tcpSocket) |
| application.liveness.httpHeaders | string | nil | Liveness check http headers (used only probe type httpGet) |
| application.liveness.initialDelaySeconds | int | 0 | Liveness check initialDelaySeconds |
| application.liveness.path | string | "/health" | Liveness check endpoint (used only probe type httpGet) |
| application.liveness.periodSeconds | int | 20 | Liveness check periodSeconds |
| application.liveness.port | int | 9000 | Liveness check port (used only probe type httpGet and tcpSocket) |
| application.liveness.scheme | string | "HTTP" | Liveness check Scheme to use for connecting to the host. Defaults to HTTP. (used only probe type httpGet) |
| application.liveness.timeoutSeconds | int | 1 | Liveness check timeoutSeconds |
| application.liveness.type | string | "httpGet" | Valid probe types are: httpGet, tcpSocket, exec |
| application.managementPort | int | 9000 | The mangement port the application, where the metrics, liveness and readiness is reachable |
| application.readiness | object | {"command":null,"enabled":true,"failureThreshold":3,"host":null,"httpHeaders":null,"initialDelaySeconds":0,"path":"/health","periodSeconds":10,"port":9000,"scheme":"HTTP","successThreshold":1,"timeoutSeconds":1,"type":"httpGet"} | Configure the ready check for the application |
| application.readiness.command | string | nil | Readiness check http headers (used only probe type exec) |
| application.readiness.enabled | bool | true | Set false to disable readiness probe |
| application.readiness.failureThreshold | int | 3 | Readiness check failureThreshold |
| application.readiness.host | string | nil | Readiness check host (used only probe type httpGet and tcpSocket) |
| application.readiness.httpHeaders | string | nil | Readiness check http headers (used only probe type httpGet) |
| application.readiness.initialDelaySeconds | int | 0 | Readiness check initialDelaySeconds |
| application.readiness.path | string | "/health" | Readiness check endpoint (used only probe type httpGet) |
| application.readiness.periodSeconds | int | 10 | Readiness check periodSeconds |
| application.readiness.port | int | 9000 | Readiness check port (used only probe type httpGet and tcpSocket) |
| application.readiness.scheme | string | "HTTP" | Readiness check Scheme to use for connecting to the host. Defaults to HTTP. (used only probe type httpGet) |
| application.readiness.successThreshold | int | 1 | Readiness check successThreshold |
| application.readiness.timeoutSeconds | int | 1 | Readiness check timeoutSeconds |
| application.readiness.type | string | "httpGet" | Valid probe types are: httpGet, tcpSocket, exec |
| application.serverPort | int | 8000 | The port where the application listens |
| application.startupProbe | object | {"command":null,"enabled":true,"failureThreshold":30,"host":null,"httpHeaders":null,"initialDelaySeconds":0,"path":"/health","periodSeconds":10,"port":9000,"scheme":"HTTP","timeoutSeconds":1,"type":"httpGet"} | Configure the startup check for the application |
| application.startupProbe.command | string | nil | Startup check http headers (used only probe type exec) |
| application.startupProbe.enabled | bool | true | Set false to disable startup probe |
| application.startupProbe.failureThreshold | int | 30 | Startup check failureThreshold |
| application.startupProbe.host | string | nil | Startup check host (used only probe type httpGet and tcpSocket) |
| application.startupProbe.httpHeaders | string | nil | Startup check http headers (used only probe type httpGet) |
| application.startupProbe.initialDelaySeconds | int | 0 | Startup check initialDelaySeconds |
| application.startupProbe.path | string | "/health" | Startup check endpoint (used only probe type httpGet) |
| application.startupProbe.periodSeconds | int | 10 | Startup check periodSeconds |
| application.startupProbe.port | int | 9000 | Startup check port (used only probe type httpGet and tcpSocket) |
| application.startupProbe.scheme | string | "HTTP" | Startup check Scheme to use for connecting to the host. Defaults to HTTP. (used only probe type httpGet) |
| application.startupProbe.timeoutSeconds | int | 1 | Startup check timeoutSeconds |
| application.startupProbe.type | string | "httpGet" | Valid probe types are: httpGet, tcpSocket, exec |
| application.terminationGracePeriodSeconds | string | nil | Configure time to wait until the pod is killed more |
| cronJob.concurrencyPolicy | string | "Allow" | concurrency-policy |
| cronJob.failedJobsHistoryLimit | int | 1 | jobs-history-limits |
| cronJob.job.activeDeadlineSeconds | string | nil | job-termination-and-cleanup |
| cronJob.job.backoffLimit | int | 6 | pod-backoff-failure-policy |
| cronJob.job.completions | int | 1 | parallel-jobs |
| cronJob.job.parallelism | int | 1 | parallel-jobs |
| cronJob.job.podRestartPolicy | string | "OnFailure" | Supported values: "OnFailure", "Never" |
| cronJob.job.ttlSecondsAfterFinished | string | nil | ttl-mechanism-for-finished-jobs |
| cronJob.schedule | string | "@daily" | schedule |
| cronJob.startingDeadlineSeconds | string | nil | starting-deadline |
| cronJob.successfulJobsHistoryLimit | int | 3 | jobs-history-limits |
| cronJob.suspend | bool | false | suspend |
| defaultIpPool | bool | false | Use 192 |
Deploy helm-common with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has helm-common on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the charthelm-common is pinned at v0.0.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply