helm-common

by Code Factory

Helm chartv0.0.1Verified publisher

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.yaml contains the project related values, like ingress config, resource allocations, imagePullSecrets, stb.
  • project_name/templates folder contains yaml files, which uses helm-common templates. See above.
  • project_name/charts folder contains the micro service configurations
  • project_name/charts/templates similar to project_name/templates
  • project_name/chart/values.yaml contains the values to a specific microservice, eg. resource allocation, secret name, environment variables, images name, version, liveness/readiness settings, etc.
  • project_name/chart/Chart.yaml contains 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

KeyTypeDefaultDescription
affinityobject{}Configure affinity
annotationsobject{}Configure annotations for the deployment and service
appEnvConfigMapobject{"annotations":{},"name":"app-env-config-map"}Configure configmap for env vars See env.configMap for more
appEnvSecret.namestring"app-env-secret"Name of the secret for sensitive env vars (It will be removed in future versions.) See env.secret for more
application.argsstringnilSet args for the application container https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes
application.commandstringnilSet command for the application container https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes
application.lifecyclestringnilSet 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.livenessobject{"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.commandstringnilLiveness check http headers (used only probe type exec)
application.liveness.enabledbooltrueSet false to disable liveness probe
application.liveness.failureThresholdint3Liveness check failureThreshold
application.liveness.hoststringnilLiveness check host (used only probe type httpGet and tcpSocket)
application.liveness.httpHeadersstringnilLiveness check http headers (used only probe type httpGet)
application.liveness.initialDelaySecondsint0Liveness check initialDelaySeconds
application.liveness.pathstring"/health"Liveness check endpoint (used only probe type httpGet)
application.liveness.periodSecondsint20Liveness check periodSeconds
application.liveness.portint9000Liveness check port (used only probe type httpGet and tcpSocket)
application.liveness.schemestring"HTTP"Liveness check Scheme to use for connecting to the host. Defaults to HTTP. (used only probe type httpGet)
application.liveness.timeoutSecondsint1Liveness check timeoutSeconds
application.liveness.typestring"httpGet"Valid probe types are: httpGet, tcpSocket, exec
application.managementPortint9000The mangement port the application, where the metrics, liveness and readiness is reachable
application.readinessobject{"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.commandstringnilReadiness check http headers (used only probe type exec)
application.readiness.enabledbooltrueSet false to disable readiness probe
application.readiness.failureThresholdint3Readiness check failureThreshold
application.readiness.hoststringnilReadiness check host (used only probe type httpGet and tcpSocket)
application.readiness.httpHeadersstringnilReadiness check http headers (used only probe type httpGet)
application.readiness.initialDelaySecondsint0Readiness check initialDelaySeconds
application.readiness.pathstring"/health"Readiness check endpoint (used only probe type httpGet)
application.readiness.periodSecondsint10Readiness check periodSeconds
application.readiness.portint9000Readiness check port (used only probe type httpGet and tcpSocket)
application.readiness.schemestring"HTTP"Readiness check Scheme to use for connecting to the host. Defaults to HTTP. (used only probe type httpGet)
application.readiness.successThresholdint1Readiness check successThreshold
application.readiness.timeoutSecondsint1Readiness check timeoutSeconds
application.readiness.typestring"httpGet"Valid probe types are: httpGet, tcpSocket, exec
application.serverPortint8000The port where the application listens
application.startupProbeobject{"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.commandstringnilStartup check http headers (used only probe type exec)
application.startupProbe.enabledbooltrueSet false to disable startup probe
application.startupProbe.failureThresholdint30Startup check failureThreshold
application.startupProbe.hoststringnilStartup check host (used only probe type httpGet and tcpSocket)
application.startupProbe.httpHeadersstringnilStartup check http headers (used only probe type httpGet)
application.startupProbe.initialDelaySecondsint0Startup check initialDelaySeconds
application.startupProbe.pathstring"/health"Startup check endpoint (used only probe type httpGet)
application.startupProbe.periodSecondsint10Startup check periodSeconds
application.startupProbe.portint9000Startup check port (used only probe type httpGet and tcpSocket)
application.startupProbe.schemestring"HTTP"Startup check Scheme to use for connecting to the host. Defaults to HTTP. (used only probe type httpGet)
application.startupProbe.timeoutSecondsint1Startup check timeoutSeconds
application.startupProbe.typestring"httpGet"Valid probe types are: httpGet, tcpSocket, exec
application.terminationGracePeriodSecondsstringnilConfigure time to wait until the pod is killed more
cronJob.concurrencyPolicystring"Allow"concurrency-policy
cronJob.failedJobsHistoryLimitint1jobs-history-limits
cronJob.job.activeDeadlineSecondsstringniljob-termination-and-cleanup
cronJob.job.backoffLimitint6pod-backoff-failure-policy
cronJob.job.completionsint1parallel-jobs
cronJob.job.parallelismint1parallel-jobs
cronJob.job.podRestartPolicystring"OnFailure"Supported values: "OnFailure", "Never"
cronJob.job.ttlSecondsAfterFinishedstringnilttl-mechanism-for-finished-jobs
cronJob.schedulestring"@daily"schedule
cronJob.startingDeadlineSecondsstringnilstarting-deadline
cronJob.successfulJobsHistoryLimitint3jobs-history-limits
cronJob.suspendboolfalsesuspend
defaultIpPoolboolfalseUse 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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the charthelm-common is pinned at v0.0.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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