codetogether-ai

by CodeTogther Inc.

Helm chartv0.2.5App 1.2.8821

CodeTogether AI on-premises Kubernetes deployment

About this chart

Helm Chart for CodeTogether AI

Summary

This chart deploys CodeTogether AI on a Kubernetes cluster using Helm. Runtime configuration is supplied as ctai-configuration.properties, and the protected storage master key is stored in a separate Kubernetes Secret.

Prerequisites

  • Helm v3.5+
  • Kubernetes v1.19+
  • PostgreSQL reachable from the cluster. This chart does not install Postgres.
  • A DNS-routable HTTPS host for CodeTogether AI, configured as service_fqdn.
  • A TLS Secret for Ingress when ingress.enabled=true.
  • Or, instead of an Ingress controller, Gateway API CRDs and a Gateway when gateway.enabled=true (see "Gateway API" below).
  • CodeTogether-provided credentials for hub.edge.codetogether.com.

PostgreSQL Prerequisites

This chart does not install Postgres. Provide an external database reachable from the cluster and configure it in ctai-configuration.properties.

Before the first pod starts, run the database grants as a Postgres admin. A dedicated application user is recommended:

GRANT ALL PRIVILEGES ON DATABASE <db> TO <app_user>;
GRANT CREATE ON DATABASE <db> TO <app_user>;
ALTER DATABASE <db> OWNER TO <app_user>;
ALTER ROLE <app_user> BYPASSRLS;

BYPASSRLS matches the production application role shape. CodeTogether uses row-level security on platform tables, including oauth2_cache, where SSO stores OAuth state. Without it, SSO redirects can fail because OAuth state cannot be inserted or read.

Managed Postgres superusers, such as DigitalOcean's doadmin, bypass RLS but are not recommended for production application connections. If your provider requires SSL, append ?sslmode=require to the JDBC URL, for example:

database_url=jdbc:postgresql://postgres.example.internal:5432/codetogether?sslmode=require

Install

1. Prepare the configuration file

Copy ctai-configuration.properties.template to ctai-configuration.properties, then replace the example values with the values for your environment.

cp ctai-configuration.properties.template ctai-configuration.properties

Set service_fqdn to the public HTTPS URL for the deployment, for example:

service_fqdn=https://ai.example.com

Set the external Postgres connection properties:

database_url=jdbc:postgresql://postgres.example.internal:5432/codetogether
database_username=codetogether
database_password=replace-with-postgres-password

Generate the random properties-file secrets and paste the output into ctai-configuration.properties:

./generate-properties-secrets.sh

The configuration file contains deployment secrets. Store it securely and do not commit customer-specific values.

2. Configure SSO

Register this redirect URI with your identity provider:

https://ai.example.com/api/v1/auth/sso/provider/callback

Use the same host as service_fqdn. For Google OAuth or Google OIDC, add that URI as an Authorized redirect URI in the Google Cloud Console, then set the provider values in ctai-configuration.properties, for example:

sso_provider1_type=google
sso_provider1=google
sso_provider1_client_id=replace-with-google-client-id
sso_provider1_client_secret=replace-with-google-client-secret
sso_provider1_client_issuer_url=https://accounts.google.com

Before testing SSO, complete the PostgreSQL prerequisites.

3. Create the TLS Secret

Create the TLS Secret in the namespace where CodeTogether AI will run. The default Secret name is codetogether-ai-tls.

kubectl create namespace codetogether-ai
kubectl create secret tls codetogether-ai-tls \
  --namespace codetogether-ai \
  --key /path/to/tls.key \
  --cert /path/to/tls.crt

4. Create the protected storage master-key Secret

CodeTogether AI uses a 32-byte AES master key to encrypt sensitive values stored in Postgres. Generate this key once per deployment environment and database. Changing the key after encrypted data exists prevents that data from being decrypted.

./generate-master-key.sh --k8s-secret-yaml --secret-name ctai-master-key \
  > ctai-master-key-secret.yaml

kubectl apply -f ctai-master-key-secret.yaml -n codetogether-ai

Save the generated base64 key in your password manager and keep it with your Postgres backup procedure.

5. Install the chart

helm repo add codetogether https://helm.codetogether.io
helm repo update

helm install codetogether-ai codetogether/codetogether-ai \
  --namespace codetogether-ai --create-namespace \
  --set-file ctaiPropertiesFile=./ctai-configuration.properties \
  --set imageCredentials.username=replace-with-hub-edge-username \
  --set imageCredentials.password=replace-with-hub-edge-password \
  --set masterKey.source=secret \
  --set masterKey.existingSecret=ctai-master-key

Ingress host and TLS are derived from service_fqdn in ctai-configuration.properties. If you also set service.fqdn in Helm values, it must exactly match service_fqdn.

By default, the chart does not set ingress.className, matching the CodeTogether Intel chart. Clusters without a default IngressClass should set one explicitly:

--set ingress.className=nginx

If you set ingress.className=codetogether-nginx, the chart also creates a matching IngressClass.

Gateway API (NGINX Gateway Fabric)

Clusters that route with Gateway API instead of an Ingress controller (for example NGINX Gateway Fabric, which replaces the retired ingress-nginx) can have the chart attach an HTTPRoute to an existing Gateway:

ingress:
  enabled: false
gateway:
  enabled: true
  parentRefs:
    - name: shared-gateway        # your Gateway
      namespace: gateway-system   # omit if it is in the release namespace
      sectionName: https          # the HTTPS listener with the certificate

The chart renders:

  • an HTTPRoute for the service_fqdn host, / to the chart Service;
  • with NGINX Gateway Fabric, a ClientSettingsPolicy that raises the request body limit to 16m (gateway.nginxGatewayFabric.clientSettingsPolicy). It replaces the Ingress annotation nginx.ingress.kubernetes.io/proxy-body-size; without it, tracker uploads over 1MB fail with 413. With enabled: auto it is rendered only when the cluster serves that API. For another Gateway API implementation, set the equivalent limit on your side.

ListenerSet: your own listener on a shared Gateway

Instead of adding a listener to the shared Gateway for this host, the chart can create a ListenerSet (gateway.networking.k8s.io/v1, Gateway API v1.5+) that adds the HTTPS listener for the service_fqdn host, with its certificate, from the release namespace. The HTTPRoute then attaches to that ListenerSet, so leave gateway.parentRefs empty:

ingress:
  enabled: false
gateway:
  enabled: true
  listenerSet:
    enabled: true
    parentRef:
      name: gateway-ngf          # the shared Gateway
      namespace: kube-system
    # The listener's hostname is the service_fqdn host. The certificate Secret
    # defaults to <release fullname>-tls; set listenerSet.tlsSecretName to change it.
    annotations:
      cert-manager.io/cluster-issuer: cert-manager-clusterissuer

The shared Gateway has to accept ListenerSets from the release namespace (spec.allowedListeners.namespaces). With a cert-manager version that supports ListenerSets, the issuer annotation on the ListenerSet issues the certificate into that Secret; otherwise create the Secret yourself. On cert-manager v1.21 that support is off by default; enable it in the cert-manager chart values:

config:
  apiVersion: controller.config.cert-manager.io/v1alpha1
  kind: ControllerConfiguration
  enableGatewayAPI: true
  enableGatewayAPIListenerSet: true
featureGates: ListenerSets=true

Without it, cert-manager logs skipping disabled controller ... listenerset and no certificate is issued.

If you already applied a ListenerSet with the same name by hand, Helm refuses to take it over. Let Helm adopt it before the upgrade:

kubectl -n <namespace> label listenerset <release-fullname> app.kubernetes.io/managed-by=Helm
kubectl -n <namespace> annotate listenerset <release-fullname> \
  meta.helm.sh/release-name=<release> meta.helm.sh/release-namespace=<namespace>

The chart doesn't create the Gateway, and without a ListenerSet it doesn't create listeners or certificates either. On the Gateway side, check that:

  • the listener allows routes from the release namespace (allowedRoutes.namespaces);
  • the listener can read its certificate Secret. A Secret in another namespace needs a ReferenceGrant there.
  • the route is accepted: kubectl get httproute <release-fullname> -o jsonpath='{.status.parents[*].conditions}' (the install notes print the exact command).

Client IP addresses

clientIp.trustedProxyHops (default 2: Ingress controller or Gateway, plus the nginx in the pod) tells the server how many proxies in front of the pod append to X-Forwarded-For. Add one for each extra proxy in front (load balancer, WAF, corporate proxy). Set it to exactly the proxies you control: too low records a proxy's address, and too high can record an address the client put in its own X-Forwarded-For when your outermost proxy keeps that header. A CTAI_INGEST_OTEL_TRUSTED_PROXY_HOPS entry in extraEnvVars takes precedence.

Configuration

The following table lists the primary configurable parameters and defaults.

ParameterDescriptionDefault
nameOverrideOverrides the chart name""
fullnameOverrideOverrides the full release name""
image.repositoryContainer image repositoryhub.edge.codetogether.com/releases/codetogether-ai
image.pullPolicyImage pull policyAlways
image.tagContainer image taglatest
image.digestOptional image digest; overrides the tag when set""
imageCredentials.enabledCreate a pull Secret from registry credentialstrue
imageCredentials.registryPrivate registry hosthub.edge.codetogether.com
imageCredentials.usernameRegistry usernamemy-customer-username
imageCredentials.passwordRegistry passwordmy-customer-password
service.fqdnPublic HTTPS URL; optional with --set-file, required for pre-created properties Secrets""
service.typeKubernetes Service typeClusterIP
service.portService port for nginx / portal1080
service.annotationsKubernetes Service annotations{}
ctaiPropertiesFileProperties file contents, normally set with --set-file""
ctaipropertiessecret.enabledMount a pre-created properties Secret instead of creating one from ctaiPropertiesFilefalse
ctaipropertiessecret.refName of the pre-created properties Secret""
masterKey.sourceMaster key source: secret, auto, or externalsecret
masterKey.existingSecretPre-created master-key Secret name when source=secretctai-master-key
masterKey.existingSecretKeyKey in the master-key SecretCTAI_PROTECTED_STORAGE_MASTER_KEY_B64
masterKey.existingSecretVersionKeyOptional version key in the master-key SecretCTAI_PROTECTED_STORAGE_MASTER_KEY_VERSION
properties.mountPathPod mount path for the properties file/opt/ctai/server/config
properties.fileNameProperties filename inside the Secretctai-configuration.properties
ingress.enabledCreate an Ingress resourcetrue
ingress.annotationsIngress annotationsnginx.ingress.kubernetes.io/proxy-body-size: "16m"
ingress.tls.secretNameTLS Secret for Ingresscodetogether-ai-tls
gateway.enabledCreate a Gateway API HTTPRoutefalse
gateway.parentRefsGateway(s) the HTTPRoute attaches to; required when enabled unless gateway.listenerSet.enabled[]
gateway.annotations / gateway.labelsExtra HTTPRoute metadata (labels also go on the ListenerSet){}
gateway.nginxGatewayFabric.clientSettingsPolicy.enabledNGINX Gateway Fabric body-size policy: auto, true or falseauto
gateway.nginxGatewayFabric.clientSettingsPolicy.bodyMaxSizeRequest body limit on the Gateway16m
gateway.listenerSet.enabledCreate a ListenerSet with this release's HTTPS listener; the HTTPRoute attaches to it when gateway.parentRefs is empty. Requires gateway.enabled=truefalse
gateway.listenerSet.parentRefThe shared Gateway (name, namespace); required when enabled{}
gateway.listenerSet.listenerName / portListener name (the route's sectionName) and porthttps / 443
gateway.listenerSet.tlsSecretNameTLS Secret for the listener<release fullname>-tls
gateway.listenerSet.annotationsListenerSet annotations (e.g. the cert-manager issuer); labels come from gateway.labels{}
clientIp.trustedProxyHopsProxies in front of the pod that append to X-Forwarded-For2
serviceAccount.createCreate a ServiceAccounttrue
serviceAccount.nameServiceAccount namecodetogether-ai
replicaCountDeployment replica count1
readinessProbe.pathReadiness endpoint on port 1080/healthz
livenessProbe.pathLiveness endpoint on port 8080/actuator/health
startupProbe.enabledEnable startup probetrue
securityContext.readOnlyRootFilesystemRun with a read-only root filesystem; the container writes only to writableDirectories. See Read-only root filesystemtrue
writableDirectories.<name>.enabledMount an emptyDir on that directory (runtime, www, logs, tmp, systemTmp); false to mount your own volume theretrue
writableDirectories.<name>.sizeLimitOptional `empty

Deploy codetogether-ai with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has codetogether-ai on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartcodetogether-ai is pinned at v0.2.5 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply