Skip to content

Instantly share code, notes, and snippets.

@reoring
Last active April 16, 2023 22:49
Show Gist options
  • Save reoring/c8a24fec54f6954b8adfce8893468be7 to your computer and use it in GitHub Desktop.
Save reoring/c8a24fec54f6954b8adfce8893468be7 to your computer and use it in GitHub Desktop.
"Multi Cloud Kubernetes Cluster with Cilium" generated by Pulumi AI
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
import * as eks from "@pulumi/eks";
import * as azure from "@pulumi/azure";
import * as k8s from "@pulumi/kubernetes";
// Create an AWS VPC.
const vpc = new awsx.ec2.Vpc("vpc");
// Create an AWS EKS cluster.
const eksCluster = new eks.Cluster("eksCluster", {
vpcId: vpc.id,
subnetIds: vpc.privateSubnetIds,
tags: {
"cloud": "aws",
},
});
// Create an Azure AKS cluster.
const resourceGroup = new azure.core.ResourceGroup("resourceGroup");
const aksCluster = new azure.containerservice.KubernetesCluster("aksCluster", {
location: resourceGroup.location,
resourceGroupName: resourceGroup.name,
dnsPrefix: "aks",
agentPoolProfiles: [{
name: "agent",
count: 2,
vmSize: "Standard_D2_v2",
}],
linuxProfile: {
adminUsername: "admin",
sshKey: {
keyData: "<your-public-ssh-key>",
},
},
tags: {
"cloud": "azure",
},
});
// Create a Kubernetes provider for each cluster.
const awsProvider = new k8s.Provider("awsProvider", { kubeconfig: eksCluster.kubeconfig });
const azureProvider = new k8s.Provider("azureProvider", { kubeconfig: aksCluster.kubeAdminConfigRaw });
// Deploy Cilium to both clusters.
const ciliumValues: any = {
agent: {
enabled: false,
},
config: {
enableEndpointRoutes: true,
},
global: {
kubeProxy: {
enabled: false,
},
tunnel: "vxlan",
},
};
const ciliumRelease = (clusterName: string, provider: k8s.Provider) => {
const cilium = new k8s.helm.v3.Chart(
`${clusterName}-cilium`,
{
chart: "cilium",
namespace: "kube-system",
fetchOpts: {
repo: "https://helm.cilium.io/",
},
values: ciliumValues,
},
{
provider: provider,
}
);
};
ciliumRelease("awsCluster", awsProvider);
ciliumRelease("azureCluster", azureProvider);
// Export the kubeconfig of both clusters.
export const awsKubeconfig = eksCluster.kubeconfig;
export const azureKubeconfig = aksCluster.kubeAdminConfigRaw;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment