Running CodeScoring in Kubernetes
Installation with a Helm chart
Installation procedure:
-
Create a namespace.
-
Create a secret for accessing the private Docker image registry for CodeScoring. Use the registry address (
REGISTRY_URL), login (USERNAME), and password (PASSWORD) received from the vendor.Alternatively, you can create a registry access secret through
values.yamlby adding the following entry to.Values.imagePullSecrets: -
Install Helm using your preferred method.
-
Run the following commands to add the current Helm repository to the local machine:
Helm chart settings
It is strongly recommended to make the necessary changes before installing CodeScoring. Otherwise, a complete system reinstall may be required. These instructions assume that the specialist has experience working with Kubernetes clusters and Helm.
All resource limits shown in this document are approximate. Actual resource consumption depends on installation load and specific usage scenarios.
To edit CodeScoring parameters conveniently, download and unpack the Helm chart source code:
In values.yaml, edit the required variables and then run the installation command from the Helm chart source directory:
The chart stores all configuration, including Kubernetes resource definitions, in values.yaml, which makes the file fairly large and not always convenient to edit.
If you need to override any parameters, it is acceptable and recommended to create an additional file with an arbitrary name, for example values-override.yaml. This document uses that name below.
For convenience, the chart includes a values-override.yaml template.
In this case, the installation command looks as follows. The order of files matters:
Installation with built-in PostgreSQL and Redis
The chart can deploy PostgreSQL and Redis using StatefulSet resources.
To enable PostgreSQL and Redis installation, define the following parameters in values-override.yaml:
When using built-in databases, no additional connection configuration is required.
Connecting external databases
When using your own database, make sure it meets the requirements.
Connecting external Redis
To connect external Redis, specify the corresponding connection strings in the following fields and keep the database numbers consistent:
Connecting to PostgreSQL through PgBouncer
External PostgreSQL must be connected through a connection pooler.
This option is suitable when PostgreSQL is already deployed in the existing infrastructure, but a connection pooler is not used. The Helm chart deploys PgBouncer and connects it to the existing PostgreSQL. Complete the following steps:
-
Configure the connection pooler by specifying the corresponding values:
-
Pass the configuration parameters created in step 1 to CodeScoring components:
Configuring volumes
Dynamic Volume Provisioning with the required StorageClass
The chart creates the required volumes through Dynamic Volume Provisioning using an explicitly specified StorageClass.
To create PersistentVolumeClaim resources, fill in the following values section:
If the cluster supports volumes with the ReadWriteMany (RWX) access mode, it is recommended to use that mode because it allows installation components to be placed on different cluster nodes.
If the cluster does not support RWX, or if RWO is required for another reason, configure podAffinity so that pods using the same volumes are scheduled on the same node.
To do this, add the following block to values-override.yaml:
PersistentVolumeClaim for pre-created PersistentVolume resources
You can specify names of pre-created PersistentVolume resources in the volumeName field, for example:
Configuring resource limits
By default, requests and limits are set to demonstration values that are not intended for production use. This makes it possible to run CodeScoring in clusters with limited resources, for example in minikube, for testing purposes.
When running in a production environment, you may need to configure resource limits. Edit the following fields:
Resource limits for init containers
Resource limits for main component containers
In general, resources are configured using the following template:
You can specify requests and limits together or separately. However, if only limits are specified, Kubernetes automatically sets requests to the same values, which may negatively affect pod scheduling.
Adding a Certificate Authority (CA) certificate
To allow CodeScoring to access resources with TLS certificates signed by a corporate Certificate Authority (CA), add the root CA certificate (RootCA) to values.yaml in key: value format.
The key is the certificate file name, including the .crt extension. The value is the certificate in PEM format. Add it to the following field:
You can specify any number of files, but each certificate must be stored in a separate file.
Environment variables
Managing environment variables through values
Environment variables and configuration files used by installation components are described in the configMaps and secrets blocks in values.yaml.
The most commonly overridden configuration parameters are included in values-override.yaml.
Managing environment variables through External Secret
External secret storage can also be connected. To use it, the cluster must have External Secrets Operator (ESO) installed. ESO adds the required CRDs (Custom Resource Definitions) to the cluster and connects it to secret storage.
To create an ExternalSecret resource and connect it to an existing SecretStore, add the corresponding entry to the vaults block:
To pass the created secret to all Deployment resources, add the resource name from the vaults block to deploymentsGeneral.envSecrets, for example:
To pass the secret only to one Deployment resource, specify it in the deployments block along with all secrets already used by that resource, for example:
Configuring Ingress
An Ingress controller must be installed in the cluster to expose the web interface and API through Ingress. Enable the Ingress, specify its class, and replace the domain name:
Set ingressClassName, hosts, and tls to match the Ingress controller, DNS, and TLS certificate configuration in your cluster. If cert-manager is not used, remove its annotation and create the Secret specified in tls.secretName by another method.
Configuring Gateway API
If the cluster uses Kubernetes Gateway API, you can create an HTTPRoute resource instead of an Ingress. The referenced Gateway resource must exist before CodeScoring is installed.
Disable the Ingress, specify the Gateway settings in httpRoutesGeneral, and enable the httpRoutes.codescoring route:
Set gatewayName, gatewayNamespace, gatewaySectionName, and hostnames to match the Gateway and DNS name in your cluster.
The backendRefs.name value must be formed as {helm-release-name}-frontend. For example, with helm install codescoring ..., specify name: codescoring-frontend.
Migration from Helm Chart 2.x.x
If built-in PostgreSQL was used, create a backup before any manipulations.
The installation will be unavailable during migration, so it is recommended to allocate a maintenance window. The migration takes 5-10 minutes in total.
Migration steps:
-
Delete all Deployment resources:
kubectl delete deployment --all -n codescoring. -
Delete all Service resources:
kubectl delete service --all -n codescoring. -
Run helm upgrade after filling in
values.yamlandvalues-override.yamlaccording to Helm chart settings:
