diff --git a/.github/actions/deploy/deploy.mjs b/.github/actions/deploy/deploy.mjs index c20a01c088..cae902b397 100644 --- a/.github/actions/deploy/deploy.mjs +++ b/.github/actions/deploy/deploy.mjs @@ -25,7 +25,9 @@ const buildType = BUILD_TYPE || 'canary'; const isProduction = buildType === 'stable'; const isBeta = buildType === 'beta'; +const isCanary = buildType === 'canary'; const isInternal = buildType === 'internal'; +const isSpotEnabled = isBeta || isCanary; const replicaConfig = { stable: { @@ -72,6 +74,9 @@ const createHelmCommand = ({ isDryRun }) => { `--set-string global.indexer.endpoint="${AFFINE_INDEXER_SEARCH_ENDPOINT}"`, `--set-string global.indexer.apiKey="${AFFINE_INDEXER_SEARCH_API_KEY}"`, ]; + const cloudSqlNodeSelector = isBeta + ? `{ \\"iam.gke.io/gke-metadata-server-enabled\\": \\"true\\", \\"cloud.google.com/gke-spot\\": \\"true\\" }` + : `{ \\"iam.gke.io/gke-metadata-server-enabled\\": \\"true\\" }`; const serviceAnnotations = [ `--set-json front.serviceAccount.annotations="{ \\"iam.gke.io/gcp-service-account\\": \\"${APP_IAM_ACCOUNT}\\" }"`, `--set-json graphql.serviceAccount.annotations="{ \\"iam.gke.io/gcp-service-account\\": \\"${APP_IAM_ACCOUNT}\\" }"`, @@ -84,10 +89,18 @@ const createHelmCommand = ({ isDryRun }) => { `--set-json front.services.renderer.annotations="{ \\"cloud.google.com/neg\\": \\"{\\\\\\"ingress\\\\\\": true}\\" }"`, `--set-json graphql.service.annotations="{ \\"cloud.google.com/neg\\": \\"{\\\\\\"ingress\\\\\\": true}\\" }"`, `--set-json cloud-sql-proxy.serviceAccount.annotations="{ \\"iam.gke.io/gcp-service-account\\": \\"${CLOUD_SQL_IAM_ACCOUNT}\\" }"`, - `--set-json cloud-sql-proxy.nodeSelector="{ \\"iam.gke.io/gke-metadata-server-enabled\\": \\"true\\" }"`, + `--set-json cloud-sql-proxy.nodeSelector="${cloudSqlNodeSelector}"`, ] : [] ); + const spotNodeSelector = `{ \\"cloud.google.com/gke-spot\\": \\"true\\" }`; + const spotScheduling = isSpotEnabled + ? [ + `--set-json front.nodeSelector="${spotNodeSelector}"`, + `--set-json graphql.nodeSelector="${spotNodeSelector}"`, + `--set-json doc.nodeSelector="${spotNodeSelector}"`, + ] + : []; const cpu = cpuConfig[buildType]; const memory = memoryConfig[buildType]; @@ -146,6 +159,7 @@ const createHelmCommand = ({ isDryRun }) => { `--set-string doc.app.host="${primaryHost}"`, `--set doc.replicaCount=${replica.doc}`, ...serviceAnnotations, + ...spotScheduling, ...resources, `--timeout 10m`, flag, diff --git a/.github/helm/affine/charts/doc/values.yaml b/.github/helm/affine/charts/doc/values.yaml index d46f418fd8..e0a30a4183 100644 --- a/.github/helm/affine/charts/doc/values.yaml +++ b/.github/helm/affine/charts/doc/values.yaml @@ -30,9 +30,12 @@ podSecurityContext: fsGroup: 2000 resources: - requests: + limits: cpu: '1' memory: 4Gi + requests: + cpu: '1' + memory: 2Gi probe: initialDelaySeconds: 20 diff --git a/.github/helm/affine/charts/front/values.yaml b/.github/helm/affine/charts/front/values.yaml index 2ca34043fe..8d936c5f9a 100644 --- a/.github/helm/affine/charts/front/values.yaml +++ b/.github/helm/affine/charts/front/values.yaml @@ -29,6 +29,9 @@ podSecurityContext: fsGroup: 2000 resources: + limits: + cpu: '1' + memory: 2Gi requests: cpu: '1' memory: 2Gi diff --git a/.github/helm/affine/charts/graphql/values.yaml b/.github/helm/affine/charts/graphql/values.yaml index 3e0da68f69..873ec68840 100644 --- a/.github/helm/affine/charts/graphql/values.yaml +++ b/.github/helm/affine/charts/graphql/values.yaml @@ -27,8 +27,11 @@ podSecurityContext: fsGroup: 2000 resources: + limits: + cpu: '1' + memory: 4Gi requests: - cpu: '2' + cpu: '1' memory: 2Gi probe: