codetogether-ai
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
Gatewaywhengateway.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
HTTPRoutefor theservice_fqdnhost,/to the chart Service; - with NGINX Gateway Fabric, a
ClientSettingsPolicythat raises the request body limit to16m(gateway.nginxGatewayFabric.clientSettingsPolicy). It replaces the Ingress annotationnginx.ingress.kubernetes.io/proxy-body-size; without it, tracker uploads over 1MB fail with 413. Withenabled: autoit 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
ReferenceGrantthere. - 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.
| Parameter | Description | Default |
|---|---|---|
nameOverride | Overrides the chart name | "" |
fullnameOverride | Overrides the full release name | "" |
image.repository | Container image repository | hub.edge.codetogether.com/releases/codetogether-ai |
image.pullPolicy | Image pull policy | Always |
image.tag | Container image tag | latest |
image.digest | Optional image digest; overrides the tag when set | "" |
imageCredentials.enabled | Create a pull Secret from registry credentials | true |
imageCredentials.registry | Private registry host | hub.edge.codetogether.com |
imageCredentials.username | Registry username | my-customer-username |
imageCredentials.password | Registry password | my-customer-password |
service.fqdn | Public HTTPS URL; optional with --set-file, required for pre-created properties Secrets | "" |
service.type | Kubernetes Service type | ClusterIP |
service.port | Service port for nginx / portal | 1080 |
service.annotations | Kubernetes Service annotations | {} |
ctaiPropertiesFile | Properties file contents, normally set with --set-file | "" |
ctaipropertiessecret.enabled | Mount a pre-created properties Secret instead of creating one from ctaiPropertiesFile | false |
ctaipropertiessecret.ref | Name of the pre-created properties Secret | "" |
masterKey.source | Master key source: secret, auto, or external | secret |
masterKey.existingSecret | Pre-created master-key Secret name when source=secret | ctai-master-key |
masterKey.existingSecretKey | Key in the master-key Secret | CTAI_PROTECTED_STORAGE_MASTER_KEY_B64 |
masterKey.existingSecretVersionKey | Optional version key in the master-key Secret | CTAI_PROTECTED_STORAGE_MASTER_KEY_VERSION |
properties.mountPath | Pod mount path for the properties file | /opt/ctai/server/config |
properties.fileName | Properties filename inside the Secret | ctai-configuration.properties |
ingress.enabled | Create an Ingress resource | true |
ingress.annotations | Ingress annotations | nginx.ingress.kubernetes.io/proxy-body-size: "16m" |
ingress.tls.secretName | TLS Secret for Ingress | codetogether-ai-tls |
gateway.enabled | Create a Gateway API HTTPRoute | false |
gateway.parentRefs | Gateway(s) the HTTPRoute attaches to; required when enabled unless gateway.listenerSet.enabled | [] |
gateway.annotations / gateway.labels | Extra HTTPRoute metadata (labels also go on the ListenerSet) | {} |
gateway.nginxGatewayFabric.clientSettingsPolicy.enabled | NGINX Gateway Fabric body-size policy: auto, true or false | auto |
gateway.nginxGatewayFabric.clientSettingsPolicy.bodyMaxSize | Request body limit on the Gateway | 16m |
gateway.listenerSet.enabled | Create a ListenerSet with this release's HTTPS listener; the HTTPRoute attaches to it when gateway.parentRefs is empty. Requires gateway.enabled=true | false |
gateway.listenerSet.parentRef | The shared Gateway (name, namespace); required when enabled | {} |
gateway.listenerSet.listenerName / port | Listener name (the route's sectionName) and port | https / 443 |
gateway.listenerSet.tlsSecretName | TLS Secret for the listener | <release fullname>-tls |
gateway.listenerSet.annotations | ListenerSet annotations (e.g. the cert-manager issuer); labels come from gateway.labels | {} |
clientIp.trustedProxyHops | Proxies in front of the pod that append to X-Forwarded-For | 2 |
serviceAccount.create | Create a ServiceAccount | true |
serviceAccount.name | ServiceAccount name | codetogether-ai |
replicaCount | Deployment replica count | 1 |
readinessProbe.path | Readiness endpoint on port 1080 | /healthz |
livenessProbe.path | Liveness endpoint on port 8080 | /actuator/health |
startupProbe.enabled | Enable startup probe | true |
securityContext.readOnlyRootFilesystem | Run with a read-only root filesystem; the container writes only to writableDirectories. See Read-only root filesystem | true |
writableDirectories.<name>.enabled | Mount an emptyDir on that directory (runtime, www, logs, tmp, systemTmp); false to mount your own volume there | true |
writableDirectories.<name>.sizeLimit | Optional `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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartcodetogether-ai is pinned at v0.2.5 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- 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