Skip to content

Commit

Permalink
ci: add create cf domain record
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgleam committed Sep 13, 2024
1 parent 12f3492 commit 3471bd0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
28 changes: 26 additions & 2 deletions infra/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import besom.*
import besom.api.hcloud
import hcloud.inputs.*
import besom.api.{kubernetes => k8s}
import besom.api.{cloudflare => cf}

@main def main: Unit = Pulumi.run {
val locations = Vector("fsn1", "nbg1", "hel1")
Expand Down Expand Up @@ -93,7 +94,7 @@ import besom.api.{kubernetes => k8s}
replicas = 1,
containerPort = 8000,
servicePort = 8000,
host = "planktonsoft.com",
host = "demo.planktonsoft.com",
secretKeyBase
)
),
Expand All @@ -103,7 +104,30 @@ import besom.api.{kubernetes => k8s}
)
)

Stack(spawnNodes, writeKubeconfig, k3s, app).exports(
val cfProvider = cf.Provider(
"cloudflare-provider",
cf.ProviderArgs(
apiToken = config.requireString("cloudflare_token")
)
)

val aRecords = serverPool.zipWithIndex.map { case (server, idx) =>
val recordIdx = idx + 1
cf.Record(
s"crappy-board-a-record-$recordIdx",
cf.RecordArgs(
name = "demo.planktonsoft.com",
`type` = "A",
value = server.ipv4Address,
zoneId = config.requireString("cloudflare_zone_id"),
ttl = 1,
proxied = true
),
opts(provider = cfProvider)
)
}.parSequence

Stack(spawnNodes, writeKubeconfig, k3s, app, aRecords).exports(
nodes = nodeIps,
kubeconfigPath = (os.pwd / "kubeconfig.conf").toString,
url = app.flatMap(_.appUrl)
Expand Down
4 changes: 4 additions & 0 deletions infra/Pulumi.crappy-board-prod.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
encryptionsalt: v1:nyAyAY3vQ/0=:v1:8BYEazTyc+8fQkVi:/fgtJaZX+OW6EN+12kNmWIyMHKqC3w==
config:
crappy-board:cloudflare_token:
secure: v1:0uIPBYCLnrqW9TMU:k9+UGOVkVEGHwIyxSx5V07XnbQC1NT00HIstbusEPjZNWqnrbGm91RCFpyfF6nImwzvTFV1prjE=
crappy-board:cloudflare_zone_id:
secure: v1:MM0Nn3XvORpM9Fis:FiGbvE249oNctA/EBd5RN5+lVUObIWMKpuSX7/eeZN9CcUu43NFRsXEK6TBJTAzb
crappy-board:github_docker_token:
secure: v1:zLcD1+iRv8Lxr+qb:zJT6evxyNrx1FsW7jNK6Kpzo+gn9oWpYvaWvc4k4KXSQEehFPOtJp/dVKeLSrdpGicquncJ19qg=
crappy-board:hcloud_token:
Expand Down

0 comments on commit 3471bd0

Please sign in to comment.