Installation in Kubernetes (legacy)
This page describes the legacy Helm chart version. For new installations, use the current Installation in Kubernetes guide.
Installation using Helm chart with default parameters
Important!: This installation option does not provide an ability to scale CodeScoring horizontally. To install CodeScoring with horizontal scaling support, please refer to the relevant documentation section below.
Important!: You must have a configured default StorageClass in the cluster. By default, volumes are created with a capacity of 20 GiB
Installation order:
-
Create a namespace.
-
Create a secret to access the private registry of Docker images of the "CodeScoring" system, using the address (
REGISTRY_URL), login (USERNAME) and password (PASSWORD) received from the vendor. -
Install Helm using your preferred method.
-
Run the following commands to add the current Helm repository to the local machine:
-
Create a
values.yamlfile with the following content:Important!: Please replace the values in the sensitive data fields with your own. These fields include
secretKey,defaultSuperuserUsername,defaultSuperuserPassword,defaultSuperuserEmail, and all fields containingusernameorpassword. It is also important to note that all such variables are mandatory. -
Run the command to install the chart
Changing the admin password
To change the admin password without manually editing the values.yaml file, you can use the following command:
Advanced settings for Helm chart parameters
Important: It is highly recommended that you 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 a Kubernetes cluster and the Helm utility.
To easily edit CodeScoring parameters, you can download and unpack the Helm chart source code with the command:
In the values.yaml file you can edit the necessary variables, and after that run the platform command in the directory with the Helm chart source code:
Connecting to external PostgreSQL and Redis
By default, PostgreSQL and Redis run in separate StatefulSets. This option may not be suitable for usage in a production environment, because it is not fault tolerant.
Important: when using your own database, you must ensure that it corresponds to requirements.
Connecting to external Redis
To connect to external Redis, you must do the following:
- Disable Redis deployment by specifying the variable -
redis.enabled: false - In the
codescoring.config.djangoCachesRedisUrlsandcodescoring.config.hueyRedisUrlvariables, specify the connection strings for external Redis.
Connecting to external Redis via TLS
To connect to external Redis, in addition to abovementioned you must do the following:
- Set the
codescoring.trustedCA.enabledvariable totrue - Add the Redis-server root certificate to
codescoring.trustedCA.certificates - In the
codescoring.config.djangoCachesRedisUrlsandcodescoring.config.hueyRedisUrlvariables, specify the connection strings for external Redis using the following format:rediss://redis.example.com:6379/0, where 0 is the Redis database number.
Connecting to PostgreSQL via Pgbouncer pooler
Important!: Connecting to external PostgreSQL must be done using a connection pooler.
This option is suitable if PostgreSQL is already deployed in the existing infrastructure, but the connection pool is not used. Helm-chart will deploy the Pgbouncer puller and connect it to the existing PostgreSQL. You need to do the following:
-
Disable PostgreSQL deployment by specifying the variable -
postgresql.enabled: false -
Connect the Pgbouncer pooler to external PostgreSQL, replacing the appropriate parameters with the required ones:
Connecting to an external PostgreSQL pooler
This option is suitable if PostgreSQL and a connection pooler (for example, PgBouncer) are already deployed in the existing infrastructure. In this case, deployment of the Pgbouncer pooler is not required. You need to do the following:
- Disable PostgreSQL deployment by specifying the variable -
postgresql.enabled: false - Disable Pgbouncer deployment by specifying the variable -
pgbouncer.enabled: false - Connect codescoring directly to an external pooler, in the
codescoring.configsection the parameters are:
- Enable an external pooler and adjust the connection settings in the
codescoring.config.externalPoolersection:
Important!: An external pooler must support both transaction and session work modes. The connection settings for the pools must be adjusted in corresponding sections: externalPooler.transactionPool and externalPooler.sessionPool.
Setting up volumes (PV)
By default, the chart creates the required volumes via Dynamic Volume Provisioning using the default StorageClass. If this volume deployment option is not suitable, you can configure volume creation in several ways.
Important!: The options described below are mutually exclusive. You must select ONLY ONE deployment option for each volume. You can select different deployment options for different volumes.
To change the size of created volumes (except for local ones), you need to change the size parameter in the corresponding sections.
Dynamic Volume Provisioning using the required StorageClass
You can set the required StorageClass in the following variables:
codescoring.persistentVolumes.analysisRoot.storageClasscodescoring.persistentVolumes.mediaRoot.storageClasscodescoring.persistentVolumes.djangoStatic.storageClasscodescoring.backup.persistentVolume.storageClassredis.persistentVolume.storageClass(if using built-in Redis)postgresql.persistentVolume.storageClass(if using built-in PostgreSQL)
In this case, volumes will be created using the specified StorageClass
PersistentVolumeClaim for pre-created PersistentVolumes
The name of pre-created volumes can be set in the following variables:
codescoring.persistentVolumes.analysisRoot.volumeNamecodescoring.persistentVolumes.mediaRoot.volumeNamecodescoring.persistentVolumes.djangoStatic.volumeNamecodescoring.backup.persistentVolume.volumeNameredis.persistentVolume.volumeName(if using built-in Redis)postgresql.persistentVolume.volumeName(if using built-in PostgreSQL)
In this case, only PersistentVolumeClaim will be created for the volumes specified in these variables
Using pre-created PersistentVolumeClaim
The name of pre-created PVCs can be set in the following variables:
codescoring.persistentVolumes.analysisRoot.existingClaimcodescoring.persistentVolumes.mediaRoot.existingClaimcodescoring.persistentVolumes.djangoStatic.existingClaimcodescoring.backup.persistentVolume.existingClaimredis.persistentVolume.existingClaim(if using built-in Redis)postgresql.persistentVolume.exsistingClaim(if using built-in PostgreSQL)
In this case, the specified PVC name will be inserted directly into the volumes section for Pod.
Using local volumes
If there is no external data storage in the Kubernetes cluster, it is possible to run CodeScoring using local volumes. In this case, the data will be stored on one of the cluster nodes.
To create local volumes, you must perform the following steps:
- Assign the value
trueto the following variables:
codescoring.persistentVolumes.analysisRoot.localVolume.enabledcodescoring.persistentVolumes.mediaRoot.localVolume.enabledcodescoring.persistentVolumes.djangoStatic.localVolume.enabledcodescoring.backup.persistentVolume.localVolume.enabledredis.persistentVolume.localVolume.enabled(if using built-in Redis)postgresql.persistentVolume.localVolume.enabled(if using built-in PostgreSQL)
- Set the path to the directory on the cluster node, in which the data in the following variables will be placed:
codescoring.persistentVolumes.analysisRoot.localVolume.pathcodescoring.persistentVolumes.mediaRoot.localVolume.pathcodescoring.persistentVolumes.djangoStatic.localVolume.pathcodescoring.backup.persistentVolume.localVolume.pathredis.persistentVolume.localVolume.path(if using built-in Redis)postgresql.persistentVolume.localVolume.path(if using built-in PostgreSQL)
- Specify the name of the node on which the local volume will be created in the following variables:
codescoring.persistentVolumes.analysisRoot.localVolume.nodeHostnamecodescoring.persistentVolumes.djangoStatic.localVolume.nodeHostnamecodescoring.backup.persistentVolume.localVolume.nodeHostnameredis.persistentVolume.localVolume.nodeHostname(if using built-in Redis)postgresql.persistentVolume.localVolume.nodeHostname(if using built-in PostgreSQL)
It is allowed to use different nodes for different volumes.
Setting up storage for temporary scan files
By default, temporary files during the scanning process are stored in the /tmp directory inside containers, to which Ephemeral Volumes of type emptyDir are mounted:
codescoring.huey.ipcsQueue.ephemeralVolumescodescoring.huey.tasksOsaContainerImageScan.ephemeralVolumescodescoring.huey.tasksOsaPackageScan.ephemeralVolumes
However, in some cases you may need to use Persistent Volume instead of Ephemeral Volume. In this case, you should comment out the appropriate sections in ephemeralVolumes for one or more services, depending on which services require volumes to be mounted:
Then you need to set the value enabled: true in one or more of the following sections:
codescoring.huey.persistentVolumes.hueyTmpcodescoring.huey.persistentVolumes.hueyPackageScanTmpcodescoring.huey.persistentVolumes.hueyContainerImageScanTmp
As a result, PersistentVolumeClaim will be created for the corresponding services. It is worth noting that the possibilities for configuring these volumes fully correspond to those described in the section Configuring volumes (PV).
When horizontally scaling services, you need to configure volumes in accordance with the instructions in the Horizontal scaling CodeScoring section.
Horizontal scaling CodeScoring
Important!: To horizontally scale the CodeScoring system, the Kubernetes cluster must have the ability to create volumes with the access type ReadWriteMany (RWX)
To scale CodeScoring horizontally, you need to create analysis-root, media-root and django-static volumes with an access type of ReadWriteMany.
To do this, you need to replace the value of ReadWriteOnce with ReadWriteMany in the variables:
codescoring.persistentVolumes.analysisRoot.accessModescodescoring.persistentVolumes.mediaRoot.accessModescodescoring.persistentVolumes.djangoStatic.accessModes
Then, you need to comment out the variables:
codescoring.backend.affinitycodescoring.frontend.affinity
If this is not done, then all pods will be launched on only one node in the cluster.
Setting resource limits
By default, requests and limits are not specified. This is done to ensure the ability to run the CodeScoring system in clusters with a small number of resources (for example, minikube) for testing purposes.
When running in a production environment, you may need to configure resource limits. This can be done by setting the following variables:
postgresql.resources(when using built-in PostgreSQL)redis.resources(when using built-in Redis)codescoring.backend.resourcescodescoring.frontend.resourcescodescoring.huey.highPriorityQueue.resourcescodescoring.huey.ipcsQueue.resourcescodescoring.huey.tasksOsaContainerImageScan.resourcescodescoring.huey.tasksOsaPackageScan.resourcescodescoring.huey.tasksPolicy.resourcescodescoring.huey.tasksMedia.resources
It is possible to specify both resources and limits together or separately, for example:
Below are approximate limits values for a CodeScoring platform with 8-10 projects:
Adding a Certificate Authority (CA) certificate
To access CodeScoring resources with TLS certificates signed by a corporate certification authority (CA), you must:
- Set the
codescoring.trustedCA.enabledvariable totrue - Add the root certificate of the certification authority (RootCA) in PEM format to the
codescoring.trustedCA.certificatesvariable in thekey: valueformat, where key is the name of the certificate file, including the.crtextension, value is the certificate in PEM format.
For example:
If you have multiple root CAs, you need to add them to separate keys, for example:
Secret Management
By default, the Secret objects are created for ipcs-backend, pgbouncer and postgresql templates. The values for their variables are provided in the values file.
It is also possible to use external secret storages. To achieve that, it is necessary to have an External Secrets Operator (ESO) installed in the cluster. It adds all required CRDs (Custom Resource Definitions) to the cluster and connects to an external secret provider.
In order to connect ESO to an external secret storage, you must configure a provider for the SecretStore in the codescoring.secretStore block.
Next, you need to configure the ExternalSecret objects to fetch secrets from the external provider in the codescoring.config.externalSecret, pgbouncer.externalSecret, postgresql.externalSecret blocks.
All the configurations must be made in accordance with the official ESO documentation.
Important!: Some providers may bill requests to secret storages. The request interval can be configured using the externalSecret.refreshInterval parameter for each particular service.
Monitoring
For metrics collection purpose there are the ServiceMonitor resources provided in the chart. The metrics are collected from the backend and the osa-api services.
The ServiceMonitor can be configured in the following values sections: codescoring.backend.prometheus.serviceMonitor, codescoring.osa_api.prometheus.serviceMonitor.
In addition there are PrometheusRule resources provided for the abovementioned services. They are required for the alerting rule setup and can be configured in the following values sections: codescoring.backend.prometheus.alerts, codescoring.osa_api.prometheus.alerts.
All the settings must be adjusted in accordance with the official Prometheus Operator documentation.
Updating CodeScoring
In order to update CodeScoring you need to actualize the helm repository by running
and then update the platform with the following command, where the CHART_NAME variable must contain the version you are going to update to:
