stakater/application Helm Chart

repository·main·Indexed 18 days ago

https://github.com/stakater/application

A generic and extensible Helm chart for deploying stateless Kubernetes workloads, including Deployments, Jobs, and CronJobs. It provides integrated support for companion resources such as Services, Ingress, RBAC, HPA/VPA, monitoring (Prometheus/Grafana), and secret management via SealedSecrets and ExternalSecrets.

Tokens
3.2K
Snippets
7
Records
17
Agent score
13%

What's inside stakater-application

  1. Overview of the Application Helm chart

    main

    The application chart is a generic Helm chart designed for deploying stateless applications on Kubernetes. It provides support for:

    • Workloads: Deployments, Jobs, and CronJobs.
    • Companion Resources: Services, Ingress, RBAC, autoscaling, monitoring, certificates, and more.
  2. Naming convention for ConfigMap, Secret, SealedSecret and ExternalSecret

    main

    When using the application chart to manage configuration or secrets, the generated resource names follow a specific pattern: {{ template "application.name" $ }}-{{ $nameSuffix }}.

    • {{ template "application.name" }}: Resolves to the value of .Values.applicationName. If not provided, it defaults to the Helm chart name.
    • nameSuffix: This is the key defined within the secret.files, configMap.files, sealedSecret.files, or externalSecret.files blocks.

    Example: If applicationName is helloworld and you define a configMap file with the key config, the resulting ConfigMap name will be helloworld-config.

    applicationName: helloworld
    
    configMap:
      files:
        config: # This is the nameSuffix
          key: value
  3. Install the Application Helm chart from the Helm repository (deprecated)

    main

    The Helm repository method is deprecated. Use the OCI registry method instead. If you must use the repository, add the stakater repo and update it before installing.

    helm repo add stakater https://stakater.github.io/stakater-charts
    helm repo update
    
    # Install the latest version
    helm install my-application stakater/application --namespace test
    
    # Install a specific version
    helm install my-application stakater/application --version <version> --namespace test
  4. Consume environment variables from ConfigMaps

    main

    You can inject environment variables into your Deployment or CronJob using the env or envFrom keys in your values file.

    1. Single Key/Value from ConfigMap

    To pull a specific key from a ConfigMap managed by this chart, use valueFrom.configMapKeyRef. You must calculate the name using the pattern <applicationName>-<nameSuffix>.

    2. Bulk Environment Variables from ConfigMap (envFrom)

    To load all keys from a ConfigMap as environment variables, use the envFrom block. You have two options:

    • Managed ConfigMap: Use nameSuffix to automatically target the ConfigMap created by this chart (name will be <applicationName>-<nameSuffix>).
    • External ConfigMap: Use name to reference a ConfigMap that exists independently of this chart.

    You can also set optional: true/false to determine if the pod should fail to start if the ConfigMap is missing.

    # Scenario: applicationName is 'my-application'
    
    # 1. Single key from managed ConfigMap
    env:
      APP_LOG_LEVEL:
        valueFrom:
          configMapKeyRef:
            name: my-application-application-config
            key: LOG
    
    # 2. All keys from managed ConfigMap
    envFrom:
      application-config-env:
        type: configmap
        nameSuffix: application-config
        optional: true
    
    # 3. All keys from an existing external ConfigMap
    envFrom:
      external-configmap:
        type: configmap
        name: my-existing-configmap
  5. Install the Application Helm chart from the OCI registry

    main

    The recommended way to install the application chart is via the OCI registry. You can install the latest version or specify a specific version using the --version flag.

    # Install the latest version
    helm install my-application oci://ghcr.io/stakater/charts/application --namespace test
    
    # Install a specific version
    helm install my-application oci://ghcr.io/stakater/charts/application --version <version> --namespace test
  6. Consume environment variables from Secrets

    main

    Similar to ConfigMaps, you can inject secrets into your application.

    1. Single Key/Value from Secret

    Use valueFrom.secretKeyRef to pull a specific key. The name follows the <applicationName>-<nameSuffix> pattern.

    2. Bulk Environment Variables from Secret (envFrom)

    To load all keys from a Secret as environment variables, use the envFrom block:

    • Managed Secret: Use nameSuffix to target the Secret created by this chart.
    • External Secret: Use name to reference an existing Secret.

    Note: The first key in the envFrom block (e.g., database-credentials) is a unique identifier for that object within the block and should be descriptive.

    # Scenario: applicationName is 'my-application'
    
    # 1. Single key from managed Secret
    env:
      KEY:
        valueFrom:
          secretKeyRef:
            name: my-application-db-credentials
            key: USER
    
    # 2. All keys from managed Secret
    envFrom:
      database-credentials:
        type: secret
        nameSuffix: db-credentials
    
    # 3. All keys from an existing external Secret
    envFrom:
      external-secret:
        type: secret
        name: my-existing-secret
  7. Configure Autoscaling (HPA and VPA)

    main

    Manage workload scaling using Horizontal or Vertical Pod Autoscalers:

    Horizontal Pod Autoscaler (HPA)

    • autoscaling.enabled: Enable HPA (default: false).
    • autoscaling.minReplicas / autoscaling.maxReplicas: Scaling boundaries.
    • autoscaling.metrics: List of metrics (e.g., CPU or Memory utilization) used for scaling.

    Vertical Pod Autoscaler (VPA)

    • vpa.enabled: Enable VPA (default: false).
    • vpa.updatePolicy: Update mode (e.g., Auto).
  8. Configure global application parameters

    main

    Use the following top-level parameters to configure global settings for all resources managed by the chart:

    • applicationName: Prefix for all resource names (defaults to the Helm release name).
    • namespaceOverride: Override the namespace for all resources.
    • componentOverride: Override the component label for all resources.
    • partOfOverride: Override the partOf label for all resources.
    • additionalLabels: An object of additional labels applied to all resources. Keys and values are evaluated as templates.
    • extraObjects: A list or object of extra Kubernetes manifests to deploy. If an object, keys are ignored and only values are used.
  9. Configure Service and Networking

    main

    Manage how your application is exposed via the following parameter groups:

    Service

    • service.enabled: Enable the Service (default: true).
    • service.type: Service type (e.g., ClusterIP, LoadBalancer).
    • service.ports: List of ports. Each port can specify name, port, protocol, and targetPort.

    Ingress

    • ingress.enabled: Enable Ingress (default: false).
    • ingress.hosts: List of hosts, each with host, paths (including path and pathType), and serviceName/servicePort.
    • ingress.tls: TLS configuration for the ingress.

    Gateway API (HTTPRoute & ListenerSet)

    • httpRoute.enabled: Enable HTTPRoute (default: false).
    • listenerSet.enabled: Enable ListenerSet (default: false).

    OpenShift Route

    • route.enabled: Deploy an OpenShift Route (default: false).
    • route.tls.termination: TLS termination strategy (e.g., edge).
  10. Configure Backups with Velero/OADP

    main

    Enable data protection using Velero/OADP:

    • backup.enabled: Enable Velero/OADP Backup (default: false).
    • backup.storageLocation: Name of the backup storage location.
    • backup.ttl: Retention duration (e.g., 1h0m0s).
    • backup.includedNamespaces: List of namespaces to include in the backup.
    • backup.snapshotVolumes: Whether to take snapshots of persistent volumes (default: true).
    • backup.defaultVolumesToFsBackup: Use filesystem backup for all pod volumes (default: true).
  11. Configure Liveness and Readiness Probes

    main

    You can configure, customize, or disable liveness and readiness probes in your values file.

    • Disable Probes: Set enabled: false.
    • HTTP Probes: The default handler is httpGet. Override path and port to customize.
    • Exec Probes: To use a command-based probe, define the exec field with a command list.
    # Disable probe
    livenessProbe:
      enabled: false
    
    # HTTP probe
    livenessProbe:
      enabled: true
      httpGet:
        path: '/path'
        port: 8080
    
    # Exec probe
    livenessProbe:
      enabled: true
      exec:
        command:
          - cat
          - /tmp/healthy