Files
supabase/apps/studio/components/interfaces/ProjectCreation/InternalOnlyConfiguration.tsx
Joaquim Moreno Prusi a27ef81d2e feat(studio): enable advanced V3 deployment for allowlisted organizations (#53158)
## Problem

Currently, in production, the Supabase UI doesn't allow for a set of
advanced deployment options, that we need to properly test new clusters
before getting those into production.

## Solution

Allow production dashboard requests to specify an AWS_K8S cluster when
the organization is included in the comma-separated
`orgsAllowedToUseV3AdvancedDeployment` setting.

Limited the exception to cluster placement fields. Preserve existing
permissions and cluster validation, require force for cordoned clusters,
and keep system requests supported. Default the allowlist to empty.

Updated the API descriptions and document ConfigCat setup.

## Review instructions
-

## Checklist

Check all before review:

- [X] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [X] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-12-01 14:18:26 +01:00

184 lines
7.3 KiB
TypeScript

import { useParams } from 'common'
import { useRef } from 'react'
import { UseFormReturn } from 'react-hook-form'
import { type CloudProvider } from 'shared-data'
import {
Checkbox,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
Input,
useWatch,
} from 'ui'
import { CollapsibleCardSection } from 'ui-patterns/CollapsibleCardSection'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { CloudProviderSelector } from './CloudProviderSelector'
import { PostgresVersionSelector } from './PostgresVersionSelector'
import { CreateProjectForm } from './ProjectCreation.schema'
import { canOverrideKubernetesCluster, isProductionEnvironment } from './ProjectCreation.utils'
import Panel from '@/components/ui/Panel'
interface InternalOnlyConfigurationProps {
form: UseFormReturn<CreateProjectForm>
isV3AdvancedDeploymentEnabled: boolean
}
export const InternalOnlyConfiguration = ({
form,
isV3AdvancedDeploymentEnabled,
}: InternalOnlyConfigurationProps) => {
const { slug } = useParams()
const showNonProdFields = !isProductionEnvironment()
const canConfigureDeployment = showNonProdFields || isV3AdvancedDeploymentEnabled
const highAvailability = useWatch({ control: form.control, name: 'highAvailability' })
const cloudProvider = useWatch({ control: form.control, name: 'cloudProvider' })
const dbRegion = useWatch({ control: form.control, name: 'dbRegion' })
const kubernetesClusterId = useWatch({ control: form.control, name: 'kubernetesClusterId' })
const useOrioleDbForCreate = useWatch({ control: form.control, name: 'useOrioleDb' })
const canOverrideCluster = canOverrideKubernetesCluster(
cloudProvider,
isV3AdvancedDeploymentEnabled
)
// Held here (outside the collapsible content) so the selector's last valid
// selection survives the section being collapsed and reopened.
const lastValidPostgresVersionSelection = useRef('')
return (
<Panel.Content>
<CollapsibleCardSection
title="Internal-only Configuration"
description="Configure additional project deployment settings"
>
<div className="flex flex-col gap-y-6">
<div className="flex flex-col gap-y-4">
<FormField
control={form.control}
name="postgresVersionSelection"
render={({ field }) => (
<PostgresVersionSelector
field={field}
form={form}
cloudProvider={cloudProvider as CloudProvider}
organizationSlug={slug}
dbRegion={dbRegion}
disabled={highAvailability}
highAvailability={highAvailability}
lastValidSelectionRef={lastValidPostgresVersionSelection}
useOrioleDbForCreate={useOrioleDbForCreate}
description={
useOrioleDbForCreate
? undefined
: 'Choose OrioleDB in the advanced configuration if you want to use it'
}
/>
)}
/>
</div>
{canConfigureDeployment && <CloudProviderSelector form={form} />}
{showNonProdFields && (
<div>
<p className="text-xs text-foreground-lighter mb-6">
The settings below are only applicable for local/staging projects
</p>
<div className="flex flex-col gap-y-4">
{!highAvailability && (
<FormField
control={form.control}
name="postgresVersion"
render={({ field }) => (
<FormItemLayout
label="Custom Postgres version"
layout="horizontal"
description="Specify a custom version of Postgres (defaults to the latest)."
>
<FormControl>
<Input placeholder="e.g 17.6.1.104" {...field} autoComplete="off" />
</FormControl>
</FormItemLayout>
)}
/>
)}
<FormField
control={form.control}
name="instanceType"
render={({ field }) => (
<FormItemLayout
label="Custom instance type"
layout="horizontal"
description="Specify a custom instance type."
>
<FormControl>
<Input placeholder="e.g t3.nano" {...field} autoComplete="off" />
</FormControl>
</FormItemLayout>
)}
/>
</div>
</div>
)}
{canOverrideCluster && (
<FormField
control={form.control}
name="kubernetesClusterId"
render={({ field }) => (
<FormItemLayout
label="Kubernetes cluster ID"
layout="horizontal"
description="Override the Kubernetes cluster this project is created on, bypassing load-balancing. Use the full cluster ID (e.g. dev-gbl-a001-c003-k001-0-eksCluster-038b450), not the short cluster name (e.g. dev-gbl-a001-c003-k001)."
>
<FormControl>
{/* The backend matches against the kubernetes_clusters.id primary
key, which is the full `<cluster-name>-eksCluster-<hash>` value —
not the short cluster name shown elsewhere (e.g. admin_studio's
project page). The short name alone won't match any cluster. */}
<Input
placeholder="e.g dev-gbl-a001-c003-k001-0-eksCluster-038b450"
{...field}
autoComplete="off"
/>
</FormControl>
</FormItemLayout>
)}
/>
)}
{canOverrideCluster && !!kubernetesClusterId && (
<FormField
control={form.control}
name="kubernetesClusterForce"
render={({ field }) => (
<FormItem className="flex items-start gap-3">
<FormControl>
<Checkbox
checked={field.value}
disabled={field.disabled}
onCheckedChange={(value) => field.onChange(value === true)}
/>
</FormControl>
<div className="space-y-1">
<FormLabel className="text-sm text-foreground">
Force-deploy to this cluster
</FormLabel>
<FormDescription className="text-foreground-lighter">
Allows deliberately targeting a CORDONED cluster. PENDING and REMOVED clusters
remain ineligible, and the cluster still needs a mapped filesystem to
provision onto.
</FormDescription>
</div>
</FormItem>
)}
/>
)}
</div>
</CollapsibleCardSection>
</Panel.Content>
)
}