mod-chart

by ygqygq2

Helm chartv5.1.0App 1.0.0Verified publisher

Chart for the nginx server

About this chart

mod-chart

mod-chart (pronounced "engine-x") is an open source reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols, as well as a load balancer, HTTP cache, and a web server (origin server).

TL;DR

$ helm repo add ygqygq2 https://ygqygq2.github.io/charts/
$ helm install my-release ygqygq2/mod-chart

Introduction

mod-chart 参考 Bitnami 作为一个通用模板,可用于新 chart 的快速制作,仅需将 app-name 名字替换下即可。

This chart bootstraps a mod-chart Open Source deployment on a Kubernetes cluster using the Helm package manager.

Bitnami charts can be used with Kubeapps for deployment and management of Helm Charts in clusters.

Prerequisites

  • Kubernetes 1.23+
  • Helm 3.8.0+

Installing the Chart

To install the chart with the release name my-release:

$ helm repo add ygqygq2 https://ygqygq2.github.io/charts/
$ helm install my-release ygqygq2/mod-chart

These commands deploy mod-chart Open Source on the Kubernetes cluster in the default configuration.

Tip: List all releases using helm list

Usage Examples

Using Gateway API (Recommended)

Gateway API is the next-generation Kubernetes ingress standard with more features than traditional Ingress.

Prerequisites

  1. Install Gateway API CRDs (Standard version):
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.4.1/standard-install.yaml
  1. Install a Gateway Implementation (choose one):
  • Envoy Gateway (Official reference implementation):
helm repo add envoy-gateway https://gateway.envoyproxy.io
helm install eg envoy-gateway/gateway-helm \
  --namespace envoy-gateway-system \
  --create-namespace
  • Or Istio, Cilium, Kong, Traefik, etc.
  1. Create a Gateway Resource:

For HTTP only:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: my-gateway
  namespace: default
spec:
  gatewayClassName: eg # Match your Gateway implementation
  listeners:
    - name: http
      protocol: HTTP
      port: 80

For HTTP + HTTPS:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: my-gateway
  namespace: default
spec:
  gatewayClassName: eg
  listeners:
    - name: http
      protocol: HTTP
      port: 80
    - name: https
      protocol: HTTPS
      port: 443
      tls:
        mode: Terminate
        certificateRefs:
          - kind: Secret
            name: my-tls-cert # TLS certificate secret

Apply the Gateway:

kubectl apply -f gateway.yaml

Example 1: Simple HTTP Routing

gateway:
  enabled: true
  gatewayClassName: my-gateway
  namespace: default
  http:
    enabled: true
    hostnames:
      - myapp.example.com
    rules:
      - matches:
          - path:
              type: PathPrefix
              value: /
        backendRefs:
          - name: "" # Auto-filled with service name
            port: 80

Deploy:

helm install myapp ygqygq2/mod-chart -f values.yaml

Example 2: HTTPS with TLS Certificate (Most Common)

Step 1: Create TLS certificate secret (choose one method):

Method A - Using cert-manager (Automatic - Recommended):

cert-manager v1.5+ 原生支持 Gateway API,可以像 Ingress 一样通过 annotation 自动管理证书。

前提:已安装 cert-manager 和配置好 ClusterIssuer(如 letsencrypt-prod)。

Method B - Using existing certificate (Manual):

# Create secret from your certificate files
kubectl create secret tls myapp-tls-cert \
  --cert=path/to/tls.crt \
  --key=path/to/tls.key \
  -n default

Step 2: Create Gateway with cert-manager annotation (自动创建证书):

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: my-gateway
  namespace: default
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod # 自动管理证书
spec:
  gatewayClassName: eg
  listeners:
    - name: http
      protocol: HTTP
      port: 80
    - name: https
      protocol: HTTPS
      port: 443
      hostname: myapp.example.com # 必须指定域名
      tls:
        mode: Terminate
        certificateRefs:
          - kind: Secret
            name: myapp-tls-cert # cert-manager 会自动创建这个 Secret

cert-manager 会自动:

  • 为 Gateway 的 HTTPS listener 创建 Certificate 资源
  • 申请 Let's Encrypt 证书
  • 创建 myapp-tls-cert Secret
  • 自动续期证书

Step 3: Deploy with HTTPRoute that uses HTTPS:

gateway:
  enabled: true
  gatewayClassName: my-gateway
  namespace: default
  http:
    enabled: true
    hostnames:
      - myapp.example.com
    rules:
      - matches:
          - path:
              type: PathPrefix
              value: /
        backendRefs:
          - name: ""
            port: 80

Deploy:

kubectl apply -f gateway.yaml
helm install myapp ygqygq2/mod-chart -f values.yaml

Access via HTTPS:

curl https://myapp.example.com

Note: The HTTPRoute automatically works for both HTTP (port 80) and HTTPS (port 443) listeners in the Gateway.

Example 3: HTTPS with HTTP to HTTPS Redirect (Production Best Practice)

Automatically redirect all HTTP traffic to HTTPS:

gateway:
  enabled: true
  gatewayClassName: my-gateway
  namespace: default
  http:
    enabled: true
    hostnames:
      - myapp.example.com
    rules:
      # Rule 1: Redirect HTTP to HTTPS
      - matches:
          - path:
              type: PathPrefix
              value: /
        filters:
          - type: RequestRedirect
            requestRedirect:
              scheme: https
              port: 443
              statusCode: 301 # Permanent redirect

Create a second HTTPRoute for HTTPS traffic (or use a separate chart release):

# Create a separate values file for HTTPS route
cat > values-https.yaml <<EOF
gateway:
  enabled: true
  gatewayClassName: my-gateway
  namespace: default
  http:
    enabled: true
    hostnames:
      - myapp.example.com
    rules:
      - matches:
          - path:
              type: PathPrefix
              value: /
        backendRefs:
          - name: myapp  # Reference the main service
            port: 80
EOF

# Install HTTP redirect route
helm install myapp-redirect ygqygq2/mod-chart -f values.yaml

# Install HTTPS route
helm install myapp ygqygq2/mod-chart -f values-https.yaml

Or use a combined configuration:

gateway:
  enabled: true
  gatewayClassName: my-gateway
  namespace: default
  http:
    enabled: true
    hostnames:
      - myapp.example.com
    rules:
      # Serve both HTTP and HTTPS (Gateway handles redirect if configured)
      - matches:
          - path:
              type: PathPrefix
              value: /
        backendRefs:
          - name: ""
            port: 80

Then configure redirect at Gateway level using Gateway implementation-specific annotations.

Example 4: Canary Deployment (Traffic Splitting)

Route 90% traffic to stable version, 10% to canary:

gateway:
  enabled: true
  gatewayClassName: my-gateway
  http:
    enabled: true
    hostnames:
      - myapp.example.com
    rules:
      - matches:
          - path:
              type: PathPrefix
              value: /
        backendRefs:
          - name: "" # Stable version
            port: 80
            weight: 90
          - name: myapp-canary # Canary version
            port: 80
            weight: 10

Example 3: HTTP to HTTPS Redirect

gateway:
  enabled: true
  gatewayClassName: my-gateway
  http:
    enabled: true
    hostnames:
      - myapp.example.com
    rules:
      - matches:
          - path:
              type: PathPrefix
              value: /
        filters:
          - type: RequestRedirect
            requestRedirect:
              scheme: https
              port: 443
              statusCode: 301

Example 5: Header-Based Routing

Route API v1 and v2 to different backends:

gateway:
  enabled: true
  gatewayClassName: my-gateway
  http:
    enabled: true
    hostnames:
      - api.example.com
    rules:
      # API v1
      - matches:
          - path:
              type: PathPrefix
              value: /api
            headers:
              - type: Exact
                name: X-API-Version
                value: "1.0"
        backendRefs:
          - name: api-v1
            port: 80
      # API v2
      - matches:
          - path:
              type: PathPrefix
              value: /api
            headers:
              - type: Exact
                name: X-API-Version
                value: "2.0"
        backendRefs:
          - name: api-v2
            port: 80

Example 6: gRPC Service

Example 6: gRPC Service

gateway:
  enabled: true
  gatewayClassName: my-gateway
  grpc:
    enabled: true
    hostnames:
      - grpc.example.com
    rules:
      - matches:
          - method:
              type: Exact
              service: com.example.UserService
              method: GetUser
        backendRefs:
          - name: ""
            port: 50051

Using Traditional Ingress (Legacy)

Example 1: Simple HTTP with NGINX Ingress

ingress:
  enabled: true
  ingressClassName: nginx
  hostname: myapp.example.com
  path: /
  pathType: Prefix

Deploy:

helm install myapp ygqygq2/mod-chart -f values.yaml

Example 2: HTTPS with cert-manager (Most Common)

前提:已安装 cert-manager 和配置好 ClusterIssuer(如 letsencrypt-prod)。

Deploy with cert-manager annotations:

ingress:
  enabled: true
  ingressClassName: nginx
  hostname: myapp.example.com
  path: /
  pathType: Prefix
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
  tls: true

Deploy:

helm install myapp ygqygq2/mod-chart -f values.yaml

cert-manager will automatically create the TLS certificate and the ingress will serve HTTPS traffic.

Example 3: HTTPS with existing certificate

Step 1: Create TLS secret:

kubectl create secret tls myapp-tls-cert \
  --cert=path/to/tls.crt \
  --key=path/to/tls.key \
  -n default

Step 2: Deploy with TLS secret:

ingress:
  enabled: true
  ingressClassName: nginx
  hostname: myapp.example.com
  path: /
  pathType: Prefix
  tls: true
  secrets:
    - name: myapp-tls-cert
      certificate: "" # Already created above
      key: ""

Deploy:

helm install myapp ygqygq2/mod-chart -f values.yaml

Uninstalling the Chart

To uninstall/delete the my-release deployment:

$ helm delete my-release

The command removes all the Kubernetes components associated with the chart and deletes the release.

Parameters

Global parameters

NameDescriptionValue
global.imageRegistryGlobal Docker image registry""
global.imagePullSecretsGlobal Docker registry secret names as an array[]
global.storageClassGlobal StorageClass for Persistent Volume(s)""

Common parameters

NameDescriptionValue
nameOverrideString to partially override nginx.fullname template (will maintain the release name)""
fullnameOverrideString to fully override nginx.fullname template""
kubeVersionForce target Kubernetes version (using Helm capabilities if not set)""
clusterDomainKubernetes Cluster Domaincluster.local
extraDeployExtra objects to deploy (value evaluated as a template)[]
commonLabelsAdd labels to all the deployed resources{}
commonAnnotationsAdd annotations to all the deployed resources{}

mod-chart parameters

NameDescriptionValue
image.registrymod-chart image registrydocker.io
image.repositorymod-chart image repositorybitnami/nginx
image.tagmod-chart image tag (immutable tags are recommended)latest
image.digestImage digest in the way sha256:aa.... Please note this parameter, if set, will override the tag""
image.pullPolicymod-chart image pull policyIfNotPresent
image.pullSecretsSpecify docker-registry secret names as an array[]
image.debugSet to true if you would like to see extra information on logsfalse
hostAliasesDeployment pod host aliases[]
commandOverride default container command (useful when using custom images)[]
argsOverride default container args (useful when u

Deploy mod-chart with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has mod-chart 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 chartmod-chart is pinned at v5.1.0 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