-
-
Save kennyjwilli/8ef9540117351cc69dc2b98c473ce99e to your computer and use it in GitHub Desktop.
k8s dashboard via helm chart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as pulumi from "@pulumi/pulumi"; | |
import * as aws from "@pulumi/aws"; | |
import * as awsx from "@pulumi/awsx"; | |
import * as k8s from "@pulumi/kubernetes"; | |
import * as eks from "@pulumi/eks"; | |
const managedPolicyArns: string[] = [ | |
"arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy", | |
"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy", | |
"arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly", | |
]; | |
// Creates a role and attches the EKS worker node IAM managed policies | |
export function createRole(name: string): aws.iam.Role { | |
const role = new aws.iam.Role(name, { | |
assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal({ | |
Service: "ec2.amazonaws.com", | |
}), | |
}); | |
let counter = 0; | |
for (const policy of managedPolicyArns) { | |
// Create RolePolicyAttachment without returning it. | |
const rpa = new aws.iam.RolePolicyAttachment(`${name}-policy-${counter++}`, | |
{ policyArn: policy, role: role }, | |
); | |
} | |
return role; | |
} | |
const vpc = awsx.ec2.Vpc.getDefault(); | |
const role0 = createRole("example-role0"); | |
const instanceProfile0 = new aws.iam.InstanceProfile("example-instanceProfile0", {role: role0}); | |
const eksCluster = new eks.Cluster("k8s-cluster", { | |
vpcId: vpc.id, | |
subnetIds: vpc.publicSubnetIds, | |
deployDashboard: false, | |
skipDefaultNodeGroup: true, | |
instanceRole: role0 | |
}); | |
eksCluster.createNodeGroup("k8s-ng", { | |
instanceType: "t2.medium", | |
desiredCapacity: 2, | |
minSize: 1, | |
maxSize: 2, | |
instanceProfile: instanceProfile0 | |
}); | |
const k8sDashboardChart = new k8s.helm.v2.Chart("kubernetes-dashboard", { | |
repo: "stable", | |
chart: "kubernetes-dashboard", | |
version: "1.5.2", | |
}, {providers: {kubernetes: eksCluster.provider}}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment