diff --git a/README.md b/README.md index dc73f7e..054858a 100644 --- a/README.md +++ b/README.md @@ -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) \ No newline at end of file +- [Aerospike Point in Time Recovery](aerospike-point-in-time-recovery) +- [Aerospike REST Gateway](aerospike-rest-gateway) \ No newline at end of file diff --git a/aerospike-rest-gateway/Chart.yaml b/aerospike-rest-gateway/Chart.yaml new file mode 100644 index 0000000..b45fcde --- /dev/null +++ b/aerospike-rest-gateway/Chart.yaml @@ -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 diff --git a/aerospike-rest-gateway/README.md b/aerospike-rest-gateway/README.md new file mode 100644 index 0000000..ac1f2b5 --- /dev/null +++ b/aerospike-rest-gateway/README.md @@ -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= +``` + +## 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 `:`. + +#### 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 `:` + +#### 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)` | diff --git a/aerospike-rest-gateway/charts/.gitkeep b/aerospike-rest-gateway/charts/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/aerospike-rest-gateway/templates/NOTES.txt b/aerospike-rest-gateway/templates/NOTES.txt new file mode 100644 index 0000000..b6df156 --- /dev/null +++ b/aerospike-rest-gateway/templates/NOTES.txt @@ -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 }} diff --git a/aerospike-rest-gateway/templates/_helpers.tpl b/aerospike-rest-gateway/templates/_helpers.tpl new file mode 100644 index 0000000..138e5f2 --- /dev/null +++ b/aerospike-rest-gateway/templates/_helpers.tpl @@ -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 -}} diff --git a/aerospike-rest-gateway/templates/deployment.yaml b/aerospike-rest-gateway/templates/deployment.yaml new file mode 100644 index 0000000..c2c6dd9 --- /dev/null +++ b/aerospike-rest-gateway/templates/deployment.yaml @@ -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 }} diff --git a/aerospike-rest-gateway/templates/ingress.yaml b/aerospike-rest-gateway/templates/ingress.yaml new file mode 100644 index 0000000..e67bfce --- /dev/null +++ b/aerospike-rest-gateway/templates/ingress.yaml @@ -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 }} \ No newline at end of file diff --git a/aerospike-rest-gateway/templates/service.yaml b/aerospike-rest-gateway/templates/service.yaml new file mode 100644 index 0000000..5ae8312 --- /dev/null +++ b/aerospike-rest-gateway/templates/service.yaml @@ -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 }} diff --git a/aerospike-rest-gateway/templates/serviceaccount.yaml b/aerospike-rest-gateway/templates/serviceaccount.yaml new file mode 100644 index 0000000..514484e --- /dev/null +++ b/aerospike-rest-gateway/templates/serviceaccount.yaml @@ -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 -}} diff --git a/aerospike-rest-gateway/templates/tests/test-connection.yaml b/aerospike-rest-gateway/templates/tests/test-connection.yaml new file mode 100644 index 0000000..5653714 --- /dev/null +++ b/aerospike-rest-gateway/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "aerospike-rest-gateway.fullname" . }}-test-connection" + labels: + {{- include "aerospike-rest-gateway.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "aerospike-rest-gateway.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/aerospike-rest-gateway/values.yaml b/aerospike-rest-gateway/values.yaml new file mode 100644 index 0000000..1af662d --- /dev/null +++ b/aerospike-rest-gateway/values.yaml @@ -0,0 +1,96 @@ +# Default values for aerospike-rest-gateway. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# Number of replicas +replicaCount: 1 + +# Aerospike REST client docker image +image: + repository: aerospike/aerospike-rest-gateway + tag: latest + pullPolicy: IfNotPresent + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +# Configuration to connect to an Aerospike cluster +config: + hostname: "127.0.0.1" + port: "3000" + user: "" + password: "" + clusterName: "" + requireAuthentication: "false" + poolSize: "16" + +# Service Account to be used with REST client 'Deployment' +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: + +# Security context (pod level) +podSecurityContext: {} + # fsGroup: 2000 + +# Security context (container level) +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +# Container port where REST client listens on +containerPort: 8080 + +# Service to access REST client 'Deployment' +# service.type can be 'ClusterIP', 'NodePort' or 'LoadBalancer' +# set at default 'ClusterIP' for when using ingress +service: + type: ClusterIP + port: 8080 + +# Ingress resource settings +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # nginx.ingress.kubernetes.io/ssl-redirect: "false" + rules: [] + # - paths: + # - '/' + # host: rest.aerospike.com + tls: [] + # - secretName: rest-client-tls + # hosts: + # - rest.aerospike.com + +# Resources - limits and requests for the REST client 'Deployment' +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +# Node Selectors +nodeSelector: {} + +# Tolerations and Taints +tolerations: [] + +# Affinity rules +affinity: {} diff --git a/docs/aerospike-rest-gateway-0.1.0.tgz b/docs/aerospike-rest-gateway-0.1.0.tgz new file mode 100644 index 0000000..af2681b Binary files /dev/null and b/docs/aerospike-rest-gateway-0.1.0.tgz differ diff --git a/docs/index.yaml b/docs/index.yaml index 1201476..aa99ae1 100644 --- a/docs/index.yaml +++ b/docs/index.yaml @@ -3,7 +3,7 @@ entries: aerospike-kafka-outbound: - apiVersion: v2 appVersion: 5.0.0 - created: "2022-10-17T23:07:11.125420937+05:30" + created: "2023-06-07T15:36:43.743316-07:00" description: A Helm chart for Aerospike Connect for Kafka - Outbound digest: 46b6cff86371f5cf40c64a93eacd5eea402f9c572d4144ad50f174129479de77 icon: https://avatars0.githubusercontent.com/u/2214313?s=200&v=4 @@ -20,4 +20,18 @@ entries: urls: - https://aerospike.github.io/helm-charts/aerospike-kafka-outbound-1.0.0.tgz version: 1.0.0 -generated: "2022-10-17T23:07:11.124527788+05:30" + aerospike-rest-gateway: + - apiVersion: v2 + appVersion: 2.1.1 + created: "2023-06-07T15:36:43.743788-07:00" + description: Helm Chart For Aerospike REST Gateway On Kubernetes + digest: f056156e0895688a486bb5082c10a3551581ef5d4ad909152f955d0d1508568b + icon: https://avatars0.githubusercontent.com/u/2214313?s=200&v=4 + name: aerospike-rest-gateway + sources: + - https://github.com/aerospike/helm-charts + type: application + urls: + - https://aerospike.github.io/helm-charts/aerospike-rest-gateway-0.1.0.tgz + version: 0.1.0 +generated: "2023-06-07T15:36:43.74228-07:00"