Skip to content

Deploying GPTS on Kubernetes cluster via Helm

Prerequisites

In order to proceed, you must prepare following prerequisites:

  • Kubernetes cluster (tested with Kubernetes bundled with Docker Desktop);
  • Helm 3 (although there's a slight possibility that Helm 2 will also work);
  • Ingress controller (optional; tested with NGINX Ingress Controller);
  • Internet connection available.

Configuring repository

In order to obtain Helm chart of GPTS, you need to configure proper repository. You can do it by executing following commands:

helm repo add icikowski https://charts.icikowski.pl
helm repo update

Fetching chart from repository

After repository is successfully added, you can check for available versions of gpts chart:

helm search repo gpts
Example command output
NAME            CHART VERSION   APP VERSION     DESCRIPTION
icikowski/gpts  0.7.2           0.7.2           GPTS - General Purpose Test Service
helm search repo gpts -l
Example command output
NAME            CHART VERSION   APP VERSION     DESCRIPTION
icikowski/gpts  0.7.2           0.7.2           GPTS - General Purpose Test Service
icikowski/gpts  0.7.1           0.7.1           GPTS - General Purpose Test Service
icikowski/gpts  0.7.0           0.7.0           GPTS - General Purpose Test Service

In order to fetch chart, execute one of following commands:

helm fetch icikowski/gpts
helm fetch icikowski/gpts --untar
# For example: chart version 0.7.2
helm fetch icikowski/gpts --version 0.7.2
# For example: chart version 0.7.2
helm fetch icikowski/gpts --version 0.7.2 --untar

Downloading chart directly

It is also possible to download charts manually from chart repository, eg. for offline use.

Changing configuration values in chart

GPTS settings are configured with environment variables described here and can be set using following values:

Option name Chart value Environment variable Default value
Service port gpts.servicePort GPTS_SERVICE_PORT 8080
Healthchecks port gpts.healthchecksPort GPTS_HEALTHCHECKS_PORT 8081
Configuration endpoint gpts.configEndpoint GPTS_CONFIG_ENDPOINT /config
Default configuration on startup gpts.defaultConfigOnStartup GPTS_DEFAULT_CONFIG_ON_STARTUP false
Log level gpts.logLevel GPTS_LOG_LEVEL info
Pretty logging gpts.prettyLog GPTS_PRETTY_LOG false
Example contents of gpts section in values.yaml
15
16
17
18
19
20
21
gpts:
  servicePort: 8080
  healthchecksPort: 8081
  configEndpoint: /config
  defaultConfigOnStartup: false
  logLevel: info
  prettyLog: false

In order to configure chart before deployment (eg. enable ingress, change service type), you need to change values in values.yaml file inside chart's directory.

Example: enabling ingress for NGINX ingress class
31
32
33
34
35
36
37
38
39
40
41
42
43
ingress:
  enabled: false
  annotations: {}
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  hosts:
  - host: example.com
    paths:
    - path: /
  tls: []
  #  - secretName: chart-example-tls
  #    hosts:
  #    - example.com
31
32
33
34
35
36
37
38
39
40
41
42
43
ingress:
  enabled: true
  annotations:
    kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  hosts:
  - host: test0.host.net
    paths:
    - path: /
  tls: []
  #  - secretName: chart-example-tls
  #    hosts:
  #    - chart-example.local

Deploying chart on cluster

As the chart is prepared, you can install it on your cluster. First of all, let's prepare a namespace for deployment:

kubectl create ns NAMESPACE
Example command execution & output

kubectl create ns test-service
namespace/test-service created

The last step is the actual deployment:

helm install -n NAMESPACE DEPLOYMENT_NAME CHART_DIRECTORY
Example command execution & output

helm install -n test-service my-service ./gpts
NAME: my-service
LAST DEPLOYED: Fri Oct  1 18:13:34 2021
NAMESPACE: test-service
STATUS: deployed
REVISION: 1
NOTES:
GPTS - General Purpose Test Service

Service installed successfully! Check out the documentation (https://icikowski.github.io/GPTS) and start using the app.

Get the application URL by running these commands:
  http://test0.host.net/

Application is up and running now! You can check it by cURLing the ingress address (if you enabled it in values.yaml).

Example command execution & output (JSON format; default)

curl -s http://test0.host.net | jq
{
    "host": "test0.host.net",
    "path": "/",
    "method": "GET",
    "headers": {
        "Accept": "*/*",
        "User-Agent": "curl/7.79.1",
        "X-Forwarded-For": "192.168.65.3",
        "X-Forwarded-Host": "test0.host.net",
        "X-Forwarded-Port": "80",
        "X-Forwarded-Proto": "http",
        "X-Forwarded-Scheme": "http",
        "X-Real-Ip": "192.168.65.3",
        "X-Request-Id": "b08e79506d17797a0f890fea0579978e",
        "X-Scheme": "http"
    },
    "queries": {}
}

Example command execution & output (YAML format)

curl -s http://test0.host.net -H "Accept: text/yaml" | yq eval -
host: test0.host.net
path: /
method: GET
headers:
  Accept: text/yaml
  User-Agent: curl/7.79.1
  X-Forwarded-For: 192.168.65.3
  X-Forwarded-Host: test0.host.net
  X-Forwarded-Port: "80"
  X-Forwarded-Proto: http
  X-Forwarded-Scheme: http
  X-Real-Ip: 192.168.65.3
  X-Request-Id: be588ef84375e7207cdf8c1c9acfe731
  X-Scheme: http
queries: {}


Last update: 2022-03-06