Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: REL-955 Add rest-gateway #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ This is a public Helm repository for [Aerospike](https://aerospike.com/) product
The following helm charts are provided

- [Aerospike Kafka Outbound](aerospike-kafka-outbound)
- [Aerospike Point in Time Recovery](aerospike-point-in-time-recovery)
- [Aerospike Point in Time Recovery](aerospike-point-in-time-recovery)
- [Aerospike REST Gateway](aerospike-rest-gateway)
9 changes: 9 additions & 0 deletions aerospike-rest-gateway/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: aerospike-rest-gateway
description: Helm Chart For Aerospike REST Gateway On Kubernetes
version: 0.1.0
icon: https://avatars0.githubusercontent.com/u/2214313?s=200&v=4
sources:
- https://github.com/aerospike/helm-charts
type: application
appVersion: 2.1.1
123 changes: 123 additions & 0 deletions aerospike-rest-gateway/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Helm chart for Aerospike REST Gateway on Kubernetes

Implements Aerospike REST Gateway deployment on Kubernetes

## Usage

### Add Aerospike repository

```shell
helm repo add aerospike https://aerospike.github.io/helm-charts
```

### Install the chart

```shell
helm install rest-gateway aerospike/aerospike-rest-gateway --set config.hostname=<aerospike_hostname>
```

## Configuration


### Connect to Aerospike cluster

#### Specify aerospike cluster seed IP or hostname and port

```shell
helm install rest-gateway aerospike/aerospike-rest-gateway \
--set config.hostname=demo-aerospike-enterprise \
--set config.port=3000
```

#### Specify username and password (for security enabled clusters)

```shell
helm install rest-gateway aerospike/aerospike-rest-gateway \
--set config.hostname=demo-aerospike-enterprise \
--set config.port=3000 \
--set config.user=superman \
--set config.password=krypton
```

#### Specify cluster name (if applicable)
```shell
--set config.clusterName=demo-aerospike-enterprise
```


### Expose REST client deployment

#### Using NodePort type service

Aerospike REST client can be exposed for external access using NodePort type services.

Set `service.type=NodePort` to expose REST client via a `NodePort`.

Applications can access REST client endpoint at `<K8sNodeIP>:<NodePort>`.

#### Using LoadBalancer type service

Aerospike REST client can be exposed for external access using Load balancers.

Set `service.type=LoadBalancer` to expose REST client via a network load balancer.

Applications can access REST client endpoint at `<LoadBalancerIP>:<LoadBalancerPort>`

#### Using Ingress

Aerospike REST client can be exposed for external access using ingress.

- Set `ingress.enabled=true`,
- Specify `ingress.annotations`, `ingress.rules` and `ingress.tls` configuration.

For example (using `nginx` controller),
```yaml
# Ingress resource settings
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: "false"
rules: []
- paths:
- '/'
# host: rest.aerospike.com
tls: []
# - secretName: rest-gateway-tls
# hosts:
# - rest.aerospike.com
```

Applications can access REST client endpoint at the specified url (or `host`) in the `rules` or at the external IP of ingress controller (loadbalancer).


## Configuration parameters and default values

| Parameter | Description| Default Value |
|:----------|:----------:|:-------------:|
| `replicaCount` | Number of replicas for the Aerospike REST client deployment | `1` |
| `image.repository` | Aerospike REST client docker image repository | `aerospike/aerospike-rest-gateway` |
| `image.tag` | Aerospike REST client docker image tag | `latest` |
| `config.hostname` | Aerospike cluster Seed IP address to connect to | `127.0.0.1` |
| `config.port` | Aerospike cluster Seed Port | `3000` |
| `config.user` | Username for access control to connect to the aerospike cluster | `""` |
| `config.password` | Password for access control to connect to the aerospike cluster | `""` |
| `config.clusterName` | Cluster name defined for the aerospike cluster | `""` |
| `config.requireAuthentication` | Require the Basic Authentication on each request | `false` |
| `config.poolSize` | Represents the max size of the clients LRU cache | `16` |
| `serviceAccount.create` | Create and use a serviceAccount for the deployment | `true` |
| `serviceAccount.annotations` | Annotations for the serviceAccount resource | `{} (nil)` |
| `serviceAccount.name` | ServiceAccount name whether to be created or already exists | `true` |
| `podSecurityContext` | Pod security context | `{} (nil)` |
| `securityContext` | Container security context | `{} (nil)` |
| `containerPort` | Aerospike REST client deployment container port | `8080` |
| `service.type` | Type of service to access REST client deployment | `ClusterIP` |
| `service.port` | Port for the service to access REST client deployment | `8080` |
| `ingress.enabled` | Enable Ingress resource | `false` |
| `ingress.annotations` | Annotations for Ingress resource | `{} (nil)` |
| `ingress.rules` | Rules for Ingress resource | `[] (nil)` |
| `ingress.tls` | TLS configuration for Ingress resource | `[] (nil)` |
| `resources` | Resources and Limits for REST client Deployment | `{} (nil)` |
| `nodeSelector` | Specify node selectors labels for Pod scheduling | `{} (nil)` |
| `tolerations` | Define tolerations and taints for Pod scheduling and execution | `[] (nil)` |
| `affinity` | Define pod and node affinity and antiAffinity | `{} (nil)` |
Empty file.
27 changes: 27 additions & 0 deletions aerospike-rest-gateway/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
_ _ _ ____ _____ ____ _____ _ _ _
/ \ ___ _ __ ___ ___ _ __ (_) | _____ | _ \| ____/ ___|_ _| ___| (_) ___ _ __ | |_
/ _ \ / _ \ '__/ _ \/ __| '_ \| | |/ / _ \ | |_) | _| \___ \ | | / __| | |/ _ \ '_ \| __|
/ ___ \ __/ | | (_) \__ \ |_) | | < __/ | _ <| |___ ___) || | | (__| | | __/ | | | |_
/_/ \_\___|_| \___/|___/ .__/|_|_|\_\___| |_| \_\_____|____/ |_| \___|_|_|\___|_| |_|\__|
|_|
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "aerospike-rest-gateway.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "aerospike-rest-gateway.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "aerospike-rest-gateway.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "aerospike-rest-gateway.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080/swagger-ui.html to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:8080
{{- end }}
63 changes: 63 additions & 0 deletions aerospike-rest-gateway/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "aerospike-rest-gateway.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
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).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "aerospike-rest-gateway.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "aerospike-rest-gateway.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "aerospike-rest-gateway.labels" -}}
helm.sh/chart: {{ include "aerospike-rest-gateway.chart" . }}
{{ include "aerospike-rest-gateway.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Selector labels
*/}}
{{- define "aerospike-rest-gateway.selectorLabels" -}}
app.kubernetes.io/name: {{ include "aerospike-rest-gateway.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "aerospike-rest-gateway.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "aerospike-rest-gateway.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
79 changes: 79 additions & 0 deletions aerospike-rest-gateway/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "aerospike-rest-gateway.fullname" . }}
labels:
{{- include "aerospike-rest-gateway.labels" . | nindent 4 }}
release: {{ .Release.Name }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "aerospike-rest-gateway.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "aerospike-rest-gateway.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "aerospike-rest-gateway.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: AEROSPIKE_RESTCLIENT_HOSTNAME
value: {{ quote .Values.config.hostname }}
- name: AEROSPIKE_RESTCLIENT_PORT
value: {{ quote .Values.config.port }}
- name: AEROSPIKE_RESTCLIENT_CLIENTPOLICY_USER
value: {{ quote .Values.config.user }}
- name: AEROSPIKE_RESTCLIENT_CLIENTPOLICY_PASSWORD
value: {{ quote .Values.config.password }}
- name: AEROSPIKE_RESTCLIENT_CLIENTPOLICY_CLUSTERNAME
value: {{ quote .Values.config.clusterName }}
- name: AEROSPIKE_RESTCLIENT_REQUIREAUTHENTICATION
value: {{ quote .Values.config.requireAuthentication }}
- name: AEROSPIKE_RESTCLIENT_POOL_SIZE
value: {{ quote .Values.config.poolSize }}
ports:
- name: http
containerPort: {{ .Values.containerPort | default 8080 }}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
# Delay livenessProbe by 10s at startup
initialDelaySeconds: 10
# Perform livenessProbe check every 10s (default)
periodSeconds: 10
readinessProbe:
httpGet:
path: /
port: http
# Delay readiness check by 10s at startup
initialDelaySeconds: 10
# Perform readiness check every 10s (default)
periodSeconds: 10
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
38 changes: 38 additions & 0 deletions aerospike-rest-gateway/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- if .Values.ingress.enabled -}}
{{- $dot := . }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ include "aerospike-rest-gateway.fullname" . }}
{{- with .Values.ingress.annotations }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "aerospike-rest-gateway.labels" . | nindent 4 }}
release: {{ .Release.Name }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range $tls := .Values.ingress.tls }}
- hosts:
{{- range $host := $tls.hosts }}
- {{ $host | quote }}
{{- end }}
secretName: {{ $tls.secretName }}
{{- end }}
{{- end }}
rules:
{{- range $rule := .Values.ingress.rules }}
- http:
paths:
{{- range $path := $rule.paths }}
- path: {{ $path | quote }}
backend:
serviceName: {{ include "aerospike-rest-gateway.fullname" $dot }}
servicePort: {{ $.Values.service.port }}
{{- end }}
{{- if $rule.host }}
host: $rule.host
{{- end }}
{{- end }}
{{- end }}
16 changes: 16 additions & 0 deletions aerospike-rest-gateway/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "aerospike-rest-gateway.fullname" . }}
labels:
{{- include "aerospike-rest-gateway.labels" . | nindent 4 }}
release: {{ .Release.Name }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "aerospike-rest-gateway.selectorLabels" . | nindent 4 }}
13 changes: 13 additions & 0 deletions aerospike-rest-gateway/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "aerospike-rest-gateway.serviceAccountName" . }}
labels:
{{- include "aerospike-rest-gateway.labels" . | nindent 4 }}
release: {{ .Release.Name }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}
Loading