Skip to main content

Kubernetes Workload in GKE

This page shows how to deploy a Kubernetes workload on Google Kubernetes Engine (GKE) using the Fractal SDK.

For prerequisites, setup, and deployment file structure, see the main guide.

Java SDK

public static GoogleKubernetesEngine getGke(String id) {
return GoogleKubernetesEngine.builder()
.withId(id)
.withRegion(EU_WEST1)
.withNodePools(getNodePools())
.withK8sWorkload(getK8sWorkload())
.build();
}

public static CaaSKubernetesWorkload getK8sWorkload() {
return CaaSKubernetesWorkload.builder()
.withId("fractal-samples")
.withDescription("Fractal Service on K8S")
.withNamespace("fractal")
.withSSHRepositoryURI("git@github.com:YanchWare/fractal-samples.git")
.withRepoId("YanchWare/fractal-samples")
.withBranchName("env/prod")
.withEnvironmentSecretShortName("my-secret-name") // Add secret access
// Optional: Use a specific CI/CD profile
//.withCiCdProfileShortName("my-other-cicd-profile")
.build();
}

public static Collection<? extends GcpNodePool> getNodePools() {
return List.of(
GcpNodePool.builder()
.withName("nodes")
.withMachineType(E2_STANDARD2)
.build()
);
}

For more details, see the Custom Workload in GKE sample on GitHub.

TypeScript SDK

import { GcpGkeCluster, LiveSystem } from '@fractal_cloud/sdk';

const gkeCluster = GcpGkeCluster.getBuilder()
.withId('my-gke-cluster')
.withVersion(1, 0, 0)
.withDisplayName('GKE with Custom Workload')
.withKubernetesVersion('1.28.5')
.withNetworkPolicyProvider('calico')
.withNodePools([
{
name: 'nodes',
machineType: 'e2-standard-2',
initialNodeCount: 1,
},
])
.withWorkloadIdentityEnabled(true)
.build();

For more details, see the TypeScript SDK samples on GitHub.