Skip to content
This repository was archived by the owner on Feb 22, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions stable/kong/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
14 changes: 14 additions & 0 deletions stable/kong/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
description: Kong is open-source API Gateway and Microservices Management Layer,
delivering high performance and reliability.
engine: gotpl
home: https://getkong.org/
icon: https://s3.amazonaws.com/downloads.kong/universe/assets/icon-kong-inc-large.png
maintainers:
- name: shashiranjan84
email: shashi@konghq.com
name: kong
sources:
- https://github.com/Kong/kong
version: 0.1.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add appVersion field.

appVersion: 0.12.1
123 changes: 123 additions & 0 deletions stable/kong/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
## Kong

[Kong](https://getkong.org/) is an open-source API Gateway and Microservices
Management Layer, delivering high performance and reliability.

## TL;DR;

```bash
$ helm install stable/kong
```

## Introduction

This chart bootstraps all the components needed to run Kong on a [Kubernetes](http://kubernetes.io)
cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.8+ with Beta APIs enabled.
- PV provisioner support in the underlying infrastructure if persistence
is needed for Kong datastore.

## Installing the Chart

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

```bash
$ helm install --name my-release stable/kong
```

> **Tip**: List all releases using `helm list`

## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```bash
$ helm delete my-release
```

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

## Configuration

### General Configuration Parameters

The following tables lists the configurable parameters of the Kong chart
and their default values.

| Parameter | Description | Default |
| ------------------------------ | -------------------------------------------------------------------- | ------------------- |
| image.repository | Kong image | `kong` |
| image.tag | Kong image version | `0.11.2` |
| image.pullPolicy | Image pull policy | `IfNotPresent` |
| replicaCount | Kong instance count | `1` |
| admin.http.servicePort | TCP port on which the Kong admin service is exposed | `8001` |
| admin.https.servicePort | Secure TCP port on which the Kong admin service is exposed | `8444` |
| admin.http.containerPort | TCP port on which Kong app listens for admin traffic | `8001` |
| admin.https.containerPort | Secure TCP port on which Kong app listens for admin traffic | `8444` |
| admin.nodePort | Node port when service type is `NodePort` | `32444` |
| admin.type | k8s service type, Options: NodePort, ClusterIP, LoadBalancer | `NodePort` |
| admin.loadBalancerIP | Will reuse an existing ingress static IP for the admin service | `null` |
| proxy.http.servicePort | TCP port on which the Kong proxy service is exposed | `8000` |
| proxy.https.servicePort | Secure TCP port on which the Kong Proxy Service is exposed | `8443` |
| proxy.http.containerPort | TCP port on which the Kong app listens for Proxy traffic | `8000` |
| proxy.https.containerPort | Secure TCP port on which the Kong app listens for Proxy traffic | `8443` |
| proxy.nodePort | Node port when service type is `NodePort` | `32443` |
| proxy.type | k8s service type. Options: NodePort, ClusterIP, LoadBalancer | `NodePort` |
| proxy.loadBalancerIP | To reuse an existing ingress static IP for the admin service | |
| env | Additional [Kong configurations](https://getkong.org/docs/latest/configuration/) |
| runMigrations | Run Kong migrations job | `true` |
| readinessProbe | Kong readiness probe | |
| livenessProbe | Kong liveness probe | |
| affinity | Node/pod affinities | |
| nodeSelector | Node labels for pod assignment | `{}` |
| podAnnotations | Annotations to add to each pod | `{}` |
| resources | Pod resource requests & limits | `{}` |
| tolerations | List of node taints to tolerate | `[]` |

### Kong-specific parameters

Kong has a choice of either Postgres or Cassandra as a backend datatstore.
This chart allows you to choose either of them with the `env.database`
parameter. Postgres is chosen by default.

Additionally, this chart allows you to use your own database or spin up a new
instance by using the `postgres.enabled` or `cassandra.enabled` parameters.
Enabling both will create both databases in your cluster, but only one
will be used by Kong based on the `env.database` parameter.
Postgres is enabled by default.

| Parameter | Description | Default |
| ------------------------------ | -------------------------------------------------------------------- | ------------------- |
| cassandra.enabled | Spin up a new cassandra cluster for Kong | `false` |
| postgres.enabled | Spin up a new postgres instance for Kong | `true ` |
| env.database | Choose either `postgres` or `cassandra` | `postgres` |
| env.pg_user | Postgres username | `kong` |
| env.pg_database | Postgres database name | `kong` |
| env.pg_password | Postgres database password (required if you are using your own database)| `kong` |
| env.pg_host | Postgres database host (required if you are using your own database) | `` |
| env.pg_port | Postgres database port | `5432` |
| env.cassandra_contact_points | Cassandra contact points (required if you are using your own database) | `` |
| env.cassandra_port | Cassandra query port | `9042` |
| env.cassandra_keyspace | Cassandra keyspace | `kong` |
| env.cassandra_repl_factor | Replication factor for the Kong keyspace | `2` |

For complete list of Kong configurations please check https://getkong.org/docs/0.11.x/configuration/.

Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

```console
$ helm install stable/kong --name my-release \
--set=image.tag=0.11.2,database.type=caasandra,cassandra.enabled=true
```

Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,

```console
$ helm install stable/kong --name my-release -f values.yaml
```

> **Tip**: You can use the default [values.yaml](values.yaml)
9 changes: 9 additions & 0 deletions stable/kong/requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: postgresql
repository: https://kubernetes-charts.storage.googleapis.com/
version: 0.8.5
- name: cassandra
repository: https://kubernetes-charts-incubator.storage.googleapis.com/
version: 0.1.9
digest: sha256:260f7cb6e0ada4190711d6bd8bff23a97bdcab3e1f0f2802270513644dd96172
generated: 2017-12-25T22:52:53.50321-08:00
9 changes: 9 additions & 0 deletions stable/kong/requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: postgresql
version: ~0.8.3
repository: https://kubernetes-charts.storage.googleapis.com/
condition: postgresql.enabled
- name: cassandra
version: ~0.1.6
repository: https://kubernetes-charts-incubator.storage.googleapis.com/
condition: cassandra.enabled
64 changes: 64 additions & 0 deletions stable/kong/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
1. Kong Admin can be accessed inside the cluster using:
DNS={{ template "kong.fullname" . }}-admin.{{ .Release.Namespace }}.svc.cluster.local
{{- if .Values.admin.https }}
PORT={{ .Values.admin.https.servicePort }}
{{- else if .Values.admin.http }}
PORT={{ .Values.admin.http.servicePort }}
{{- end }}


To connect from outside the K8s cluster:
{{- if contains "LoadBalancer" .Values.admin.type }}
HOST=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "kong.fullname" . }}-admin -o jsonpath='{.status.loadBalancer.ingress.ip}')
PORT=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "kong.fullname" . }}-admin -o jsonpath='{.spec.ports[0].nodePort}')

{{- else if contains "NodePort" .Values.admin.type }}
HOST=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath='{.items[0].status.addresses[0].address}')
PORT=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "kong.fullname" . }}-admin -o jsonpath='{.spec.ports[0].nodePort}')

{{- else if contains "ClusterIP" .Values.admin.type }}
HOST=127.0.0.1

{{- if .Values.admin.https }}
# Execute the following commands to route the connection to Admin SSL port:
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "release={{ .Release.Name }}, app={{ template "kong.name" . }}" -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward $POD_NAME {{ .Values.admin.https.servicePort }}:{{ .Values.admin.https.servicePort }}
{{- else if .Values.admin.http }}
# Execute the following commands to route the connection to Admin port:
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "release={{ .Release.Name }}, app={{ template "kong.name" . }}" -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward $POD_NAME {{ .Values.admin.http.servicePort }}:{{ .Values.admin.http.servicePort }}
{{- end }}
{{- end }}


2. Kong Proxy can be accessed inside the cluster using:
DNS={{ template "kong.fullname" . }}-proxy.{{ .Release.Namespace }}.svc.cluster.local
{{- if .Values.proxy.https }}
PORT={{ .Values.proxy.https.servicePort }}
{{- else if .Values.proxy.http }}
PORT={{ .Values.proxy.http.servicePort }}
{{- end }}


To connect from outside the K8s cluster:
{{- if contains "LoadBalancer" .Values.proxy.type }}
HOST=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "kong.fullname" . }}-proxy -o jsonpath='{.status.loadBalancer.ingress.ip}')
PORT=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "kong.fullname" . }}-proxy -o jsonpath='{.spec.ports[0].nodePort}')

{{- else if contains "NodePort" .Values.proxy.type }}
HOST=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath='{.items[0].status.addresses[0].address}')
PORT=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "kong.fullname" . }}-proxy -o jsonpath='{.spec.ports[0].nodePort}')

{{- else if contains "ClusterIP" .Values.proxy.type }}
HOST=127.0.0.1

{{- if .Values.proxy.https }}
# Execute the following commands to route the connection to proxy SSL port:
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "release={{ .Release.Name }}, app={{ template "kong.name" . }}" -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward $POD_NAME {{ .Values.proxy.https.servicePort }}:{{ .Values.proxy.https.servicePort }}
{{- else if .Values.proxy.http }}
# Execute the following commands to route the connection to proxy port:
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "release={{ .Release.Name }}, app={{ template "kong.name" . }}" -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward $POD_NAME {{ .Values.proxy.http.servicePort }}:{{ .Values.proxy.http.servicePort }}
{{- end }}
{{- end }}
24 changes: 24 additions & 0 deletions stable/kong/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}

{{- define "kong.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "kong.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "kong.postgresql.fullname" -}}
{{- $name := default "postgresql" .Values.postgresql.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "kong.cassandra.fullname" -}}
{{- $name := default "cassandra" .Values.cassandra.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
100 changes: 100 additions & 0 deletions stable/kong/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: "{{ template "kong.fullname" . }}"
labels:
app: "{{ template "kong.name" . }}"
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "kong.name" . }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add release label to selector.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

release: {{ .Release.Name }}
template:
metadata:
{{- if .Values.podAnnotations }}
annotations:
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
labels:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only app and release labels should go here.

app: {{ template "kong.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ template "kong.name" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: KONG_ADMIN_LISTEN
value: 0.0.0.0:{{ default 8001 .Values.admin.http.containerPort }}
- name: KONG_ADMIN_LISTEN_SSL
value: 0.0.0.0:{{ default 8444 .Values.admin.https.containerPort }}
- name: KONG_PROXY_LISTEN
value: 0.0.0.0:{{ default 8000 .Values.proxy.http.containerPort }}
- name: KONG_PROXY_LISTEN_SSL
value: 0.0.0.0:{{ default 8443 .Values.proxy.https.containerPort }}
- name: KONG_NGINX_DAEMON
value: "off"
- name: KONG_PROXY_ACCESS_LOG
value: "/dev/stdout"
- name: KONG_ADMIN_ACCESS_LOG
value: "/dev/stdout"
- name: KONG_PROXY_ERROR_LOG
value: "/dev/stderr"
- name: KONG_ADMIN_ERROR_LOG
value: "/dev/stderr"
{{- range $key, $val := .Values.env }}
- name: KONG_{{ $key | upper}}
value: {{ $val | quote }}
{{- end}}
{{- if .Values.postgresql.enabled }}
- name: KONG_PG_HOST
value: {{ template "kong.postgresql.fullname" . }}
- name: KONG_PG_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "kong.postgresql.fullname" . }}
key: postgres-password
{{- end }}
{{- if .Values.cassandra.enabled }}
- name: KONG_CASSANDRA_CONTACT_POINTS
value: {{ template "kong.cassandra.fullname" . }}
{{- end }}
ports:
{{- if .Values.admin.https }}
- name: admin-ssl
containerPort: {{ .Values.admin.https.containerPort }}
protocol: TCP
{{- else if .Values.admin.http }}
- name: admin
containerPort: {{ .Values.admin.http.containerPort }}
protocol: TCP
{{ end }}
{{- if .Values.proxy.https }}
- name: proxy-ssl
containerPort: {{ .Values.proxy.https.containerPort }}
protocol: TCP
{{- else if .Values.proxy.http }}
- name: proxy
containerPort: {{ .Values.proxy.http.containerPort }}
protocol: TCP
{{- end }}
readinessProbe:
{{ toYaml .Values.readinessProbe | indent 10 }}
livenessProbe:
{{ toYaml .Values.livenessProbe | indent 10 }}
resources:
{{ toYaml .Values.resources | indent 10 }}
{{- if .Values.affinity }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
Loading