https://github.com/dirien/pulumi-aiven-openfaas
Running OpenFaas Pro on Linode K8s (feat. Aiven and Pulumi)
https://github.com/dirien/pulumi-aiven-openfaas
Last synced: 9 months ago
JSON representation
Running OpenFaas Pro on Linode K8s (feat. Aiven and Pulumi)
- Host: GitHub
- URL: https://github.com/dirien/pulumi-aiven-openfaas
- Owner: dirien
- License: apache-2.0
- Created: 2021-08-03T13:04:21.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-02-16T22:06:42.000Z (over 4 years ago)
- Last Synced: 2025-04-04T23:08:58.710Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 91.8 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Running OpenFaas Pro on Linode K8s (feat. Aiven and Pulumi)
Alex Ellis did a great job, when he wrote a tutorial
about [Event-driven OpenFaaS with Managed Kafka from Aiven](https://www.openfaas.com/blog/openfaas-kafka-aiven/).
So this got me hooked. My personal challenge was: **How can I fully automate the deployment of the whole stack.**
To spice up the challenge, I decided to use only Pulumi for this in Go.
## Preparation
Set the API keys for Linode and Aiven and th OpenFaas Pro license via the
```bash
cd 00-infrastructure
pulumi config set linode:token xxx --secret
cd 01-aiven
pulumi config set aiven:apiToken xxx --secret
02-openfaas
pulumi config set openfaas xxx --secret
```
Otherwise, you can't replay the deployment.
## How to
Firs I cut the whole stack into three different Pulumi `Stacks`:
- 00-infrastructure
- 01-aiven
- 02-openfaas
Creating this kind of independent IaC modules, I would consider as good practice. So at the end you can work independent
on a specific stack, without running having this all-in-one single deployment files.
The only dependency we have between the different stacks are the:
[Export](https://www.pulumi.com/docs/intro/concepts/stack/#outputs) of properties, a different stack would need for the
services to provision.
```go
ctx.Export("caCert", pulumi.ToSecret(project.CaCert))
```
On the other side to consume the outputs in a different stack, you just need to get
the [stack reference](https://www.pulumi.com/docs/intro/concepts/stack/#stackreferences).
```go
aiven, err := pulumi.NewStackReference(ctx, "dirien/01-aiven/dev", nil)
if err != ...
caCert := aiven.GetStringOutput(pulumi.String("caCert"))
```
Now you can `pulumi up` every folder and your whole stack gets deployed.
So running a deployment of a larger app with different layers (infra, managed services and app) is becoming more and
more accessible and enables us to work more in a DevOps fashion inside our team.
## Alternative solutions
An alternative solution would be, to use Pulumi for the provisioning of the infrastructure and manged services and
bootstrapping a GitOps engine (like Flux2 or ArgoCD).
Another solution could be to just provision your kubernetes infrastructure and use [Crossplane](https://crossplane.io/)
to provision the "real" infrastructure.