Skip to content

Commit f792ca9

Browse files
authored
chore: add gateway helm chart (#83)
Signed-off-by: Nic <[email protected]>
1 parent d75f9b7 commit f792ca9

26 files changed

+2168
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ Detailed instructions are enrolled in the README of each chart.
66

77
## Projects
88

9-
* [api7-gateway](./charts/api7/README.md)
9+
* [api7-control-plane](./charts/api7/README.md)
10+
* [api7-gateway](./charts/gateway/README.md)

charts/gateway/.helmignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.DS_Store
2+
# Common VCS dirs
3+
.git/
4+
.gitignore
5+
.bzr/
6+
.bzrignore
7+
.hg/
8+
.hgignore
9+
.svn/
10+
# Common backup files
11+
*.swp
12+
*.bak
13+
*.tmp
14+
*.orig
15+
*~
16+
# Various IDEs
17+
.project
18+
.idea/
19+
*.tmproj
20+
.vscode/

charts/gateway/Chart.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- name: etcd
3+
repository: https://charts.bitnami.com/bitnami
4+
version: 8.7.7
5+
digest: sha256:c03ff5323e855335d94ce6cfce35745b84d03538dbb197e1a27520a7d69ea3ef
6+
generated: "2024-01-26T10:32:56.291587554+08:00"

charts/gateway/Chart.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apiVersion: v2
2+
name: gateway
3+
description: A Helm chart for API7 Gateway
4+
# A chart can be either an 'application' or a 'library' chart.
5+
#
6+
# Application charts are a collection of templates that can be packaged into versioned archives
7+
# to be deployed.
8+
#
9+
# Library charts provide useful utilities or functions for the chart developer. They're included as
10+
# a dependency of application charts to inject those utilities and functions into the rendering
11+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
12+
type: application
13+
14+
# This is the chart version. This version number should be incremented each time you make changes
15+
# to the chart and its templates, including the app version.
16+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
17+
version: 0.1.0
18+
19+
# This is the version number of the application being deployed. This version number should be
20+
# incremented each time you make changes to the application. Versions are not expected to
21+
# follow Semantic Versioning. They should reflect the version the application is using.
22+
appVersion: "3.2.0"
23+
24+
dependencies:
25+
- name: etcd
26+
version: 8.7.7
27+
repository: https://charts.bitnami.com/bitnami
28+
condition: etcd.enabled

charts/gateway/README.md

Lines changed: 205 additions & 0 deletions
Large diffs are not rendered by default.

charts/gateway/README.md.gotmpl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## API7 Gateway for Kubernetes
2+
3+
API7 Gateway is a dynamic, real-time, high-performance API gateway.
4+
5+
API7 Gateway provides rich traffic management features such as load balancing, dynamic upstream, canary release, circuit breaking, authentication, observability, and more.
6+
7+
You can use API7 Gateway to handle traditional north-south traffic, as well as east-west traffic between services.
8+
9+
This chart bootstraps all the components needed to run API7 Gateway on a Kubernetes Cluster using [Helm](https://helm.sh).
10+
11+
## Prerequisites
12+
13+
* Kubernetes v1.14+
14+
* Helm v3+
15+
16+
## Install
17+
18+
```sh
19+
helm repo add api7 https://charts.api7.ai
20+
helm repo update
21+
22+
helm install [RELEASE_NAME] api7/gateway --namespace api7 --create-namespace
23+
```
24+
25+
## Uninstall
26+
27+
```sh
28+
helm delete [RELEASE_NAME] --namespace api7
29+
```
30+
31+
The command removes all the Kubernetes components associated with the chart and deletes the release.
32+
33+
34+
## Parameters
35+
36+
{{ template "chart.valuesSection" . }}
42.6 KB
Binary file not shown.

charts/gateway/templates/NOTES.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.gateway.ingress.enabled }}
3+
{{- range $host := .Values.gateway.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.gateway.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.gateway.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "apisix.fullname" . }}-gateway)
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.gateway.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "apisix.fullname" . }}-gateway'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "apisix.fullname" . }}-gateway --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.gateway.http.servicePort }}
17+
{{- else if contains "ClusterIP" .Values.gateway.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "apisix.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
echo "Visit http://127.0.0.1:8080 to use your application"
20+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
21+
{{- end }}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "apisix.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
7+
{{- end }}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "apisix.fullname" -}}
15+
{{- if .Values.fullnameOverride }}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
17+
{{- else }}
18+
{{- $name := default .Chart.Name .Values.nameOverride }}
19+
{{- if contains $name .Release.Name }}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
21+
{{- else }}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
23+
{{- end }}
24+
{{- end }}
25+
{{- end }}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "apisix.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
32+
{{- end }}
33+
34+
{{/*
35+
Common labels
36+
*/}}
37+
{{- define "apisix.labels" -}}
38+
helm.sh/chart: {{ include "apisix.chart" . }}
39+
{{ include "apisix.selectorLabels" . }}
40+
{{- if .Chart.AppVersion }}
41+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
42+
{{- end }}
43+
app.kubernetes.io/managed-by: {{ .Release.Service }}
44+
{{- end }}
45+
46+
{{/*
47+
Selector labels
48+
*/}}
49+
{{- define "apisix.selectorLabels" -}}
50+
{{- if .Values.gateway.labelsOverride }}
51+
{{- tpl (.Values.gateway.labelsOverride | toYaml) . }}
52+
{{- else }}
53+
app.kubernetes.io/name: {{ include "apisix.name" . }}
54+
app.kubernetes.io/instance: {{ .Release.Name }}
55+
{{- end }}
56+
{{- end }}
57+
58+
{{/*
59+
Create the name of the service account to use
60+
*/}}
61+
{{- define "apisix.serviceAccountName" -}}
62+
{{- if .Values.serviceAccount.create }}
63+
{{- default (include "apisix.fullname" .) .Values.serviceAccount.name }}
64+
{{- else }}
65+
{{- default "default" .Values.serviceAccount.name }}
66+
{{- end }}
67+
{{- end }}
68+
69+
{{/*
70+
Renders a value that contains template.
71+
Usage:
72+
{{ include "apisix.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $) }}
73+
*/}}
74+
{{- define "apisix.tplvalues.render" -}}
75+
{{- if typeIs "string" .value }}
76+
{{- tpl .value .context }}
77+
{{- else }}
78+
{{- tpl (.value | toYaml) .context }}
79+
{{- end }}
80+
{{- end -}}
81+
82+
{{- define "apisix.basePluginAttrs" -}}
83+
{{- if .Values.serviceMonitor.enabled }}
84+
prometheus:
85+
export_addr:
86+
ip: 0.0.0.0
87+
port: {{ .Values.serviceMonitor.containerPort }}
88+
export_uri: {{ .Values.serviceMonitor.path }}
89+
metric_prefix: {{ .Values.serviceMonitor.metricPrefix }}
90+
{{- end }}
91+
{{- if .Values.customPlugins.enabled }}
92+
{{- range $plugin := .Values.customPlugins.plugins }}
93+
{{- if $plugin.attrs }}
94+
{{ $plugin.name }}: {{- $plugin.attrs | toYaml | nindent 2 }}
95+
{{- end }}
96+
{{- end }}
97+
{{- end }}
98+
{{- end -}}
99+
100+
{{- define "apisix.pluginAttrs" -}}
101+
{{- merge .Values.pluginAttrs (include "apisix.basePluginAttrs" . | fromYaml) | toYaml -}}
102+
{{- end -}}
103+
104+
{{/*
105+
Scheme to use while connecting etcd
106+
*/}}
107+
{{- define "apisix.etcd.auth.scheme" -}}
108+
{{- if .Values.etcd.auth.tls.enabled }}
109+
{{- "https" }}
110+
{{- else }}
111+
{{- "http" }}
112+
{{- end }}
113+
{{- end }}

0 commit comments

Comments
 (0)