Skip to content

Pulumi

Creating a SKS cluster with Pulumi

The current folder contains 2 files:

  • Pulumi.yaml defines the Exoscale resources to be created (security group, security group rules, SKS cluster, node pool and kubeconfig file)

  • Pulumi.demo.yaml defines the configuration option to be applied to the Pulumi.yaml in order to create a stack named demo

First we log to the Pulumi cloud (place where the stack state will be stored)

pulumi login

Next we set the env variables so Pulumi can connect to the Exoscale API

export EXOSCALE_API_KEY=...
export EXOSCALE_API_SECRET=...

Next we initialize the demo stack

pulumi stack init demo

We can verify the stack exists in the Pulumi backend

pulumi stack ls

Pulumi stack

Before deploying the stack we preview the resources it will create

pulumi preview

This should return an output similar to the following one:

Previewing update (demo)

View in Browser (Ctrl+O): https://app.pulumi.com/lucj/sks-template/demo/previews/7b2dedb7-0cb5-42df-9980-5404c1ff09d5

     Type                                 Name                            Plan
 +   pulumi:pulumi:Stack                  sks-template-demo               create
 +   ├─ exoscale:index:SecurityGroup      securityGroup                   create
 +   ├─ exoscale:index:SksCluster         cluster                         create
 +   ├─ exoscale:index:SecurityGroupRule  securityGroupRulesKubelet       create
 +   ├─ exoscale:index:SecurityGroupRule  securityGroupRulesCiliumHCICMP  create
 +   ├─ exoscale:index:SecurityGroupRule  securityGroupRulesNodePorts     create
 +   ├─ exoscale:index:SecurityGroupRule  securityGroupRulesCiliumVXLAN   create
 +   ├─ exoscale:index:SksNodepool        nodepool                        create
 +   ├─ exoscale:index:SecurityGroupRule  securityGroupRulesCiliumHCTCP   create
 +   ├─ exoscale:index:SecurityGroupRule  securityGroupRulesPrometheus    create
 +   └─ exoscale:index:SksKubeconfig      kubeconfig                      create

Outputs:
    kubeConfig: output<string>

Resources:
    + 11 to create

Next we deploy the stack, this will create the infrastructure components defined in Pulumi.yaml applying the configuration from Pulumi.demo.yaml

pulumi up

Info

It takes about 2 minutes for the cluster to be available and the associated resources to be available.

Portal

Next we retrieve the kubeconfig file

pulumi stack output kubeConfig --show-secrets > kubeconfig

And configure our local kubectl

export KUBECONFIG=$PWD/kubeconfig

We can then access the cluster

kubectl get nodes

Cleanup

Once we are done we can delete the cluster and its associated resources

# Delete the infrastructure
pulumi destroy

# Remove the stack from Pulumi backend
pulumi stack rm demo

# Remove kubeconfig file
rm $KUBECONFIG