diff --git a/.github/workflows/helm-chart.yml b/.github/workflows/helm-chart.yml deleted file mode 100644 index 1855e9cd..00000000 --- a/.github/workflows/helm-chart.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: helm-chart - -on: - push: - paths: - - ".github/workflows/helm-chart.yml" - - "infra/charts/**" - branches: - - main - workflow_dispatch: - inputs: - owner: - description: The GitHub user or org that owns this repository - type: string - required: true - repository: - description: The GitHub repository - type: string - required: true - default: "charts" - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Run chart-releaser - uses: stefanprodan/helm-gh-pages@v1.4.1 - with: - token: "${{ secrets.GH_PAGES_TOKEN }}" - charts_dir: infra/charts - owner: "${{ github.event.inputs.owner || 'turing-ml' }}" - repository: "${{ github.event.inputs.repository || 'charts' }}" - commit_username: ${{ github.actor }} - commit_email: "${{ github.actor }}@users.noreply.github.com" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 526f20cf..d617df81 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,19 +1,4 @@ repos: - - repo: https://github.com/norwoodj/helm-docs - rev: v1.11.0 - hooks: - - id: helm-docs-built - name: 'Helm Docs for XP Management Service Chart' - files: '^infra/charts/management-service/' - args: - - --chart-search-root=infra/charts/management-service - - --template-files=./README.md.gotmpl - - id: helm-docs-built - name: 'Helm Docs for XP Treatment Service Chart' - files: '^infra/charts/treatment-service/' - args: - - --chart-search-root=infra/charts/treatment-service - - --template-files=./README.md.gotmpl - repo: local hooks: - id: format diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cab47e8e..0517b018 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,7 +63,7 @@ Setup [`pre-commit`](https://pre-commit.com/) to automatically lint and format t make setup ``` -3. On push, the pre-commit hook will run. This runs `make format`, `make lint`, `UI linting` and `generation of helm docs`. +3. On push, the pre-commit hook will run. This runs `make format`, `make lint` and `UI linting`. ## XP Management/Treatment Service using Go diff --git a/README.md b/README.md index 462e5377..194c54d9 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,10 @@ To test authorization for Management Service locally, make the following changes To use the XP Go modules as API dependencies, simply import the XP Go modules directly i.e. `import "github.com/caraml-dev/xp/..."` +#### d. XP Helm installation + +For running a helm installation of XP, you may refer to the [xp-management](https://github.com/caraml-dev/helm-charts/tree/main/charts/xp-management) and [xp-treatment](https://github.com/caraml-dev/helm-charts/tree/main/charts/xp-treatment) charts. + ## Contributing XP is still under active development. Please have a look at our contributing and development guides if you want to contribute to the project: diff --git a/docs/infra/treatment-service.md b/docs/infra/treatment-service.md index 3c5c2a1a..60115dd3 100644 --- a/docs/infra/treatment-service.md +++ b/docs/infra/treatment-service.md @@ -63,49 +63,7 @@ In short, the service account configured would minimally need these roles/permis #### As a Helm Release -*Some of these steps have been adapted from https://github.com/caraml-dev/xp/tree/main/infra/charts/treatment-service* - -##### 1. Add the Helm Repository - -```shell -$ helm repo add xp https://turing-ml.github.io/charts -``` - -##### 2. Install the Helm Chart - -This command will install XP Treatment Service release named `xp-treatment` in the `default` namespace. -Default chart values will be used for the installation: -```shell -$ helm install xp-treatment xp/xp-treatment -``` - -You can (and most likely, should) override the default configuration with Helm chart values suitable for your -installation. Refer to [Configuration](https://github.com/caraml-dev/xp/tree/main/infra/charts/treatment-service#configuration) section for the detailed description of available configuration keys. - -You can also refer to [values.yaml](https://github.com/caraml-dev/xp/tree/main/infra/charts/treatment-service/values.yaml) -for a minimal configuration that needs to be provided for XP Treatment Service installation. - -```shell -$ helm install xp-treatment xp/xp-treatment \ - --values=path/to/helm/chart/values/file.yaml -``` - -Notice that you can specify the *Treatment Service configuration* [values](#configuration) under the `xpTreatment` -field in the Helm chart values file like below: - -```yaml -xpTreatment: - config: - Port: 8080 - ManagementService: - URL: https://caraml-dev.io/api/xp/v1 - AuthorizationEnabled: true - # ... -``` - -These configuration values would be saved in a `.yaml` file within a -[secret](https://kubernetes.io/docs/concepts/configuration/secret/) that gets mounted automatically onto the -Treatment Service pod, where it will be read by the Treatment Service. +*Follow the installation steps from https://github.com/caraml-dev/helm-charts/tree/main/charts/xp-treatment* ##### 2.1 Configure the Standalone Treatment Service to use a Google Cloud Provider (GCP) Service Account (Optional) @@ -182,36 +140,26 @@ is configured as a plugin for. #### Configuration -Unlike for the standalone Treatment Service whereby the configuration values are placed in a file solely dedicated -for Treatment Service configurations, the Treatment Service Plugin configuration values need to be placed under -the experiment engines section, within the -[Helm chart values](https://github.com/caraml-dev/turing/blob/477ac2392c590d3dd6453a5834657dc773fe0e56/infra/charts/turing/values.yaml#L104) +Unlike for the standalone Treatment Service whereby the configuration values are placed in a file solely dedicated for Treatment Service configurations, the Treatment Service Plugin configuration values need to be placed under the experiment engines section, within the +[Helm chart values](https://github.com/caraml-dev/helm-charts/blob/ce4026287443c9d5f2c3fb69d2dd33f3d90f89e3/charts/turing/values.yaml#L118) of a Turing API server deployment. -Note that not all the configuration values used in a standalone Treatment Service need to be specified for the -Treatment Service Plugin, since some of those values will be retrieved directly via the Management Service (e.g. Pub/Sub -configuration or segmenter configuration). See [below](#1-prepare-the-turing-api-server-helm-chart-values-file) for +Note that not all the configuration values used in a standalone Treatment Service need to be specified for the Treatment Service Plugin, since some of those values will be retrieved directly via the Management Service (e.g. Pub/Sub configuration or segmenter configuration). See [below](#1-prepare-the-turing-api-server-helm-chart-values-file) for an example of the configuration values that need to be specified. -When the Turing API server deploys a router, the plugin manager will automatically retrieve the aforementioned -configurations from the Management Service, as well as the experiment engine configuration -(shown in the code block above) from the Turing API server. +When the Turing API server deploys a router, the plugin manager will automatically retrieve the aforementioned configurations from the Management Service, as well as the experiment engine configuration (shown in the code block above) from the Turing API server. -The plugin manager then creates a new plugin configuration object that will subsequently be passed to the API and then -to the Treatment Service plugin runner, which will be configured with those values passed to it. +The plugin manager then creates a new plugin configuration object that will subsequently be passed to the API and then to the Treatment Service plugin runner, which will be configured with those values passed to it. ![treatment_service_plugin_configuration.png](treatment_service_plugin_configuration.png) #### Google Cloud Provider (GCP) Service Account -Just as in the standalone Treatment Service, a GCP Service Account with the following roles is needed for the -Treatment Service Plugin to communicate with the Management Service via a +Just as in the standalone Treatment Service, a GCP Service Account with the following roles is needed for the Treatment Service Plugin to communicate with the Management Service via a [Google Cloud Pub/Sub](https://cloud.google.com/pubsub/docs/overview) subscription and for logging treatment responses to a table in [Google BigQuery](https://cloud.google.com/bigquery): -- [roles/pubsub.subscriber](https://cloud.google.com/pubsub/docs/access-control#roles), minimally, for the topic - that the Management Service will publish updates to -- [roles/bigquery.dataEditor](https://cloud.google.com/bigquery/docs/access-control#bigquery.dataEditor), minimally, - for the table that will contain the logs (if logging to BigQuery is configured) +- [roles/pubsub.subscriber](https://cloud.google.com/pubsub/docs/access-control#roles), minimally, for the topic that the Management Service will publish updates to +- [roles/bigquery.dataEditor](https://cloud.google.com/bigquery/docs/access-control#bigquery.dataEditor), minimally, for the table that will contain the logs (if logging to BigQuery is configured) ### Deploying the Treatment Service Plugin @@ -261,14 +209,13 @@ turing: As mentioned [earlier](#configuration), the Treatment Service Plugin configuration values must also be provided. Place those values within the `turing.experimentEngines.*.options.treatment_service_config` field of the Turing API's -[Helm chart values file](https://github.com/caraml-dev/turing/blob/477ac2392c590d3dd6453a5834657dc773fe0e56/infra/charts/turing/values.yaml#L104). +[Helm chart values file](https://github.com/caraml-dev/helm-charts/blob/ce4026287443c9d5f2c3fb69d2dd33f3d90f89e3/charts/turing/values.yaml#L118). #### 1.1 Configure the Treatment Service Plugin to use a Google Cloud Provider (GCP) Service Account (Optional) The service account token file has to be made accessible to the Turing API server such that it is available for it to be mounted within a Turing Router. The Turing API server looks for this service account token file via the filepath stored in the `turing.expermentEngines.*.serviceAccountKeyFilePath` field of the Turing API -server -[Helm chart values file](https://github.com/caraml-dev/turing/blob/477ac2392c590d3dd6453a5834657dc773fe0e56/infra/charts/turing/values.yaml#L104): +server [Helm chart values file](https://github.com/caraml-dev/helm-charts/blob/ce4026287443c9d5f2c3fb69d2dd33f3d90f89e3/charts/turing/values.yaml#L118): ```yaml turing: @@ -284,11 +231,7 @@ How this service account token file has to be made accessible to the Turing API deploying the Turing API server and is out of scope of this guide. However, one recommended way to do so is to use the -[Helm chart installation of Turing](https://github.com/caraml-dev/turing/tree/477ac2392c590d3dd6453a5834657dc773fe0e56/infra/charts/turing), -which allows the service account token file (assumed to already exist within the same cluster as the Turing API -server deployment as a [secret](https://kubernetes.io/docs/concepts/configuration/secret/)) to be mounted as a volume into the -Turing API server container, through the use of `extraVolumes` and `extraVolumeMounts` in the Turing API's -[Helm chart values file](https://github.com/caraml-dev/turing/blob/477ac2392c590d3dd6453a5834657dc773fe0e56/infra/charts/turing/values.yaml#L104): +[Helm chart installation of Turing](https://github.com/caraml-dev/helm-charts/blob/ce4026287443c9d5f2c3fb69d2dd33f3d90f89e3/charts/turing), which allows the service account token file (assumed to already exist within the same cluster as the Turing API server deployment as a [secret](https://kubernetes.io/docs/concepts/configuration/secret/)) to be mounted as a volume into the Turing API server container, through the use of `extraVolumes` and `extraVolumeMounts` in the Turing API's [Helm chart values file](https://github.com/caraml-dev/helm-charts/blob/ce4026287443c9d5f2c3fb69d2dd33f3d90f89e3/charts/turing/values.yaml#L118): ```yaml turing: @@ -316,9 +259,7 @@ to access the mounted service account token. Last but not least, specify the `turing.experimentEngines.*.options.treatment_service_config.deployment_config.google_application_credentials_env_var` -field as follows to allow the Treatment Service Plugin to retrieve the filepath of the GCP service account secret -token from the Turing Router container correctly (the Turing API automatically injects the filepath of the mounted -service account token as the `GOOGLE_APPLICATION_CREDENTIALS_EXPERIMENT_ENGINE` env var within the Turing Router): +field as follows to allow the Treatment Service Plugin to retrieve the filepath of the GCP service account secret token from the Turing Router container correctly (the Turing API automatically injects the filepath of the mounted service account token as the `GOOGLE_APPLICATION_CREDENTIALS_EXPERIMENT_ENGINE` env var within the Turing Router): ```yaml turing: diff --git a/infra/charts/management-service/Chart.yaml b/infra/charts/management-service/Chart.yaml deleted file mode 100644 index b674d186..00000000 --- a/infra/charts/management-service/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -appVersion: v0.9.0 -description: A Helm chart for Kubernetes Deployment of the XP Management Service -name: xp-management -version: 0.1.2 diff --git a/infra/charts/management-service/README.md b/infra/charts/management-service/README.md deleted file mode 100644 index 5767e01c..00000000 --- a/infra/charts/management-service/README.md +++ /dev/null @@ -1,104 +0,0 @@ -# xp-management - ---- -![Version: 0.1.2](https://img.shields.io/badge/Version-0.1.2-informational?style=flat-square) -![AppVersion: v0.9.0](https://img.shields.io/badge/AppVersion-v0.9.0-informational?style=flat-square) - -A Helm chart for Kubernetes Deployment of the XP Management Service - -## Introduction - -This Helm chart installs [Management Service](https://github.com/caraml-dev/xp/management-service) and all its dependencies in a Kubernetes cluster. - -## Prerequisites - -To use the charts here, [Helm](https://helm.sh/) must be configured for your -Kubernetes cluster. Setting up Kubernetes and Helm is outside the scope of -this README. Please refer to the Kubernetes and Helm documentation. - -- **Helm 3.0+** – This chart was tested with Helm v3.7.1, but it is also expected to work with earlier Helm versions -- **Kubernetes 1.18+** – This chart was tested with GKE v1.20.x, but it's possible it works with earlier k8s versions too. - -## Installation - -### Add Helm repository - -```sh -$ helm repo add xp https://turing-ml.github.io/charts -``` - -### Installing the chart - -This command will install XP Management Service release named `management-service` in the `default` namespace. -Default chart values will be used for the installation: -```shell -$ helm install xp xp/management-service -``` - -You can (and most likely, should) override the default configuration with values suitable for your installation. -Refer to [Configuration](#configuration) section for the detailed description of available configuration keys. - -You can also refer to [values.minimal.yaml](./values.minimal.yaml) to check a minimal configuration that needs -to be provided for XP Management Service installation. - -### Uninstalling the chart - -To uninstall `management-service` release: -```shell -$ helm uninstall management-service -``` - -The command removes all the Kubernetes components associated with the chart and deletes the release, -except for postgresql PVC, those will have to be removed manually. - -## Configuration - -The following table lists the configurable parameters of the XP Management Service chart and their default values. - -| Key | Type | Default | Description | -|-----|------|---------|-------------| -| global.mlp.encryption.key | string | `nil` | Global MLP Encryption Key to be used by all MLP components | -| global.sentry.dsn | string | `nil` | Global Sentry DSN value | -| postgresql | object | `{"containerPorts":{"postgresql":5432},"metrics":{"enabled":false,"replication":{"applicationName":"xp","enabled":false,"numSynchronousReplicas":2,"password":"repl_password","slaveReplicas":2,"synchronousCommit":"on","user":"repl_user"},"serviceMonitor":{"enabled":false}},"persistence":{"enabled":true,"size":"10Gi"},"postgresqlDatabase":"xp","postgresqlPassword":"xp","postgresqlUsername":"xp","resources":{"requests":{"cpu":"500m","memory":"256Mi"}},"tls":{"enabled":false}}` | Postgresql configuration to be applied to XP Management Service's postgresql database deployment Reference: https://artifacthub.io/packages/helm/bitnami/postgresql/10.16.2#parameters | -| postgresql.persistence.enabled | bool | `true` | Persist Postgresql data in a Persistent Volume Claim | -| postgresql.postgresqlPassword | string | `"xp"` | Password for XP Management Service Postgresql database | -| postgresql.resources | object | `{"requests":{"cpu":"500m","memory":"256Mi"}}` | Resources requests and limits for XP Management Service database. This should be set according to your cluster capacity and service level objectives. Reference: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ | -| swaggerUi.apiServer | string | `"http://127.0.0.1/v1"` | URL of API server | -| swaggerUi.image | object | `{"tag":"v3.47.1"}` | Docker tag for Swagger UI https://hub.docker.com/r/swaggerapi/swagger-ui | -| swaggerUi.service.externalPort | int | `8080` | Swagger UI Kubernetes service port number | -| swaggerUi.service.internalPort | int | `8081` | Swagger UI container port number | -| tags.db | bool | `true` | Specifies if Postgresql database needs to be installed together with XP Management Service | -| xpManagement.apiConfig | object | `{}` | XP Management Service server configuration. | -| xpManagement.extraArgs | list | `[]` | List of string containing additional XP Management Service server arguments. For example, multiple "-config" can be specified to use multiple config files | -| xpManagement.extraEnvs | list | `[]` | List of extra environment variables to add to XP Management Service server container | -| xpManagement.extraLabels | object | `{}` | List of extra labels to add to XP Management Service K8s resources | -| xpManagement.extraVolumeMounts | list | `[]` | Extra volume mounts to attach to XP Management Service server container. For example to mount the extra volume containing secrets | -| xpManagement.extraVolumes | list | `[]` | Extra volumes to attach to the Pod. For example, you can mount additional secrets to these volumes | -| xpManagement.image.pullPolicy | string | `"IfNotPresent"` | Docker image pull policy | -| xpManagement.image.registry | string | `"ghcr.io"` | Docker registry for XP Management Service image | -| xpManagement.image.repository | string | `"caraml-dev/xp/xp-management"` | Docker image repository for XP Management Service | -| xpManagement.image.tag | string | `"v0.9.0"` | Docker image tag for XP Management Service | -| xpManagement.ingress.class | string | `""` | Ingress class annotation to add to this Ingress rule, useful when there are multiple ingress controllers installed | -| xpManagement.ingress.enabled | bool | `false` | Enable ingress to provision Ingress resource for external access to XP Management Service | -| xpManagement.ingress.host | string | `""` | Set host value to enable name based virtual hosting. This allows routing HTTP traffic to multiple host names at the same IP address. If no host is specified, the ingress rule applies to all inbound HTTP traffic through the IP address specified. https://kubernetes.io/docs/concepts/services-networking/ingress/#name-based-virtual-hosting | -| xpManagement.labels | object | `{}` | | -| xpManagement.livenessProbe.initialDelaySeconds | int | `60` | Liveness probe delay and thresholds | -| xpManagement.livenessProbe.path | string | `"/v1/internal/live"` | HTTP path for liveness check | -| xpManagement.livenessProbe.periodSeconds | int | `10` | | -| xpManagement.livenessProbe.successThreshold | int | `1` | | -| xpManagement.livenessProbe.timeoutSeconds | int | `5` | | -| xpManagement.readinessProbe.initialDelaySeconds | int | `60` | Liveness probe delay and thresholds | -| xpManagement.readinessProbe.path | string | `"/v1/internal/ready"` | HTTP path for readiness check | -| xpManagement.readinessProbe.periodSeconds | int | `10` | | -| xpManagement.readinessProbe.successThreshold | int | `1` | | -| xpManagement.readinessProbe.timeoutSeconds | int | `5` | | -| xpManagement.replicaCount | int | `1` | | -| xpManagement.resources | object | `{}` | Resources requests and limits for XP Management Service. This should be set according to your cluster capacity and service level objectives. Reference: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ | -| xpManagement.sentry.dsn | string | `""` | Sentry DSN value used by both XP Management Service and XP UI | -| xpManagement.sentry.enabled | bool | `false` | | -| xpManagement.service.externalPort | int | `8080` | XP Management Service Kubernetes service port number | -| xpManagement.service.internalPort | int | `8080` | XP Management Service container port number | -| xpManagement.serviceAccount.annotations | object | `{}` | | -| xpManagement.serviceAccount.create | bool | `true` | | -| xpManagement.serviceAccount.name | string | `""` | | -| xpManagement.uiConfig | object | `{"apiConfig":{"mlpApiUrl":"/api/v1","xpApiUrl":"/api/xp/v1"},"appConfig":{"docsUrl":[{"href":"https://github.com/caraml-dev/xp/tree/main/docs","label":"XP User Guide"}]},"authConfig":{"oauthClientId":""},"sentryConfig":{}}` | XP UI configuration. | diff --git a/infra/charts/management-service/README.md.gotmpl b/infra/charts/management-service/README.md.gotmpl deleted file mode 100644 index 19371d65..00000000 --- a/infra/charts/management-service/README.md.gotmpl +++ /dev/null @@ -1,57 +0,0 @@ -{{ template "chart.header" . }} ---- -{{ template "chart.versionBadge" . }} -{{ template "chart.appVersionBadge" . }} - -{{ template "chart.description" . }} - -## Introduction - -This Helm chart installs [Management Service](https://github.com/caraml-dev/xp/management-service) and all its dependencies in a Kubernetes cluster. - -## Prerequisites - -To use the charts here, [Helm](https://helm.sh/) must be configured for your -Kubernetes cluster. Setting up Kubernetes and Helm is outside the scope of -this README. Please refer to the Kubernetes and Helm documentation. - -- **Helm 3.0+** – This chart was tested with Helm v3.7.1, but it is also expected to work with earlier Helm versions -- **Kubernetes 1.18+** – This chart was tested with GKE v1.20.x, but it's possible it works with earlier k8s versions too. - -## Installation - -### Add Helm repository - -```sh -$ helm repo add xp https://turing-ml.github.io/charts -``` - -### Installing the chart - -This command will install XP Management Service release named `management-service` in the `default` namespace. -Default chart values will be used for the installation: -```shell -$ helm install xp xp/management-service -``` - -You can (and most likely, should) override the default configuration with values suitable for your installation. -Refer to [Configuration](#configuration) section for the detailed description of available configuration keys. - -You can also refer to [values.minimal.yaml](./values.minimal.yaml) to check a minimal configuration that needs -to be provided for XP Management Service installation. - -### Uninstalling the chart - -To uninstall `management-service` release: -```shell -$ helm uninstall management-service -``` - -The command removes all the Kubernetes components associated with the chart and deletes the release, -except for postgresql PVC, those will have to be removed manually. - -## Configuration - -The following table lists the configurable parameters of the XP Management Service chart and their default values. - -{{ template "chart.valuesTable" . }} diff --git a/infra/charts/management-service/charts/postgresql-10.16.2.tgz b/infra/charts/management-service/charts/postgresql-10.16.2.tgz deleted file mode 100644 index d3a6d0f8..00000000 Binary files a/infra/charts/management-service/charts/postgresql-10.16.2.tgz and /dev/null differ diff --git a/infra/charts/management-service/requirements.lock b/infra/charts/management-service/requirements.lock deleted file mode 100644 index 68a42bf8..00000000 --- a/infra/charts/management-service/requirements.lock +++ /dev/null @@ -1,6 +0,0 @@ -dependencies: -- name: postgresql - repository: https://charts.bitnami.com/bitnami - version: 10.16.2 -digest: sha256:cddad872d58f7f052d938e50fbcd18c844380eb21e17c78b0f297a34f4304be8 -generated: "2022-07-18T12:20:25.553187+08:00" diff --git a/infra/charts/management-service/requirements.yaml b/infra/charts/management-service/requirements.yaml deleted file mode 100644 index 566de37f..00000000 --- a/infra/charts/management-service/requirements.yaml +++ /dev/null @@ -1,6 +0,0 @@ -dependencies: - - name: postgresql - repository: https://charts.bitnami.com/bitnami - version: 10.16.2 - tags: - - db diff --git a/infra/charts/management-service/templates/_helpers.tpl b/infra/charts/management-service/templates/_helpers.tpl deleted file mode 100644 index 47c9dbe4..00000000 --- a/infra/charts/management-service/templates/_helpers.tpl +++ /dev/null @@ -1,96 +0,0 @@ -{{/* -Expand the name of the chart. -*/}} -{{- define "xp.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 "xp.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 "xp.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{- define "xp.environment" -}} -{{- .Values.global.environment | default .Values.xpManagement.environment | default "dev" -}} -{{- end -}} - -{{/* -Common labels -*/}} -{{- define "xp.labels" -}} -helm.sh/chart: {{ include "xp.chart" . }} -{{- with (.Values.xpManagement).extraLabels }} -{{- toYaml . | nindent 0 }} -{{- end }} -{{ include "xp.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "xp.selectorLabels" -}} -app.kubernetes.io/name: {{ include "xp.fullname" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - -{{/* -Create the name of the service account to use -*/}} -{{- define "xp.serviceAccountName" -}} -{{- if .Values.xpManagement.serviceAccount.create }} -{{- default (include "xp.fullname" .) .Values.xpManagement.serviceAccount.name }} -{{- else }} -{{- default "default" .Values.xpManagement.serviceAccount.name }} -{{- end }} -{{- end }} - -{{- define "xp.sentry.enabled" -}} -{{ eq ((.Values.xpManagement.apiConfig.sentryConfig).enabled | toString) "true" }} -{{- end -}} - -{{- define "xp.sentry.dsn" -}} -{{- .Values.global.sentry.dsn | default .Values.xpManagement.sentry.dsn -}} -{{- end -}} - -{{- define "xp.ui.defaultConfig" -}} -{{- if .Values.xpManagement.uiConfig -}} -appConfig: - environment: {{ .Values.xpManagement.uiConfig.appConfig.environment | default (include "xp.environment" .) }} -authConfig: - oauthClientId: {{ .Values.global.oauthClientId | default .Values.xpManagement.uiConfig.authConfig.oauthClientId | quote }} -{{- if (include "xp.sentry.enabled" .) }} -sentryConfig: - environment: {{ .Values.xpManagement.uiConfig.sentryConfig.environment | default (include "xp.environment" .) }} - dsn: {{ .Values.xpManagement.uiConfig.sentryConfig.dsn | default (include "xp.sentry.dsn" .) | quote }} -{{- end -}} -{{- end -}} -{{- end -}} - -{{- define "xp.ui.config" -}} -{{- $defaultConfig := include "xp.ui.defaultConfig" . | fromYaml -}} -{{ .Values.xpManagement.uiConfig | merge $defaultConfig | toPrettyJson }} -{{- end -}} diff --git a/infra/charts/management-service/templates/deployment.yaml b/infra/charts/management-service/templates/deployment.yaml deleted file mode 100644 index 665ad10f..00000000 --- a/infra/charts/management-service/templates/deployment.yaml +++ /dev/null @@ -1,130 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "xp.fullname" . }} - labels: - {{- include "xp.labels" . | nindent 4 }} -spec: - replicas: {{ .Values.xpManagement.replicaCount }} - selector: - matchLabels: - app: {{ template "xp.name" .}} - release: {{ .Release.Name }} - strategy: - type: RollingUpdate - rollingUpdate: - maxUnavailable: 0 - template: - metadata: - labels: - app: {{ template "xp.name" .}} - release: {{ .Release.Name }} - {{- include "xp.labels" . | nindent 8 }} - spec: - {{- with .Values.xpManagement.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "xp.serviceAccountName" . }} - containers: - - name: api - image: "{{ .Values.xpManagement.image.registry }}{{ .Values.xpManagement.image.repository }}:{{ .Values.xpManagement.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.xpManagement.image.pullPolicy }} - env: - {{- with .Values.xpManagement.extraEnvs }} - {{- toYaml . | nindent 12 }} - {{- end }} - ports: - - name: http - containerPort: 8080 - protocol: TCP - livenessProbe: - httpGet: - path: {{ .Values.xpManagement.livenessProbe.path }} - port: {{ .Values.xpManagement.service.internalPort }} - scheme: HTTP - initialDelaySeconds: {{ .Values.xpManagement.livenessProbe.initialDelaySeconds }} - periodSeconds: {{ .Values.xpManagement.livenessProbe.periodSeconds }} - successThreshold: {{ .Values.xpManagement.livenessProbe.successThreshold }} - timeoutSeconds: {{ .Values.xpManagement.livenessProbe.timeoutSeconds }} - readinessProbe: - httpGet: - path: {{ .Values.xpManagement.readinessProbe.path }} - port: {{ .Values.xpManagement.service.internalPort }} - scheme: HTTP - initialDelaySeconds: {{ .Values.xpManagement.readinessProbe.initialDelaySeconds }} - periodSeconds: {{ .Values.xpManagement.readinessProbe.periodSeconds }} - successThreshold: {{ .Values.xpManagement.readinessProbe.successThreshold }} - timeoutSeconds: {{ .Values.xpManagement.readinessProbe.timeoutSeconds }} - resources: - {{- toYaml .Values.xpManagement.resources | nindent 12 }} - # Give time for running pods to terminate existing connection before letting - # Kubernetes terminate the pods. - # https://blog.sebastian-daschner.com/entries/zero-downtime-updates-kubernetes - lifecycle: - preStop: - exec: - command: ["/bin/bash", "-c", "sleep 15"] - args: - - serve - - --config=/etc/xp/config.yaml - {{- if .Values.xpManagement.uiConfig }} - - -ui-config - - /etc/xp/ui.config.json - {{- end }} - {{- with .Values.xpManagement.extraArgs }} - {{- toYaml . | nindent 8 }} - {{- end }} - volumeMounts: - - name: config - mountPath: /etc/xp - {{- with .Values.xpManagement.extraVolumeMounts }} - {{- toYaml . | nindent 8 }} - {{- end }} - - name: swagger-ui - image: "swaggerapi/swagger-ui:{{ .Values.swaggerUi.image.tag }}" - imagePullPolicy: IfNotPresent - ports: - - containerPort: {{ .Values.swaggerUi.service.internalPort }} - resources: - requests: - cpu: 100m - memory: 64Mi - limits: - cpu: 500m - memory: 128Mi - env: - - name: LAYOUT - value: "BaseLayout" - - name: SWAGGER_JSON - value: "/app/experiments.yaml" - - name: PORT - value: "{{ .Values.swaggerUi.service.internalPort }}" - - name: API_SERVER - value: "{{ .Values.swaggerUi.apiServer }}" - command: ["sh", "-c"] - args: - - | - mkdir /app - export LOCAL_API_SERVER="http://127.0.0.1:{{ .Values.xpManagement.service.internalPort }}" - echo "Fetching swagger configuration from ${LOCAL_API_SERVER}/experiments.yaml..." - until $$(wget -O $${SWAGGER_JSON} --tries 1 --timeout 1 ${LOCAL_API_SERVER}/experiments.yaml); do - printf '.' - sleep 10 - done - echo "Fetching swagger configuration from ${LOCAL_API_SERVER}/schema.yaml..." - until $$(wget -O /app/schema.yaml --tries 1 --timeout 1 ${LOCAL_API_SERVER}/schema.yaml); do - printf '.' - sleep 10 - done - echo "Update Swagger config..." - sed -r -i 's%^((\s*)-(\s*)url\s*:).*$$%\1 "'$${API_SERVER}'"%' $${SWAGGER_JSON} - echo "Running Swagger UI..." - /usr/share/nginx/run.sh - volumes: - - name: config - secret: - secretName: {{ template "xp.fullname" .}}-api-config - {{- with .Values.xpManagement.extraVolumes }} - {{- toYaml . | nindent 6 }} - {{- end }} diff --git a/infra/charts/management-service/templates/ingress.yaml b/infra/charts/management-service/templates/ingress.yaml deleted file mode 100644 index abdf5112..00000000 --- a/infra/charts/management-service/templates/ingress.yaml +++ /dev/null @@ -1,33 +0,0 @@ -{{- if .Values.xpManagement.ingress.enabled }} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ template "xp.fullname" .}} - namespace: {{ .Release.Namespace }} - annotations: - {{- with .Values.xpManagement.ingress.class }} - ingress.class: {{ . }} - {{- end }} - labels: - app: {{ include "xp.fullname" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} - helm.sh/chart: {{ include "xp.chart" . }} - app.kubernetes.io/name: {{ include "xp.fullname" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- if .Values.xpManagement.labels }} -{{ toYaml .Values.xpManagement.labels | indent 4 }} -{{- end }} -spec: - rules: - - {{- with .Values.xpManagement.ingress.host }} - host: {{ . }} - {{- end }} - http: - paths: - - path: / - backend: - serviceName: {{ template "xp.fullname" .}} - servicePort: {{ .Values.xpManagement.service.externalPort }} -{{- end }} diff --git a/infra/charts/management-service/templates/secrets.yaml b/infra/charts/management-service/templates/secrets.yaml deleted file mode 100644 index 1ab09eda..00000000 --- a/infra/charts/management-service/templates/secrets.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - namespace: {{ .Release.Namespace }} - name: {{ template "xp.fullname" .}}-api-config -stringData: - config.yaml: | - {{- toYaml .Values.xpManagement.apiConfig | nindent 4 -}} - {{- if .Values.xpManagement.uiConfig }} - ui.config.json: | - {{- include "xp.ui.config" . | nindent 4 -}} - {{- end }} diff --git a/infra/charts/management-service/templates/service-swagger.yaml b/infra/charts/management-service/templates/service-swagger.yaml deleted file mode 100644 index b6572137..00000000 --- a/infra/charts/management-service/templates/service-swagger.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ template "xp.fullname" .}}-swagger - namespace: {{ .Release.Namespace }} - labels: - app: {{ template "xp.fullname" .}} - chart: {{ template "xp.chart" .}} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -{{ if .Values.xpManagement.labels -}} -{{ toYaml .Values.xpManagement.labels | indent 4 -}} -{{- end }} -spec: - type: ClusterIP - ports: - - name: http - port: {{ .Values.swaggerUi.service.externalPort }} - targetPort: {{ .Values.swaggerUi.service.internalPort }} - protocol: TCP - selector: - app: {{ template "xp.fullname" .}} - release: {{ .Release.Name }} diff --git a/infra/charts/management-service/templates/service-xp.yaml b/infra/charts/management-service/templates/service-xp.yaml deleted file mode 100644 index d0af6037..00000000 --- a/infra/charts/management-service/templates/service-xp.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ template "xp.fullname" .}} - namespace: {{ .Release.Namespace }} - labels: - app: {{ template "xp.fullname" .}} - chart: {{ template "xp.chart" .}} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -{{ if .Values.xpManagement.labels -}} -{{ toYaml .Values.xpManagement.labels | indent 4 -}} -{{- end }} -spec: - type: ClusterIP - ports: - - name: http - port: {{ .Values.xpManagement.service.externalPort }} - targetPort: {{ .Values.xpManagement.service.internalPort }} - protocol: TCP - selector: - app: {{ template "xp.name" .}} - release: {{ .Release.Name }} diff --git a/infra/charts/management-service/templates/serviceaccount.yaml b/infra/charts/management-service/templates/serviceaccount.yaml deleted file mode 100644 index 6e88baa9..00000000 --- a/infra/charts/management-service/templates/serviceaccount.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{{- if .Values.xpManagement.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "xp.serviceAccountName" . }} - labels: - {{- include "xp.labels" . | nindent 4 }} - {{- with .Values.xpManagement.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} diff --git a/infra/charts/management-service/values.yaml b/infra/charts/management-service/values.yaml deleted file mode 100644 index 2feff8f9..00000000 --- a/infra/charts/management-service/values.yaml +++ /dev/null @@ -1,177 +0,0 @@ -xpManagement: - image: - # -- Docker registry for XP Management Service image - registry: ghcr.io - # -- Docker image repository for XP Management Service - repository: caraml-dev/xp/xp-management - # -- Docker image tag for XP Management Service - tag: v0.9.0 - # -- Docker image pull policy - pullPolicy: IfNotPresent - - labels: {} - replicaCount: 1 - - # -- Resources requests and limits for XP Management Service. This should be set - # according to your cluster capacity and service level objectives. - # Reference: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - resources: {} - - livenessProbe: - # -- HTTP path for liveness check - path: "/v1/internal/live" - # -- Liveness probe delay and thresholds - initialDelaySeconds: 60 - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 5 - - readinessProbe: - # -- HTTP path for readiness check - path: "/v1/internal/ready" - # -- Liveness probe delay and thresholds - initialDelaySeconds: 60 - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 5 - - service: - # -- XP Management Service Kubernetes service port number - externalPort: 8080 - # -- XP Management Service container port number - internalPort: 8080 - - ingress: - # -- Enable ingress to provision Ingress resource for external access to XP Management Service - enabled: false - # -- Set host value to enable name based virtual hosting. This allows routing - # HTTP traffic to multiple host names at the same IP address. If no host is - # specified, the ingress rule applies to all inbound HTTP traffic through - # the IP address specified. - # https://kubernetes.io/docs/concepts/services-networking/ingress/#name-based-virtual-hosting - host: "" - # -- Ingress class annotation to add to this Ingress rule, - # useful when there are multiple ingress controllers installed - class: "" - - # -- XP Management Service server configuration. - apiConfig: {} - - # -- XP UI configuration. - uiConfig: - apiConfig: - xpApiUrl: /api/xp/v1 - mlpApiUrl: /api/v1 - appConfig: - docsUrl: - - label: XP User Guide - href: https://github.com/caraml-dev/xp/tree/main/docs - authConfig: - oauthClientId: "" - sentryConfig: { } - - # -- List of string containing additional XP Management Service server arguments. For - # example, multiple "-config" can be specified to use multiple config files - extraArgs: [] - # Example - # - --config=/etc/secrets/experiment.yaml - # - --config=/etc/secrets/database.yaml - - # -- List of extra environment variables to add to XP Management Service server container - extraEnvs: [] - # # Example - # - name: DEMO_GREETING - # value: "Hello from the environment" - - # -- List of extra labels to add to XP Management Service K8s resources - extraLabels: {} - - # -- Extra volumes to attach to the Pod. For example, you can mount - # additional secrets to these volumes - extraVolumes: [] - # # Example - # - name: varlog - # emptyDir: {} - - # -- Extra volume mounts to attach to XP Management Service server container. For example - # to mount the extra volume containing secrets - extraVolumeMounts: [] - # # Example - # - name: varlog - # mountPath: /var/log - - 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: "" - - sentry: - enabled: false - # -- Sentry DSN value used by both XP Management Service and XP UI - dsn: "" - -# -- Postgresql configuration to be applied to XP Management Service's postgresql database deployment -# Reference: https://artifacthub.io/packages/helm/bitnami/postgresql/10.16.2#parameters -postgresql: - # -- Resources requests and limits for XP Management Service database. This should be set - # according to your cluster capacity and service level objectives. - # Reference: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - resources: - requests: - memory: 256Mi - cpu: 500m - persistence: - # -- Persist Postgresql data in a Persistent Volume Claim - enabled: true - size: 10Gi - postgresqlDatabase: xp - postgresqlUsername: xp - # -- Password for XP Management Service Postgresql database - postgresqlPassword: xp - tls: - enabled: false - containerPorts: - postgresql: 5432 - metrics: - enabled: false - serviceMonitor: - enabled: false - replication: - enabled: false - user: repl_user - password: repl_password - slaveReplicas: 2 - synchronousCommit: "on" - numSynchronousReplicas: 2 - applicationName: xp - -global: - sentry: - # -- (string) Global Sentry DSN value - dsn: - - mlp: - encryption: - # -- (string) Global MLP Encryption Key to be used by all MLP components - key: - -swaggerUi: - # -- Docker tag for Swagger UI https://hub.docker.com/r/swaggerapi/swagger-ui - image: - tag: v3.47.1 - # -- URL of API server - apiServer: http://127.0.0.1/v1 - service: - # -- Swagger UI container port number - internalPort: 8081 - # -- Swagger UI Kubernetes service port number - externalPort: 8080 - -# Tags are used to include/exclude chart dependencies -tags: - # -- Specifies if Postgresql database needs to be installed together with XP Management Service - db: true diff --git a/infra/charts/treatment-service/Chart.yaml b/infra/charts/treatment-service/Chart.yaml deleted file mode 100644 index 02de962f..00000000 --- a/infra/charts/treatment-service/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -appVersion: v0.9.0 -name: xp-treatment -description: A Helm chart for Kubernetes Deployment of the XP Treatment Service -version: 0.1.2 diff --git a/infra/charts/treatment-service/README.md b/infra/charts/treatment-service/README.md deleted file mode 100644 index 60c2b95a..00000000 --- a/infra/charts/treatment-service/README.md +++ /dev/null @@ -1,97 +0,0 @@ -# xp-treatment - ---- -![Version: 0.1.2](https://img.shields.io/badge/Version-0.1.2-informational?style=flat-square) -![AppVersion: v0.9.0](https://img.shields.io/badge/AppVersion-v0.9.0-informational?style=flat-square) - -A Helm chart for Kubernetes Deployment of the XP Treatment Service - -## Introduction - -This Helm chart installs [Treatment Service](https://github.com/caraml-dev/xp/treatment-service) and all its dependencies in a Kubernetes cluster. - -## Prerequisites - -To use the charts here, [Helm](https://helm.sh/) must be configured for your -Kubernetes cluster. Setting up Kubernetes and Helm is outside the scope of -this README. Please refer to the Kubernetes and Helm documentation. - -- **Helm 3.0+** – This chart was tested with Helm v3.7.1, but it is also expected to work with earlier Helm versions -- **Kubernetes 1.18+** – This chart was tested with GKE v1.20.x, but it's possible it works with earlier k8s versions too. - -## Installation - -### Add Helm repository - -```sh -$ helm repo add xp https://turing-ml.github.io/charts -``` - -### Installing the chart - -This command will install XP Treatment Service release named `xp-treatment` in the `default` namespace. -Default chart values will be used for the installation: -```shell -$ helm install xp-treatment xp/xp-treatment -``` - -You can (and most likely, should) override the default configuration with values suitable for your installation. -Refer to [Configuration](#configuration) section for the detailed description of available configuration keys. - -You can also refer to [values.yaml](./values.yaml) to check a minimal configuration that needs -to be provided for XP Treatment Service installation. - -### Uninstalling the chart - -To uninstall the `xp-treatment` release: -```shell -$ helm uninstall xp-treatment -``` - -The command removes all the Kubernetes components associated with the chart and deletes the release, -except for postgresql PVC, those will have to be removed manually. - -## Configuration - -The following table lists the configurable parameters of the XP Treatment Service chart and their default values. - -| Key | Type | Default | Description | -|-----|------|---------|-------------| -| swaggerUi.apiServer | string | `"http://127.0.0.1/v1"` | URL of API server | -| swaggerUi.enabled | bool | `false` | | -| swaggerUi.image | object | `{"tag":"v3.47.1"}` | Docker tag for Swagger UI https://hub.docker.com/r/swaggerapi/swagger-ui | -| swaggerUi.service.externalPort | int | `8080` | Swagger UI Kubernetes service port number | -| swaggerUi.service.internalPort | int | `8081` | Swagger UI container port number | -| xpTreatment.autoscaling.enabled | bool | `false` | | -| xpTreatment.autoscaling.maxReplicas | int | `2` | | -| xpTreatment.autoscaling.minReplicas | int | `1` | | -| xpTreatment.autoscaling.targetCPUUtilizationPercentage | int | `80` | | -| xpTreatment.autoscaling.targetMemoryUtilizationPercentage | int | `80` | | -| xpTreatment.extraEnvs | list | `[]` | List of extra environment variables to add to XP Treatment Service server container | -| xpTreatment.extraLabels | object | `{}` | List of extra labels to add to XP Treatment Service K8s resources | -| xpTreatment.extraVolumeMounts | list | `[]` | Extra volume mounts to attach to XP Treatment Service server container. For example to mount the extra volume containing secrets | -| xpTreatment.extraVolumes | list | `[]` | Extra volumes to attach to the Pod. For example, you can mount additional secrets to these volumes | -| xpTreatment.image.pullPolicy | string | `"IfNotPresent"` | Docker image pull policy | -| xpTreatment.image.registry | string | `"ghcr.io"` | Docker registry for XP Treatment Service image | -| xpTreatment.image.repository | string | `"caraml-dev/xp/xp-treatment"` | Docker image repository for XP Treatment Service | -| xpTreatment.image.tag | string | `"v0.9.0"` | Docker image tag for XP Treatment Service | -| xpTreatment.ingress.class | string | `""` | Ingress class annotation to add to this Ingress rule, useful when there are multiple ingress controllers installed | -| xpTreatment.ingress.enabled | bool | `false` | Enable ingress to provision Ingress resource for external access to XP Treatment Service | -| xpTreatment.ingress.host | string | `""` | Set host value to enable name based virtual hosting. This allows routing HTTP traffic to multiple host names at the same IP address. If no host is specified, the ingress rule applies to all inbound HTTP traffic through the IP address specified. https://kubernetes.io/docs/concepts/services-networking/ingress/#name-based-virtual-hosting | -| xpTreatment.labels | object | `{}` | | -| xpTreatment.livenessProbe.initialDelaySeconds | int | `60` | Liveness probe delay and thresholds | -| xpTreatment.livenessProbe.path | string | `"/v1/internal/health/live"` | HTTP path for liveness check | -| xpTreatment.livenessProbe.periodSeconds | int | `10` | | -| xpTreatment.livenessProbe.successThreshold | int | `1` | | -| xpTreatment.livenessProbe.timeoutSeconds | int | `5` | | -| xpTreatment.nodeSelector | object | `{}` | | -| xpTreatment.readinessProbe.initialDelaySeconds | int | `60` | Liveness probe delay and thresholds | -| xpTreatment.readinessProbe.path | string | `"/v1/internal/health/ready"` | HTTP path for readiness check | -| xpTreatment.readinessProbe.periodSeconds | int | `10` | | -| xpTreatment.readinessProbe.successThreshold | int | `1` | | -| xpTreatment.readinessProbe.timeoutSeconds | int | `5` | | -| xpTreatment.replicaCount | int | `1` | | -| xpTreatment.resources | object | `{}` | Resources requests and limits for XP Treatment Service. This should be set according to your cluster capacity and service level objectives. Reference: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ | -| xpTreatment.service.externalPort | int | `8080` | XP Treatment Service Kubernetes service port number | -| xpTreatment.service.internalPort | int | `8080` | XP Treatment Service container port number | -| xpTreatment.service.type | string | `"ClusterIP"` | | diff --git a/infra/charts/treatment-service/README.md.gotmpl b/infra/charts/treatment-service/README.md.gotmpl deleted file mode 100644 index c2719d81..00000000 --- a/infra/charts/treatment-service/README.md.gotmpl +++ /dev/null @@ -1,57 +0,0 @@ -{{ template "chart.header" . }} ---- -{{ template "chart.versionBadge" . }} -{{ template "chart.appVersionBadge" . }} - -{{ template "chart.description" . }} - -## Introduction - -This Helm chart installs [Treatment Service](https://github.com/caraml-dev/xp/treatment-service) and all its dependencies in a Kubernetes cluster. - -## Prerequisites - -To use the charts here, [Helm](https://helm.sh/) must be configured for your -Kubernetes cluster. Setting up Kubernetes and Helm is outside the scope of -this README. Please refer to the Kubernetes and Helm documentation. - -- **Helm 3.0+** – This chart was tested with Helm v3.7.1, but it is also expected to work with earlier Helm versions -- **Kubernetes 1.18+** – This chart was tested with GKE v1.20.x, but it's possible it works with earlier k8s versions too. - -## Installation - -### Add Helm repository - -```sh -$ helm repo add xp https://turing-ml.github.io/charts -``` - -### Installing the chart - -This command will install XP Treatment Service release named `xp-treatment` in the `default` namespace. -Default chart values will be used for the installation: -```shell -$ helm install xp-treatment xp/xp-treatment -``` - -You can (and most likely, should) override the default configuration with values suitable for your installation. -Refer to [Configuration](#configuration) section for the detailed description of available configuration keys. - -You can also refer to [values.yaml](./values.yaml) to check a minimal configuration that needs -to be provided for XP Treatment Service installation. - -### Uninstalling the chart - -To uninstall the `xp-treatment` release: -```shell -$ helm uninstall xp-treatment -``` - -The command removes all the Kubernetes components associated with the chart and deletes the release, -except for postgresql PVC, those will have to be removed manually. - -## Configuration - -The following table lists the configurable parameters of the XP Treatment Service chart and their default values. - -{{ template "chart.valuesTable" . }} diff --git a/infra/charts/treatment-service/templates/_helpers.tpl b/infra/charts/treatment-service/templates/_helpers.tpl deleted file mode 100644 index 53cfdfe6..00000000 --- a/infra/charts/treatment-service/templates/_helpers.tpl +++ /dev/null @@ -1,54 +0,0 @@ -{{/* -Expand the name of the chart. -*/}} -{{- define "xp.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 "xp.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 "xp.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "xp.labels" -}} -helm.sh/chart: {{ include "xp.chart" . }} -{{- with (.Values.xpTreatment).extraLabels }} -{{- toYaml . | nindent 0 }} -{{- end }} -{{ include "xp.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "xp.selectorLabels" -}} -app.kubernetes.io/name: {{ include "xp.fullname" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} diff --git a/infra/charts/treatment-service/templates/deployment.yaml b/infra/charts/treatment-service/templates/deployment.yaml deleted file mode 100644 index f6d16697..00000000 --- a/infra/charts/treatment-service/templates/deployment.yaml +++ /dev/null @@ -1,136 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "xp.fullname" . }} - labels: - {{- include "xp.labels" . | nindent 4 }} -spec: - replicas: {{ .Values.xpTreatment.replicaCount }} - selector: - matchLabels: - app: {{ template "xp.name" . }} - release: {{ .Release.Name }} - strategy: - type: RollingUpdate - rollingUpdate: - maxUnavailable: 0 - template: - metadata: - labels: - app: {{ template "xp.name" . }} - release: {{ .Release.Name }} - {{- include "xp.labels" . | nindent 8 }} - {{- with .Values.xpTreatment.annotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - spec: - {{- with .Values.xpTreatment.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - containers: - - name: api - image: "{{ .Values.xpTreatment.image.registry }}{{ .Values.xpTreatment.image.repository }}:{{ .Values.xpTreatment.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.xpTreatment.image.pullPolicy }} - env: - {{- with .Values.xpTreatment.extraEnvs }} - {{- toYaml . | nindent 12 }} - {{- end }} - ports: - - name: http - containerPort: 8080 - protocol: TCP - livenessProbe: - httpGet: - path: {{ .Values.xpTreatment.livenessProbe.path }} - port: {{ .Values.xpTreatment.service.internalPort }} - scheme: HTTP - initialDelaySeconds: {{ .Values.xpTreatment.livenessProbe.initialDelaySeconds }} - periodSeconds: {{ .Values.xpTreatment.livenessProbe.periodSeconds }} - successThreshold: {{ .Values.xpTreatment.livenessProbe.successThreshold }} - timeoutSeconds: {{ .Values.xpTreatment.livenessProbe.timeoutSeconds }} - readinessProbe: - httpGet: - path: {{ .Values.xpTreatment.readinessProbe.path }} - port: {{ .Values.xpTreatment.service.internalPort }} - scheme: HTTP - initialDelaySeconds: {{ .Values.xpTreatment.readinessProbe.initialDelaySeconds }} - periodSeconds: {{ .Values.xpTreatment.readinessProbe.periodSeconds }} - successThreshold: {{ .Values.xpTreatment.readinessProbe.successThreshold }} - timeoutSeconds: {{ .Values.xpTreatment.readinessProbe.timeoutSeconds }} - resources: - {{- toYaml .Values.xpTreatment.resources | nindent 12 }} - # Give time for running pods to terminate existing connection before letting - # Kubernetes terminate the pods. - # https://blog.sebastian-daschner.com/entries/zero-downtime-updates-kubernetes - lifecycle: - preStop: - exec: - command: ["/bin/bash", "-c", "sleep 15"] - args: - - serve - - --config=/etc/xp/config.yaml - {{- with .Values.xpTreatment.extraArgs }} - {{- toYaml . | nindent 8 }} - {{- end }} - volumeMounts: - - name: config - mountPath: /etc/xp - {{- with .Values.xpTreatment.extraVolumeMounts }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- if .Values.swaggerUi.enabled }} - - name: swagger-ui - image: "swaggerapi/swagger-ui:{{ .Values.swaggerUi.image.tag }}" - imagePullPolicy: IfNotPresent - ports: - - containerPort: {{ .Values.swaggerUi.service.internalPort }} - resources: - requests: - cpu: 100m - memory: 64Mi - limits: - cpu: 500m - memory: 128Mi - env: - - name: LAYOUT - value: "BaseLayout" - - name: SWAGGER_JSON - value: "/app/treatment.yaml" - - name: PORT - value: "{{ .Values.swaggerUi.service.internalPort }}" - - name: API_SERVER - value: "{{ .Values.swaggerUi.apiServer }}" - command: ["sh", "-c"] - args: - - | - mkdir /app - export LOCAL_API_SERVER="http://127.0.0.1:{{ .Values.xpTreatment.service.internalPort }}" - echo "Fetching swagger configuration from ${LOCAL_API_SERVER}/treatment.yaml..." - until $$(wget -O $${SWAGGER_JSON} --tries 1 --timeout 1 ${LOCAL_API_SERVER}/treatment.yaml); do - printf '.' - sleep 10 - done - echo "Fetching swagger configuration from ${LOCAL_API_SERVER}/schema.yaml..." - until $$(wget -O /app/schema.yaml --tries 1 --timeout 1 ${LOCAL_API_SERVER}/schema.yaml); do - printf '.' - sleep 10 - done - echo "Update Swagger config..." - sed -r -i 's%^((\s*)-(\s*)url\s*:).*$$%\1 "'$${API_SERVER}'"%' $${SWAGGER_JSON} - echo "Running Swagger UI..." - /usr/share/nginx/run.sh - {{- end }} - volumes: - - name: config - secret: - secretName: {{ template "xp.fullname" .}}-config - {{- with .Values.xpTreatment.extraVolumes }} - {{- toYaml . | nindent 6 }} - {{- end }} - -{{- if .Values.xpTreatment.nodeSelector }} - nodeSelector: -{{ toYaml .Values.xpTreatment.nodeSelector | nindent 8 }} -{{ end -}} diff --git a/infra/charts/treatment-service/templates/hpa.yaml b/infra/charts/treatment-service/templates/hpa.yaml deleted file mode 100644 index e002200b..00000000 --- a/infra/charts/treatment-service/templates/hpa.yaml +++ /dev/null @@ -1,32 +0,0 @@ -{{- if .Values.xpTreatment.autoscaling.enabled }} -apiVersion: autoscaling/v2beta2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ include "xp.fullname" . }} - labels: - {{- include "xp.labels" . | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ include "xp.fullname" . }} - minReplicas: {{ .Values.xpTreatment.autoscaling.minReplicas }} - maxReplicas: {{ .Values.xpTreatment.autoscaling.maxReplicas }} - metrics: - {{- if .Values.xpTreatment.autoscaling.targetCPUUtilizationPercentage }} - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.xpTreatment.autoscaling.targetCPUUtilizationPercentage }} - {{- end }} - {{- if .Values.xpTreatment.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: {{ .Values.xpTreatment.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} -{{- end }} diff --git a/infra/charts/treatment-service/templates/ingress.yaml b/infra/charts/treatment-service/templates/ingress.yaml deleted file mode 100644 index d6db030b..00000000 --- a/infra/charts/treatment-service/templates/ingress.yaml +++ /dev/null @@ -1,33 +0,0 @@ -{{- if .Values.xpTreatment.ingress.enabled }} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ template "xp.fullname" .}} - namespace: {{ .Release.Namespace }} - annotations: - {{- with .Values.xpTreatment.ingress.class }} - ingress.class: {{ . }} - {{- end }} - labels: - app: {{ include "xp.fullname" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} - helm.sh/chart: {{ include "xp.chart" . }} - app.kubernetes.io/name: {{ include "xp.fullname" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- if .Values.xpTreatment.labels }} -{{ toYaml .Values.xpTreatment.labels | indent 4 }} -{{- end }} -spec: - rules: - - {{- with .Values.xpTreatment.ingress.host }} - host: {{ . }} - {{- end }} - http: - paths: - - path: / - backend: - serviceName: {{ template "xp.fullname" .}} - servicePort: {{ .Values.xpTreatment.service.externalPort }} -{{- end }} diff --git a/infra/charts/treatment-service/templates/secrets.yaml b/infra/charts/treatment-service/templates/secrets.yaml deleted file mode 100644 index e8745645..00000000 --- a/infra/charts/treatment-service/templates/secrets.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - namespace: {{ .Release.Namespace }} - name: {{ template "xp.fullname" .}}-config -stringData: - config.yaml: | - {{- toYaml .Values.xpTreatment.config | nindent 4 -}} diff --git a/infra/charts/treatment-service/templates/service-swagger.yaml b/infra/charts/treatment-service/templates/service-swagger.yaml deleted file mode 100644 index 0cce43f1..00000000 --- a/infra/charts/treatment-service/templates/service-swagger.yaml +++ /dev/null @@ -1,25 +0,0 @@ -{{- if .Values.swaggerUi.enabled }} -apiVersion: v1 -kind: Service -metadata: - name: {{ include "xp.fullname" . }}-swagger - namespace: {{ .Release.Namespace }} - labels: - app: {{ template "xp.fullname" .}} - chart: {{ template "xp.chart" .}} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -{{ if .Values.xpTreatment.labels -}} -{{ toYaml .Values.xpTreatment.labels | indent 4 -}} -{{- end }} -spec: - type: {{ .Values.swaggerUi.service.type }} - ports: - - name: http - port: {{ .Values.swaggerUi.service.externalPort }} - targetPort: {{ .Values.swaggerUi.service.internalPort }} - protocol: TCP - selector: - app: {{ template "xp.fullname" .}} - release: {{ .Release.Name }} -{{- end }} diff --git a/infra/charts/treatment-service/templates/service-xp.yaml b/infra/charts/treatment-service/templates/service-xp.yaml deleted file mode 100644 index 7d514b01..00000000 --- a/infra/charts/treatment-service/templates/service-xp.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "xp.fullname" . }} - namespace: {{ .Release.Namespace }} - labels: - app: {{ template "xp.fullname" .}} - chart: {{ template "xp.chart" .}} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -{{ if .Values.xpTreatment.labels -}} -{{ toYaml .Values.xpTreatment.labels | indent 4 -}} -{{- end }} -spec: - type: {{ .Values.xpTreatment.service.type }} - ports: - - name: http - port: {{ .Values.xpTreatment.service.externalPort }} - targetPort: {{ .Values.xpTreatment.service.internalPort }} - protocol: TCP - selector: - app: {{ template "xp.name" .}} - release: {{ .Release.Name }} diff --git a/infra/charts/treatment-service/values.yaml b/infra/charts/treatment-service/values.yaml deleted file mode 100644 index bc145c48..00000000 --- a/infra/charts/treatment-service/values.yaml +++ /dev/null @@ -1,98 +0,0 @@ -xpTreatment: - image: - # -- Docker registry for XP Treatment Service image - registry: ghcr.io - # -- Docker image repository for XP Treatment Service - repository: caraml-dev/xp/xp-treatment - # -- Docker image tag for XP Treatment Service - tag: v0.9.0 - # -- Docker image pull policy - pullPolicy: IfNotPresent - - labels: {} - replicaCount: 1 - - # -- Resources requests and limits for XP Treatment Service. This should be set - # according to your cluster capacity and service level objectives. - # Reference: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - resources: {} - - livenessProbe: - # -- HTTP path for liveness check - path: "/v1/internal/health/live" - # -- Liveness probe delay and thresholds - initialDelaySeconds: 60 - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 5 - - readinessProbe: - # -- HTTP path for readiness check - path: "/v1/internal/health/ready" - # -- Liveness probe delay and thresholds - initialDelaySeconds: 60 - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 5 - - service: - type: ClusterIP - # -- XP Treatment Service Kubernetes service port number - externalPort: 8080 - # -- XP Treatment Service container port number - internalPort: 8080 - - ingress: - # -- Enable ingress to provision Ingress resource for external access to XP Treatment Service - enabled: false - # -- Set host value to enable name based virtual hosting. This allows routing - # HTTP traffic to multiple host names at the same IP address. If no host is - # specified, the ingress rule applies to all inbound HTTP traffic through - # the IP address specified. - # https://kubernetes.io/docs/concepts/services-networking/ingress/#name-based-virtual-hosting - host: "" - # -- Ingress class annotation to add to this Ingress rule, - # useful when there are multiple ingress controllers installed - class: "" - - # -- List of extra environment variables to add to XP Treatment Service server container - extraEnvs: [] - - # -- List of extra labels to add to XP Treatment Service K8s resources - extraLabels: {} - - # -- Extra volumes to attach to the Pod. For example, you can mount - # additional secrets to these volumes - extraVolumes: [] - # # Example - # - name: varlog - # emptyDir: {} - - # -- Extra volume mounts to attach to XP Treatment Service server container. For example - # to mount the extra volume containing secrets - extraVolumeMounts: [] - # # Example - # - name: varlog - # mountPath: /var/log - - nodeSelector: {} - - autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 2 - targetCPUUtilizationPercentage: 80 - targetMemoryUtilizationPercentage: 80 - -swaggerUi: - enabled: false - # -- Docker tag for Swagger UI https://hub.docker.com/r/swaggerapi/swagger-ui - image: - tag: v3.47.1 - # -- URL of API server - apiServer: http://127.0.0.1/v1 - service: - # -- Swagger UI container port number - internalPort: 8081 - # -- Swagger UI Kubernetes service port number - externalPort: 8080