diff --git a/.github/workflows/helm-test.yml b/.github/workflows/helm-test.yml new file mode 100644 index 0000000..b4a8be6 --- /dev/null +++ b/.github/workflows/helm-test.yml @@ -0,0 +1,56 @@ + +name: Test Action +on: + push: + branches: + - main + tags: + - v* + pull_request: + branches: + - main + +jobs: + test: + name: Basic chart test using Minikube + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Start minikube + uses: medyagh/setup-minikube@master + - name: Test whether the cluster is running + run: kubectl get pods -A + - name: Install PostgreSQL + run: helm install psql oci://registry-1.docker.io/bitnamicharts/postgresql --set global.postgresql.auth.postgresPassword=postgres + - name: Check deployment status + run: | + kubectl rollout status --watch statefulset/psql-postgresql --timeout=5m + - name: Wait for PostgreSQL database to start + run: | + for n in [ 0 1 2 3 4 5 6 7 8 9 ] + do + if kubectl logs pod/psql-postgresql-0 | grep 'database system is ready to accept connections' + then + exit 0 + fi + sleep 30 + done + echo PostgreSQL did not start within 300 seconds! + exit 1 + - name: Install gatewayd + run: helm install gatewayd . + - name: Check deployment status + run: | + kubectl rollout status --watch deployment/gatewayd --timeout=5m + - name: Wait for gatewayd to start + run: | + for n in [ 0 1 2 3 4 5 6 7 8 9 ] + do + if kubectl get deployment gatewayd | awk '{print $2}' | grep 1/1 + then + exit 0 + fi + sleep 30 + done + echo gatewayd did not start within 300 seconds! + exit 1 diff --git a/charts/gatewayd/.helmignore b/.helmignore similarity index 100% rename from charts/gatewayd/.helmignore rename to .helmignore diff --git a/charts/gatewayd/Chart.yaml b/Chart.yaml similarity index 100% rename from charts/gatewayd/Chart.yaml rename to Chart.yaml diff --git a/README.md b/README.md index ddc1e34..60d34ca 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,97 @@ We welcome contributions from everyone. Just open an [issue](https://github.com/ ## License GatewayD Helm Charts is licensed under the [Apache 2.0 License](https://github.com/gatewayd-io/helm-charts/blob/main/LICENSE). + +# GatewayD Community Kubernetes Helm Charts + +This Helm charts installs GatewayD on your Kubernetes cluster. + +## How to use the charts + +1. Clone this repository +2. Install the chart +3. (Optionally) Uninstall the chart + +```bash +git clone https://github.com/gatewayd-io/helm-charts.git +cd helm-charts/charts/gatewayd/ +helm install gatewayd-release -f values.yaml ./ +# helm uninstall gatewayd-release +``` + +## Configuration for GatewayD Helm Chart + +#### Deployment Configuration + +| Parameter | Description | Default Value | +|---------------------------------------------|-------------------------------------------------------------------------------------------------------|-----------------------------| +| `autoscaling.enabled` | Determines whether autoscaling is enabled for the deployment. If not enabled, the `replicaCount` value is used to set the number of replicas. | `false` | +| `replicaCount` | The number of replicas to create for the deployment | `1` | +| `podAnnotations` | Annotations to add to the pod | `{}` | +| `podLabels` | Labels to add to the pod | `{}` | +| `imagePullSecrets` | Image pull secrets for the Docker registry | `[]` | +| `serviceAccountName` | The name of the service account to use for the deployment | `""` | +| `podSecurityContext` | Security context for the pod | `{}` | +| `securityContext` | Security context for the container | `{}` | +| `image.repository` | The Docker image repository | `gatewaydio/gatewayd` | +| `image.tag` | The Docker image tag. If not set, the app version from the chart is used | `""` | +| `image.pullPolicy` | The image pull policy | `IfNotPresent` | +| `resources` | Resource requests and limits for the container | `{}` | +| `gatewaydPluginsConfig.enabled` | Determines whether the `gatewayd_plugins.yaml` ConfigMap is mounted to the container. If enabled, a volume and volumeMount are added to the deployment. | `false` | +| `nodeSelector` | Node selector for the pod | `{}` | +| `affinity` | Affinity for the pod | `{}` | +| `tolerations` | Tolerations for the pod | `[]` | + +#### Service Configuration + +| Parameter | Description | Default Value | +|---------------------------------------------|-------------------------------------------------------------------------------------------------------|-----------------------------| +| `service.port` | The port that the service listens on | `15432` | +| `ingress.enabled` | Determines whether an Ingress resource should be created | `false` | + +#### Ingress Configuration + +| Parameter | Description | Default Value | +|---------------------------------------------|-------------------------------------------------------------------------------------------------------|-----------------------------| +| `gatewayd.fullname` | The full name of the deployment, used as part of the Ingress resource name | | +| `service.port` | The port that the service listens on, used as the service port in the Ingress rules | | +| `ingress.className` | The Ingress class to assign to the Ingress resource. This is only used for Kubernetes versions less than 1.18. | | +| `ingress.annotations` | Annotations to add to the Ingress resource. If `ingress.className` is set and the Kubernetes version is less than 1.18, the `kubernetes.io/ingress.class` annotation is added with the value of `ingress.className`. | `{}` | +| `Capabilities.KubeVersion.GitVersion` | The Kubernetes version running in the cluster. This is used to determine the API version of the Ingress resource to create. | | + +#### Autoscaling Configuration + +| Parameter | Description | Default Value | +|---------------------------------------------|-------------------------------------------------------------------------------------------------------|-----------------------------| +| `gatewayd.fullname` | The full name of the deployment, used as the target of the Horizontal Pod Autoscaler. | | +| `autoscaling.minReplicas` | The minimum number of replicas that the Horizontal Pod Autoscaler should maintain | | +| `autoscaling.maxReplicas` | The maximum number of replicas that the Horizontal Pod Autoscaler can scale out to | | +| `autoscaling.targetCPUUtilizationPercentage`| The target percentage of CPU utilization across all replicas that the Horizontal Pod Autoscaler should maintain. If set, a CPU utilization metric is added to the Horizontal Pod Autoscaler. | | +| `autoscaling.targetMemoryUtilizationPercentage`| The target percentage of memory utilization across all replicas that the Horizontal Pod Autoscaler should maintain. If set, a memory utilization metric is added to the Horizontal Pod Autoscaler. | | + +#### Service Account Configuration + +| Parameter | Description | Default Value | +|---------------------------------------------|-------------------------------------------------------------------------------------------------------|-----------------------------| +| `serviceAccount.create` | Determines whether a ServiceAccount should be created | | +| `gatewayd.serviceAccountName` | The name of the ServiceAccount. This is used as the name of the ServiceAccount resource. | | +| `gatewayd.labels` | The labels to apply to the ServiceAccount. | | +| `serviceAccount.annotations` | Annotations to add to the ServiceAccount. | | +| `serviceAccount.automount` | Determines whether the ServiceAccount token should be automatically mounted to the pods. This is set as the `automountServiceAccountToken` field in the ServiceAccount resource. | | + +#### ConfigMap Configuration + +| Parameter | Description | Default Value | +|---------------------------------------------|-------------------------------------------------------------------------------------------------------|-----------------------------| +| `gatewayd.fullname` | The full name of the deployment, used as the name of the ConfigMap. | | +| `.Release.Name` | The release name, used as part of the ConfigMap name. | | +| `gatewaydPluginsConfig.content` | The content of the `gatewayd_plugins.yaml` file. This is set as the `gatewayd_plugins.yaml` data in the ConfigMap. | | + + +## Usage + +Modify the [values.yaml](values.yaml) file to customize the deployment according to your requirements. You can override any default values as needed. + +## Contributing + +Feel free to contribute to the development of this Helm chart by submitting issues or pull requests to the GitHub repository. diff --git a/charts/gatewayd/README.md b/charts/gatewayd/README.md deleted file mode 100644 index c174724..0000000 --- a/charts/gatewayd/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# GatewayD Community Kubernetes Helm Charts - -This Helm charts installs GatewayD on your Kubernetes cluster. - -## How to use the charts - -1. Clone this repository -2. Install the chart -3. (Optionally) Uninstall the chart - -```bash -git clone https://github.com/gatewayd-io/helm-charts.git -cd helm-charts/charts/gatewayd/ -helm install gatewayd-release -f values.yaml ./ -# helm uninstall gatewayd-release -``` diff --git a/charts/gatewayd/templates/NOTES.txt b/templates/NOTES.txt similarity index 100% rename from charts/gatewayd/templates/NOTES.txt rename to templates/NOTES.txt diff --git a/charts/gatewayd/templates/_helpers.tpl b/templates/_helpers.tpl similarity index 100% rename from charts/gatewayd/templates/_helpers.tpl rename to templates/_helpers.tpl diff --git a/charts/gatewayd/templates/configmap.yaml b/templates/configmap.yaml similarity index 100% rename from charts/gatewayd/templates/configmap.yaml rename to templates/configmap.yaml diff --git a/charts/gatewayd/templates/deployment.yaml b/templates/deployment.yaml similarity index 83% rename from charts/gatewayd/templates/deployment.yaml rename to templates/deployment.yaml index 478cb12..130b9f2 100644 --- a/charts/gatewayd/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -19,7 +19,7 @@ spec: {{- end }} labels: {{- include "gatewayd.labels" . | nindent 8 }} - {{- with .Values.podLabels }} + {{- with .Values.podLabels }} {{- toYaml . | nindent 8 }} {{- end }} spec: @@ -46,13 +46,17 @@ spec: name: {{ include "gatewayd.fullname" . }} resources: {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.volumeMounts }} + {{- if .Values.gatewaydPluginsConfig.enabled }} volumeMounts: - {{- toYaml . | nindent 12 }} + - name: config-volume + mountPath: /etc/gatewayd_plugins.yaml + subPath: gatewayd_plugins.yaml {{- end }} - {{- with .Values.volumes }} + {{- if .Values.gatewaydPluginsConfig.enabled }} volumes: - {{- toYaml . | nindent 8 }} + - name: config-volume + configMap: + name: {{ .Release.Name }}-gatewayd-plugins-config {{- end }} {{- with .Values.nodeSelector }} nodeSelector: @@ -65,4 +69,4 @@ spec: {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} - {{- end }} + {{- end }} \ No newline at end of file diff --git a/templates/gatewayd_plugins_config.yaml b/templates/gatewayd_plugins_config.yaml new file mode 100644 index 0000000..eb4d90f --- /dev/null +++ b/templates/gatewayd_plugins_config.yaml @@ -0,0 +1,9 @@ +{{- if .Values.gatewaydPluginsConfig.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-gatewayd-plugins-config +data: + gatewayd_plugins.yaml: | + {{ .Values.gatewaydPluginsConfig.content | nindent 4 }} +{{- end }} \ No newline at end of file diff --git a/charts/gatewayd/templates/hpa.yaml b/templates/hpa.yaml similarity index 100% rename from charts/gatewayd/templates/hpa.yaml rename to templates/hpa.yaml diff --git a/charts/gatewayd/templates/ingress.yaml b/templates/ingress.yaml similarity index 100% rename from charts/gatewayd/templates/ingress.yaml rename to templates/ingress.yaml diff --git a/charts/gatewayd/templates/service.yaml b/templates/service.yaml similarity index 100% rename from charts/gatewayd/templates/service.yaml rename to templates/service.yaml diff --git a/charts/gatewayd/templates/serviceaccount.yaml b/templates/serviceaccount.yaml similarity index 100% rename from charts/gatewayd/templates/serviceaccount.yaml rename to templates/serviceaccount.yaml diff --git a/charts/gatewayd/templates/tests/test-connection.yaml b/templates/tests/test-connection.yaml similarity index 100% rename from charts/gatewayd/templates/tests/test-connection.yaml rename to templates/tests/test-connection.yaml diff --git a/charts/gatewayd/values.yaml b/values.yaml similarity index 59% rename from charts/gatewayd/values.yaml rename to values.yaml index 7fe807c..35acb35 100644 --- a/charts/gatewayd/values.yaml +++ b/values.yaml @@ -1,7 +1,7 @@ gatewayd: clients: default: - address: "postgres:5432" + address: "psql-postgresql:5432" loggers: default: # For production, use info @@ -82,21 +82,41 @@ autoscaling: targetCPUUtilizationPercentage: 80 # targetMemoryUtilizationPercentage: 80 -# Additional volumes on the output Deployment definition. -volumes: [] -# - name: foo -# secret: -# secretName: mysecret -# optional: false - -# Additional volumeMounts on the output Deployment definition. -volumeMounts: [] -# - name: foo -# mountPath: "/etc/foo" -# readOnly: true - nodeSelector: {} tolerations: [] affinity: {} + +gatewaydPluginsConfig: + enabled: false + content: | + compatibilityPolicy: "strict" + enableMetricsMerger: True + metricsMergerPeriod: 5s + healthCheckPeriod: 5s + reloadOnCrash: True + timeout: 30s + + plugins: + - name: gatewayd-plugin-cache + enabled: True + url: github.com/gatewayd-io/gatewayd-plugin-cache@latest + localPath: ../gatewayd-plugin-cache/gatewayd-plugin-cache + args: ["--log-level", "info"] + env: + - MAGIC_COOKIE_KEY=GATEWAYD_PLUGIN + - MAGIC_COOKIE_VALUE=5712b87aa5d7e9f9e9ab643e6603181c5b796015cb1c09d6f5ada882bf2a1872 + - REDIS_URL=redis://localhost:6379/0 + - EXPIRY=1h + - METRICS_ENABLED=True + - METRICS_UNIX_DOMAIN_SOCKET=/tmp/gatewayd-plugin-cache.sock + - METRICS_PATH=/metrics + - PERIODIC_INVALIDATOR_ENABLED=True + - PERIODIC_INVALIDATOR_INTERVAL=1m + - PERIODIC_INVALIDATOR_START_DELAY=1m + - API_ADDRESS=localhost:18080 + - EXIT_ON_STARTUP_ERROR=False + - SENTRY_DSN=https://70eb1abcd32e41acbdfc17bc3407a543@o4504550475038720.ingest.sentry.io/4505342961123328 + - CACHE_CHANNEL_BUFFER_SIZE=100 + checksum: 3988e10aefce2cd9b30888eddd2ec93a431c9018a695aea1cea0dac46ba91cae