Skip to content

Commit

Permalink
CONNECTOR-1088-provide-a-helm-chart-for-aerospike-proxy (#23)
Browse files Browse the repository at this point in the history
* Add aerospike-proxy helm charts
  • Loading branch information
davi17g authored Jul 22, 2024
1 parent ce193fb commit 491af0c
Show file tree
Hide file tree
Showing 26 changed files with 1,038 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
features.conf
docker-config.json
.idea/
.DS_Store
23 changes: 23 additions & 0 deletions aerospike-proxy/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions aerospike-proxy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: aerospike-proxy
description: Helm chart for Aerospike Proxy

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.1.1"
184 changes: 184 additions & 0 deletions aerospike-proxy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
# Aerospike Proxy

This helm chart sets up a `Deployment` for Aerospike Proxy.


## Prerequisites
- Kubernetes cluster
- Helm v3
- An Aerospike cluster that can connect to Pods in the Kubernetes cluster.
The Aerospike cluster can be deployed in the same Kubernetes cluster using [Aerospike Kubernetes Operator](https://docs.aerospike.com/cloud/kubernetes/operator)

## Adding the helm chart repository

Add the `aerospike` helm repository if not already done

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

## Supported configuration

### Configuration

| Parameter | Description | Default |
|---------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------|
| `replicaCount` | Configures the number Aerospike Backup Service instance pods to run. | '1' |
| `image` | Configures Aerospike Aerospike Backup Service image repository, tag and pull policy. | see [values.yaml](values.yaml) |
| `imagePullSecrets` | For Private docker registries, when authentication is needed. | see [values.yaml](values.yaml) |
| `proxyConfig` | Proxy configuration deployed to `/etc/aerospike-proxy/aerospike-proxy.yml`. | see [values.yaml](values.yaml) |
| `serviceAccount` | Service Account details like name and annotations. | see [values.yaml](values.yaml) |
| `podAnnotations` | Additional pod [annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/). Should be specified as a map of annotation names to annotation values. | `{}` |
| `podLabels` | Additional pod [labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/). Should be specified as a map of label names to label values. | `{}` |
| `podSecurityContext` | Pod [security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) | `{}` |
| `securityContext` | Container [security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) | `{}` |
| `resources` | Resource [requests and limits](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) for the proxy service pods. | `{}` |
| `autoscaling` | Enable the horizontal pod auto-scaler. | see [values.yaml](values.yaml) |
| `volumes` | List of additional volumes to attach to the proxy pod. | see [values.yaml](values.yaml) |
| `extraVolumeMounts` | Extra volume mounts corresponding to the volumes added to `extraVolumes`. | see [values.yaml](values.yaml) |
| `extraSecretVolumeMounts` | Extra secret volume mounts corresponding to the volumes added to `extraVolumes`. | see [values.yaml](values.yaml) |
| `affinity` | [Affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) rules if any for the pods. | `{}` |
| `nodeSelector` | [Node selector](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector) for the pods. | `{}` |
| `tolerations` | [Tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) for the pods. | `{}` |



## Deploy the Aerospike-Proxy

We recommend creating a new `.yaml` for providing configuration values to the helm chart for deployment.
See the [examples](examples) folder for examples.


We recommend naming the file with the name of the Aerospike Proxy service. For example if you want to name your service as
`aerospike-proxy`, create a file `aerospike-proxy-values.yaml`.
Once you have created this custom values file, deploy the Aerospike Proxy, using the following commands.

### Create a new namespace
We recommend using `aerospike` namespace for the Aerospike Proxy. If the namespace does not exist run the following command:
```shell
kubectl create namespace aerospike
```

### Create secrets

You can create additional secrets, for confidential data like TLS certificates or Aerospike cluster password these are mounted to the proxy pods as files.
The Aerospike Proxy service can then be configured to use these secrets.

### Deploy Aerospike Proxy

```shell
# helm install --namespace <target namespace> <helm release name/cluster name> -f <path to custom values yaml> aerospike/aerospike-backup-service
helm install proxy "aerospike/aerospike-proxy" \
--namespace aerospike \
--values aerospike-proxy-values.yaml \
--create-namespace \
--wait
```

Here `proxy` is the release name for the Aerospike Proxy service.

On successful deployment you should see output similar to below:

```shell
NAME: proxy
LAST DEPLOYED: Sun Jul 21 11:36:42 2024
NAMESPACE: aerospike
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace aerospike -l "app.kubernetes.io/name=aerospike-proxy,app.kubernetes.io/instance=proxy" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace aerospike $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace aerospike port-forward $POD_NAME 8080:$CONTAINER_PORT
```

## List pods for the Aerospike Proxy
To list the pods for the Aerospike Proxy service run the following command:
```shell
# kubectl get pods --namespace aerospike --selector=app=<helm release name>-aerospike-proxy
kubectl get pods --namespace aerospike --selector=app=proxy-aerospike-proxy
```

You should see output similar to the following:
```shell
NAME READY STATUS RESTARTS AGE
proxy-aerospike-proxy-f49cb67f4-llw4h 1/1 Running 0 9m3s
```

## Get logs for all Aerospike Proxy instances

```shell
# kubectl -n aerospike logs -f deployment/<helm release name>-aerospike-proxy
# Skip the -f flag to get a one time dump of the log
kubectl -n aerospike logs -f deployment/proxy-aerospike-proxy
```

## Get logs for one Aerospike Proxy pod

```shell
# kubectl -n aerospike logs -f <helm release name>-aerospike-proxy-<random-hash>
# Skip the -f flag to get a one time dump of the log
kubectl -n aerospike logs -f proxy-aerospike-proxy-f49cb67f4-llw4h
```

## Updating Aerospike Proxy configuration

Edit the `proxyConfig` section in the custom values file and save the changes.

Upgrade the Aerospike Proxy deployment using the following command.

```shell
#helm upgrade --namespace <target namespace> <helm release name> -f <path to custom values yaml file> aerospike/aerospike-proxy
helm upgrade --namespace aerospike proxy -f aerospike-proxy-values.yaml aerospike/aerospike-proxy
```

On successful execution of the command the Aerospike Proxy service pods will undergo a rolling restart and come up with the new configuration.

To verify the changes are applied
- [List the pods](#list-pods-for-the-aerospike-proxy)
- [Verify the configuration in Aerospike Proxy logs](#get-logs-for-all-aerospike-proxy-instances)

**_NOTE:_** The changes might take some time to apply. If you do not see the desired Aerospike Proxy config try again after some time.
If proxy pods are not being listed or report status as crashed see [troubleshooting](#troubleshooting).

## Scaling up/down the Aerospike Proxy

Edit the `replicaCount` to the desired Aerospike Proxy service count and upgrade the proxy deployment using the following command.

```shell
#helm upgrade --namespace <target namespace> <helm release name> -f <path to custom values yaml file> aerospike/aerospike-proxy
helm upgrade --namespace aerospike proxy -f aerospike-proxy-values.yaml aerospike/aerospike-proxy
```

Verify that the Aerospike Proxy have been scaled.
- [List the pods](#list-pods-for-the-aerospike-proxy) and verify the count of proxy instances is as desired

**_NOTE:_** The changes might take some time to apply. If you do not see the desired count try again after some time.
If proxy pods are not being listed or report status as crashed see [troubleshooting](#troubleshooting).

## Troubleshooting

### Aerospike Proxy pods not listed

Check for any error events on the Deployment created for the Aerospike Proxy.
```shell
# kubectl -n aerospike describe deployment <helm release name>-aerospike-proxy
kubectl -n aerospike describe deployment proxy-aerospike-proxy
```

### Aerospike Proxy pods stuck in `init` or `pending` state

Check for any error events on the pod created for the Aerospike Proxy service.
```shell
# kubectl -n aerospike describe pod <helm release name>-aerospike-proxy--<random-hash>
kubectl -n aerospike describe pod proxy-aerospike-proxy-f49cb67f4-llw4h
```

The most likely reason is secret listed in `proxyConfig` has not been created in the proxy namespace.

### Aerospike Proxy pods in crashed state

The most likely reason is proxy configuration provided in `proxyConfig` is invalid.
Verify this by [viewing the proxy logs](#get-logs-for-all-aerospike-proxy-instances), fix and [update](#updating-aerospike-proxy-configuration)
the Aerospike Proxy configuration.
86 changes: 86 additions & 0 deletions aerospike-proxy/examples/kind/aerospike.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
apiVersion: asdb.aerospike.com/v1
kind: AerospikeCluster
metadata:
name: aerospike-cluster
namespace: aerospike
spec:
size: 1
image: aerospike/aerospike-server-enterprise:7.1

podSpec:
multiPodPerHost: true

storage:
filesystemVolumePolicy:
cascadeDelete: true
initMethod: deleteFiles
volumes:
- name: workdir
source:
persistentVolume:
storageClass: standard
volumeMode: Filesystem
size: 3Gi
aerospike:
path: /opt/aerospike
- name: nsvol1
aerospike:
path: /mnt/disks/test
source:
persistentVolume:
storageClass: standard
volumeMode: Filesystem
size: 16G
- name: nsvol2
aerospike:
path: /mnt/disks/avs
source:
persistentVolume:
storageClass: standard
volumeMode: Filesystem
size: 16G
- name: aerospike-config-secret
source:
secret:
secretName: aerospike-secret
aerospike:
path: /etc/aerospike/secret

# aerospikeAccessControl:
# users:
# - name: admin
# secretName: auth-secret
# roles:
# - sys-admin
# - user-admin

aerospikeConfig:
service:
feature-key-file: /etc/aerospike/secret/features.conf
# security: {}
network:
service:
port: 3000
fabric:
port: 3001
heartbeat:
port: 3002
namespaces:
- name: test
replication-factor: 1
storage-engine:
type: device
filesize: 17179869184
files:
- /mnt/disks/test/test.dat
- name: avs-meta
nsup-period: 600
nsup-threads: 2
evict-tenths-pct: 5
replication-factor: 1
storage-engine:
type: device
filesize: 17179869184
files:
- /mnt/disks/avs/avs-meta.dat
12 changes: 12 additions & 0 deletions aerospike-proxy/examples/kind/proxy-kind-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
proxyConfig:
service:
ports:
4000: { }
manage:
4040: { }
aerospike:
seeds:
- aerospike-cluster-0-0.aerospike-cluster.aerospike.svc.cluster.local:
port: 3000
imagePullSecrets:
- name: regcred
16 changes: 16 additions & 0 deletions aerospike-proxy/kind/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Local Env Installation

### Create Local Env
```shell
./install-kind.sh
```

### Access Quote Search
```
http://127.0.0.1:80/
```

### Destroy Local Env
```shell
./uninstall-kind.sh
```
17 changes: 17 additions & 0 deletions aerospike-proxy/kind/config/gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: proxy-gw
namespace: aerospike
spec:
selector:
istio: ingress
servers:
- port:
number: 4000
name: grpc
protocol: GRPC
hosts:
- "*"
tls:
mode: PASSTHROUGH
15 changes: 15 additions & 0 deletions aerospike-proxy/kind/config/istio-ingressgateway-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
service:
type: LoadBalancer
ports:
- name: http
port: 80
targetPort: 80
- name: https
port: 443
targetPort: 443
- name: status-port
port: 15021
targetPort: 15021
- name: grpc
port: 4000
targetPort: 4000
Loading

0 comments on commit 491af0c

Please sign in to comment.