# Socket Runner

Runner definitions are typically loaded from a url or database when calling this chart. The chart also deploys a service on runner port for cluster access.

### Containers

#### Init Container

Chart contains an initialization container, which executes any preinit.sh and postinit.sh commands included in deployment, and also retrieves certifications required.

#### Main Container

Main container of this chart is a Java based process, which executes actual event runners and typically has liveness probes enabled.

#### Extra Container

It is possible to add an extra container to each pod (e.g. as a side car), if deployment parameters include relevant image details.

### Configuration

#### Local Configuration

Chart contains:

* 1 x config map containing build/execution files mounted on /app/config
* 1 x environment config map that can be used to add environment variables
* 1 x secret that can be used to add secret files mounted on /app/secrets
* 1 x environment secret that can be used to add environment variables

#### Global Configuration

Chart containers also have access to:

* global-config: Mounted on /app/globalconfig including key-value pairs and extra lines to include in application.properties files
* global-config-env: A config map that can be used to add environment variables for all namespace deployments
* global-secrets: Mounted on /app/globalsecrets including key-secret pairs and extra lines to include in application.properties files
* global-secrets-env: A secret that can be used to add environment variables for all namespace deployments
* global-secrets-docker: Used as the imagePullSecrets secret

### Configuration

The following table lists the configurable parameters of the Runner-socket chart and their default values.

| Parameter                        | Description                                                                                                                                                     | Default                                                 |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| `id`                             | unique id of the deployment package                                                                                                                             | `"x"`                                                   |
| `namespace`                      | namespace to deploy on                                                                                                                                          | `"runner"`                                              |
| `tier`                           | tier annotation to use for deployment                                                                                                                           | `"runner"`                                              |
| `unit`                           | unit annotation to use for deployment                                                                                                                           | `"runner-socket"`                                       |
| `scope`                          | scope annotation to use for deployment                                                                                                                          | `"admin"`                                               |
| `language`                       | language annotation to use for deployment                                                                                                                       | `"java"`                                                |
| `template`                       |                                                                                                                                                                 | `"socket"`                                              |
| `image`                          | docker image to use for main container                                                                                                                          | `"gradle:openj9"`                                       |
| `imagePullPolicy`                |                                                                                                                                                                 | `"IfNotPresent"`                                        |
| `cloud`                          | cloud vendor to use for deployment (e.g. gcp, aws)                                                                                                              | `"TBD"`                                                 |
| `poolSelector`                   | node pool selector annotation specific to cloud vendor                                                                                                          | `"TBD"`                                                 |
| `pool`                           | node pool to deploy on                                                                                                                                          | `"admin-node-pool"`                                     |
| `strategyType`                   | deployment strategy to use (e.g. Recreate)                                                                                                                      | `"RollingUpdate"`                                       |
| `maxSurge`                       |                                                                                                                                                                 | `1`                                                     |
| `maxUnavailable`                 |                                                                                                                                                                 | `0`                                                     |
| `replicaCount`                   | number of replicas to deploy                                                                                                                                    | `1`                                                     |
| `deploymentKind`                 | whether deployment should be a StatefulSet or Deployment                                                                                                        | `"Deployment"`                                          |
| `podManagementPolicy`            | policy for launching / terminating stateful set pods                                                                                                            | `"Parallel"`                                            |
| `useProbes`                      | whether main container should use liveness, etc. probes                                                                                                         | `false`                                                 |
| `healthPort`                     | port to use for health probes                                                                                                                                   | `0`                                                     |
| `healthScheme`                   | scheme to use for health probes                                                                                                                                 | `"HTTP"`                                                |
| `useOTLP`                        | whether opentelemetry should be enabled                                                                                                                         | `false`                                                 |
| `otlpInstrument`                 | opentelemetry auto-instrumentation                                                                                                                              | `"monitoring/grpc-instrumentation"`                     |
| `jvmArgs`                        | JVM parameters such as -Xms128m                                                                                                                                 | `""`                                                    |
| `initMemoryRequest`              | memory request for init container                                                                                                                               | `"256Mi"`                                               |
| `initCpuRequest`                 | cpu request for init container                                                                                                                                  | `"250m"`                                                |
| `initDiskRequest`                | ephemeral storage request for init container                                                                                                                    | `"0"`                                                   |
| `initMemoryLimit`                | memory limit for init container                                                                                                                                 | `"512Mi"`                                               |
| `initCpuLimit`                   | cpu limit for init container                                                                                                                                    | `"500m"`                                                |
| `initDiskLimit`                  | ephemeral storage limit for init container                                                                                                                      | `"0"`                                                   |
| `memoryRequest`                  | memory request for main container                                                                                                                               | `"256Mi"`                                               |
| `cpuRequest`                     | cpu request for main container                                                                                                                                  | `"250m"`                                                |
| `diskRequest`                    | ephemeral storage request for main container                                                                                                                    | `"0"`                                                   |
| `memoryLimit`                    | memory limit for main container                                                                                                                                 | `"512Mi"`                                               |
| `cpuLimit`                       | cpu limit for main container                                                                                                                                    | `"500m"`                                                |
| `diskLimit`                      | ephemeral storage limit for main container                                                                                                                      | `"0"`                                                   |
| `disableMavenCentral`            | whether gradle should access maven central                                                                                                                      | `false`                                                 |
| `mavenUrl`                       | url for Rierino maven packages                                                                                                                                  | `"https://maven.pkg.github.com/rierino/maven"`          |
| `mavenAuthenticated`             |                                                                                                                                                                 | `true`                                                  |
| `rierinoVersion`                 | Rierino package version to deploy                                                                                                                               | `"0.1.1"`                                               |
| `rierinoInstall`                 | Whether Rierino packages should be built on each restart                                                                                                        | `"always"`                                              |
| `mainClass`                      | name of the main Java class to execute                                                                                                                          | `"com.rierino.runner.spring.Application"`               |
| `logLevel`                       | logging level for the main container                                                                                                                            | `"ERROR"`                                               |
| `port`                           | port to use for socket communications                                                                                                                           | `0`                                                     |
| `scheme`                         | scheme to use for socket communications                                                                                                                         | `"HTTP"`                                                |
| `useDiscovery`                   | whether the runner should report to service discovery application                                                                                               | `false`                                                 |
| `consulHost`                     | Consul host (if useDiscovery)                                                                                                                                   | `"${dollar}{{rierino.system.consul.main.host}}"`        |
| `consulPort`                     | Consul port (if useDiscovery)                                                                                                                                   | `"${dollar}{{rierino.system.consul.main.port}}"`        |
| `useCert`                        | whether the runner should generate and use a certificate (requires additional parameters)                                                                       | `false`                                                 |
| `configLoaderClass`              | Java class name for loading configurations                                                                                                                      | `"com.rierino.runner.loader.MongoElementLoader"`        |
| `configloaderUri`                | Configuration loader database uri                                                                                                                               | `"${dollar}{{rierino.system.mongodb.devops_main.uri}}"` |
| `configloaderDatabase`           | Configuration loader database name                                                                                                                              | `"devops"`                                              |
| `valueLoaderClass`               | Java class name for key-value lookups                                                                                                                           | `"com.rierino.runner.loader.PropertiesKVLoader"`        |
| `valueLoaderProperties.path`     | File path for key-value lookups                                                                                                                                 | `"/app/globalconfig/properties"`                        |
| `valueLoaderProperties.dynamic`  | Whether key-values can change over time                                                                                                                         | `"true"`                                                |
| `secretLoaderClass`              | Java class name for key-secret lookups                                                                                                                          | `"com.rierino.runner.loader.PropertiesKVLoader"`        |
| `secretLoaderProperties.path`    | File path for key-secret lookups                                                                                                                                | `"/app/globalsecrets/properties"`                       |
| `secretLoaderProperties.dynamic` | Whether key-secrets can change over time                                                                                                                        | `"true"`                                                |
| `deploymentId`                   | ID of deployment package to deploy (dynamic alternative to providing list of runners)                                                                           | `null`                                                  |
| `runners`                        | list of runners to deploy                                                                                                                                       | `null`                                                  |
| `contents`                       | additional contents for deployment files (can include "preinit.sh", "postinit.sh", "prerun.sh", "application.properties", "build.gradle:dependencies" sections) | `null`                                                  |
| `runner_extra_properties`        | extra application.properties to include                                                                                                                         | `""`                                                    |
| `quiet`                          | whether gradle run should be quiet or not                                                                                                                       | `false`                                                 |
| `skipInit`                       | whether deployment uses an init container                                                                                                                       | `true`                                                  |
| `useExtraContainer`              | whether deployment uses an extra container                                                                                                                      | `false`                                                 |
| `extraImage`                     | image name for the extra container                                                                                                                              | `"ghcr.io/rierino-open/py-dynamic:dynamic"`             |
| `extraImagePullPolicy`           | policy for pulling extra container image                                                                                                                        | `"IfNotPresent"`                                        |
| `extraCommand`                   | entrypoint for the extra container                                                                                                                              | `"./command.sh"`                                        |
| `pyRepo`                         |                                                                                                                                                                 | `"rierino-open/py-runner"`                              |
| `pyMainModule`                   |                                                                                                                                                                 | `"rierino_runner.Py4JGateway"`                          |
| `pyScript`                       |                                                                                                                                                                 | `"/app/config/extraContainer.sh"`                       |
| `extraMemoryRequest`             | memory request for extra container                                                                                                                              | `"256Mi"`                                               |
| `extraCpuRequest`                | cpu request for extra container                                                                                                                                 | `"250m"`                                                |
| `extraDiskRequest`               | ephemeral storage request for extra container                                                                                                                   | `"0"`                                                   |
| `extraMemoryLimit`               | memory limit for extra container                                                                                                                                | `"512Mi"`                                               |
| `extraCpuLimit`                  | cpu limit for extra container                                                                                                                                   | `"500m"`                                                |
| `extraDiskLimit`                 | ephemeral storage limit for extra container                                                                                                                     | `"0"`                                                   |
