-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c0bb33
commit 501318b
Showing
5 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
### Scala an JVM | ||
*.class | ||
*.log | ||
.bsp | ||
.scala-build | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
|
||
kubeconfig.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import besom.* | ||
import besom.api.aws | ||
import besom.api.eks | ||
import besom.api.kubernetes as k8s | ||
|
||
@main def main = Pulumi.run { | ||
// Get the default VPC and select the default subnet | ||
val vpc = aws.ec2.getVpc(aws.ec2.GetVpcArgs(default = true)) | ||
val subnet = vpc.flatMap(vpc => | ||
aws.ec2.getSubnet( | ||
aws.ec2.GetSubnetArgs( | ||
vpcId = vpc.id, | ||
defaultForAz = true | ||
) | ||
) | ||
) | ||
|
||
// Create an EKS cluster using the default VPC and subnet | ||
val cluster = eks.Cluster( | ||
"my-cluster", | ||
eks.ClusterArgs( | ||
vpcId = vpc.id, | ||
subnetIds = List(subnet.id), | ||
instanceType = "t2.medium", | ||
desiredCapacity = 2, | ||
minSize = 1, | ||
maxSize = 3, | ||
storageClasses = "gp2" | ||
) | ||
) | ||
|
||
val k8sProvider = k8s.Provider( | ||
"k8s-provider", | ||
k8s.ProviderArgs( | ||
kubeconfig = cluster.kubeconfigJson | ||
) | ||
) | ||
|
||
val pod = k8s.core.v1.Pod( | ||
"mypod", | ||
k8s.core.v1.PodArgs( | ||
spec = k8s.core.v1.inputs.PodSpecArgs( | ||
containers = List( | ||
k8s.core.v1.inputs.ContainerArgs( | ||
name = "echo", | ||
image = "k8s.gcr.io/echoserver:1.4" | ||
) | ||
) | ||
) | ||
), | ||
opts = opts( | ||
provider = k8sProvider, | ||
dependsOn = cluster, | ||
deletedWith = cluster // skip deletion to save time, since it will be deleted with the cluster | ||
) | ||
) | ||
|
||
// Export the cluster's kubeconfig | ||
Stack(cluster, pod).exports(kubeconfig = cluster.kubeconfig) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: aws-eks | ||
description: EKS cluster example | ||
runtime: scala | ||
template: | ||
config: | ||
aws:region: | ||
description: The AWS region to deploy into | ||
default: us-west-2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Amazon EKS Cluster | ||
|
||
This example deploys an EKS Kubernetes cluster with an EBS-backed StorageClass. | ||
|
||
## Prerequisites | ||
|
||
[Follow the instructions](https://www.pulumi.com/docs/clouds/aws/get-started/begin/) | ||
to get started with Pulumi & AWS. | ||
|
||
## Deploying | ||
|
||
Note: some values in this example will be different from run to run. | ||
These values are indicated with `***`. | ||
|
||
1. Create a new stack, which is an isolated deployment target for this example: | ||
|
||
```bash | ||
pulumi stack init aws-eks-dev | ||
``` | ||
|
||
2. Set the AWS region: | ||
|
||
```bash | ||
pulumi config set aws:region us-west-2 | ||
``` | ||
|
||
We recommend using `us-west-2` to host your EKS cluster as other regions (notably `us-east-1`) may have capacity issues that prevent EKS | ||
clusters from creating. | ||
|
||
We are tracking enabling the creation of VPCs limited to specific AZs to unblock this in `us-east-1`: pulumi/pulumi-awsx#32 | ||
|
||
3. Stand up the EKS cluster: | ||
|
||
```bash | ||
pulumi up | ||
``` | ||
4. After 10-15 minutes, your cluster will be ready, and the `kubeconfig` JSON you'll use to connect to the cluster will | ||
be available as an output. You can save this `kubeconfig` to a file like so: | ||
|
||
```bash | ||
pulumi stack output kubeconfig --show-secrets > kubeconfig.json | ||
``` | ||
|
||
Once you have this file in hand, you can interact with your new cluster as usual via `kubectl`: | ||
|
||
```bash | ||
kubectl --kubeconfig=./kubeconfig.json get pods --all-namespaces | ||
``` | ||
|
||
5. To clean up resources, destroy your stack and remove it: | ||
|
||
```bash | ||
pulumi destroy | ||
``` | ||
```bash | ||
pulumi stack rm aws-eks | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//> using scala "3.3.1" | ||
//> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement | ||
//> using plugin "org.virtuslab::besom-compiler-plugin:0.2.0-SNAPSHOT" | ||
//> using dep "org.virtuslab::besom-core:0.2.0-SNAPSHOT" | ||
//> using dep "org.virtuslab::besom-eks:2.2.1-core.0.2-SNAPSHOT" | ||
//> using repository sonatype:snapshots |