-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1361 from AletheiaFact/stage
Migrate the config.yaml and k8s deployment file generation to PKL
- Loading branch information
Showing
19 changed files
with
585 additions
and
232 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,16 @@ | ||
amends "./modules/main.pkl" | ||
import "./modules/database/mongodb.pkl" | ||
appBaseUrl = "aletheiafact.org" | ||
|
||
var = new { | ||
name = "aletheia-development" | ||
conf { | ||
cors = "*" | ||
recaptcha_sitekey = "6Lc2BtYUAAAAAOUBI-9r1sDJUIfG2nt6C43noOXh" | ||
websocketUrl = "wss://testws.\(appBaseUrl) " | ||
baseUrl = "https://test.\(appBaseUrl)" | ||
db = (mongodb) { | ||
atlas = true | ||
} | ||
} | ||
} |
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 @@ | ||
access_token = read("env:AGENCIA_ACCESS_TOKEN") |
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,3 @@ | ||
bucket = read("env:AWS_SDK_BUCKET") | ||
accessKeyId = read("env:AWS_ACCESS_KEY_ID") | ||
secretAccessKey = read("env:AWS_SECRET_ACCESS_KEY") |
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 @@ | ||
atlas = false | ||
connection_uri = read("env:MONGODB_URI") | ||
options = new { | ||
useUnifiedTopology = true | ||
useNewUrlParser = true | ||
retryWrites = true | ||
w = "majority" | ||
} |
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,3 @@ | ||
url = read("env:GITLAB_FEATURE_FLAG_URL") | ||
appName = read("env:ENV") | ||
instanceId = read("env:GITLAB_FEATURE_FLAG_INSTANCE_ID") |
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,34 @@ | ||
import "./database/mongodb.pkl" | ||
import "./service/confBase.pkl" | ||
import "./ory.pkl" as oryConfig | ||
|
||
|
||
hidden appBaseUrl: String | ||
|
||
hidden var = new { | ||
name = "service-aletheia" | ||
conf = new { | ||
port = 3000 | ||
recaptcha_sitekey = read("env:RECAPTCHA_SITEKEY") | ||
websocketUrl = read("env:WEBSOCKET_URL") | ||
baseUrl = read("env:BASE_URL") | ||
automatedFactCheckingAPIUrl = read("env:AGENTS_API_URL") | ||
recaptcha_secret = read("env:RECAPTCHA_SECRET") | ||
throttle = new confBase.Throttle { | ||
ttl = 60 | ||
limit = 100 | ||
} | ||
ory = (oryConfig) { | ||
admin_endpoint = "admin" | ||
} | ||
} | ||
} | ||
|
||
services = new Listing { | ||
new { | ||
name = var.name | ||
conf = (confBase) { | ||
...var.conf | ||
} | ||
} | ||
} |
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,2 @@ | ||
api_key = read("env:NOVU_API_KEY") | ||
application_identifier = read("env:NOVU_APPLICATION_IDENTIFIER") |
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,2 @@ | ||
api_key = read("env:OPENAI_API_KEY") | ||
|
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,5 @@ | ||
url = read("env:ORY_SDK_URL") | ||
admin_url = read("env:ORY_SDK_URL") | ||
admin_endpoint: String | ||
access_token = read("env:ORY_ACCESS_TOKEN") | ||
schema_id = read("env:ALETHEIA_SCHEMA_ID") |
31 changes: 31 additions & 0 deletions
31
deployment/config/config-file/modules/service/confBase.pkl
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,31 @@ | ||
import "../database/mongodb.pkl" as mongoDbConfig | ||
import "../ory.pkl" as oryConfig | ||
import "../feature_flag.pkl" as featureFlagConfig | ||
import "../aws/s3.pkl" as s3Config | ||
import "../novu.pkl" as novuConfig | ||
import "../openai.pkl" as openaiConfig | ||
import "../zenvia.pkl" as zenviaConfig | ||
import "../agencia.pkl" as agenciaConfig | ||
|
||
class Throttle { | ||
ttl: Number | ||
limit: Number | ||
} | ||
|
||
port: Number | ||
cors: String | ||
websocketUrl: String | ||
baseUrl: String | ||
automatedFactCheckingAPIUrl: String | ||
recaptcha_secret: String | ||
recaptcha_sitekey: String | ||
throttle: Throttle | ||
authentication_type = "ory" | ||
db = (mongoDbConfig) {} | ||
ory = (oryConfig) {} | ||
feature_flag = (featureFlagConfig) {} | ||
aws = (s3Config) {} | ||
novu = (novuConfig) {} | ||
openai = (openaiConfig) {} | ||
zenvia = (zenviaConfig) {} | ||
agencia = (agenciaConfig) {} |
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,2 @@ | ||
api_url = read("env:ZENVIA_API_URL") | ||
api_token = read("env:ZENVIA_API_TOKEN") |
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,16 @@ | ||
amends "./modules/main.pkl" | ||
import "./modules/database/mongodb.pkl" | ||
appBaseUrl = "aletheiafact.org" | ||
|
||
var = new { | ||
name = "aletheia-production" | ||
conf { | ||
cors = "*" | ||
recaptcha_sitekey = "6Lc2BtYUAAAAAOUBI-9r1sDJUIfG2nt6C43noOXh" | ||
websocketUrl = "wss://ws.\(appBaseUrl) " | ||
baseUrl = "https://\(appBaseUrl)" | ||
db = (mongodb) { | ||
atlas = true | ||
} | ||
} | ||
} |
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,92 @@ | ||
import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/K8sResource.pkl" | ||
import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/apps/v1/Deployment.pkl" | ||
import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/core/v1/Service.pkl" | ||
import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/networking/v1/Ingress.pkl" | ||
import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/core/v1/PodSpec.pkl" | ||
import "./modules/ingress.pkl" as ingress | ||
|
||
hidden appNamespace = "development" | ||
hidden podPort = 3000 | ||
|
||
hidden IngressOptions = new { | ||
rules = new {} | ||
} | ||
hidden ServiceOptions = new { | ||
spec = new Service.ServiceSpec { | ||
type = "NodePort" | ||
selector { | ||
["app"] = "aletheia" | ||
} | ||
ports { | ||
new { | ||
name = "aletheia" | ||
targetPort = trace(podPort) | ||
port = 80 | ||
} | ||
} | ||
} | ||
} | ||
hidden DeploymentOptions = new { | ||
replicas = 1 | ||
containers = new Listing<PodSpec.Container> {} | ||
} | ||
|
||
|
||
resources: Listing<K8sResource> = new { | ||
new Ingress { | ||
metadata { | ||
name = "ingress-aletheia" | ||
namespace = appNamespace | ||
annotations { | ||
["kubernetes.io/ingress.class"] = "traefik" | ||
} | ||
} | ||
spec { | ||
rules = new { | ||
for (_rule in IngressOptions.rules) { | ||
_rule | ||
} | ||
} | ||
} | ||
} | ||
|
||
new Service { | ||
metadata { | ||
name = "aletheia" | ||
namespace = appNamespace | ||
} | ||
spec = ServiceOptions.spec | ||
} | ||
|
||
new Deployment { | ||
metadata { | ||
name = "aletheia" | ||
namespace = appNamespace | ||
} | ||
spec { | ||
replicas = DeploymentOptions.replicas | ||
selector { | ||
matchLabels { | ||
["app"] = "aletheia" | ||
} | ||
} | ||
template { | ||
metadata { | ||
labels { | ||
["app"] = "aletheia" | ||
} | ||
} | ||
spec { | ||
containers = DeploymentOptions.containers | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
output { | ||
value = resources | ||
renderer = (K8sResource.output.renderer as YamlRenderer) { | ||
isStream = true | ||
} | ||
} |
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,28 @@ | ||
amends "./app.pkl" | ||
import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/K8sResource.pkl" | ||
import "./modules/ingress.pkl" as ingress | ||
import "./modules/aletheia.pkl" | ||
|
||
appNamespace = "development" | ||
podPort = 3000 | ||
|
||
local newAletheia = new (aletheia) { | ||
ns = appNamespace | ||
p = podPort | ||
} | ||
|
||
IngressOptions { | ||
rules { | ||
(ingress.rule) { | ||
host = "test.aletheiafact.org" | ||
} | ||
} | ||
} | ||
|
||
DeploymentOptions { | ||
containers { | ||
(newAletheia.pod.container) { | ||
name = "aletheia" | ||
} | ||
} | ||
} |
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,11 @@ | ||
import "./container.pkl" as containerConfig | ||
import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/core/v1/PodSpec.pkl" | ||
|
||
hidden ns = "" | ||
hidden p = 3000 | ||
|
||
pod = (containerConfig) { | ||
namespace = ns | ||
imagePath = "134187360702.dkr.ecr.us-east-1.amazonaws.com/aletheiafact-production" + ":" + read("env:TAG") | ||
podPort = p | ||
} |
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,79 @@ | ||
import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/core/v1/EnvVar.pkl" | ||
import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/core/v1/ResourceRequirements.pkl" | ||
import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/core/v1/PodSpec.pkl" | ||
|
||
hidden namespace = "" | ||
hidden imagePath = "" | ||
hidden podPort = "" | ||
|
||
container: PodSpec.Container = new { | ||
name = "" | ||
image = imagePath | ||
imagePullPolicy = "Always" | ||
env = new { | ||
new { | ||
name = "NEXT_PUBLIC_UMAMI_SITE_ID" | ||
value = read("env:UMAMI_SITE_ID") | ||
} | ||
new { | ||
name = "NEXT_PUBLIC_RECAPTCHA_SITEKEY" | ||
value = read("env:RECAPTCHA_SITEKEY") | ||
} | ||
new { | ||
name = "ORY_SDK_URL" | ||
value = read("env:ORY_SDK_URL") | ||
} | ||
new { | ||
name = "ORY_ACCESS_TOKEN" | ||
value = read("env:ORY_ACCESS_TOKEN") | ||
} | ||
new { | ||
name = "NEW_RELIC_LICENSE_KEY" | ||
value = read("env:NEW_RELIC_LICENSE_KEY") | ||
} | ||
new { | ||
name = "NEW_RELIC_APP_NAME" | ||
value = "aletheia-" + namespace | ||
} | ||
new { | ||
name = "NEXT_PUBLIC_ORY_SDK_URL" | ||
value = read("env:ORY_SDK_URL") | ||
} | ||
new { | ||
name = "OPENAI_API_KEY" | ||
value = read("env:OPENAI_API_KEY") | ||
} | ||
new { | ||
name = "ENV_NAME" | ||
value = namespace | ||
} | ||
} | ||
|
||
readinessProbe { | ||
httpGet { | ||
path = "/api/health" | ||
port = podPort | ||
} | ||
initialDelaySeconds = 50 | ||
timeoutSeconds = 5 | ||
} | ||
livenessProbe { | ||
httpGet { | ||
path = "/api/health" | ||
port = podPort | ||
} | ||
initialDelaySeconds = 50 | ||
timeoutSeconds = 10 | ||
failureThreshold = 10 | ||
} | ||
resources { | ||
requests { | ||
["cpu"] = "300m" | ||
["memory"] = 512.mib | ||
} | ||
limits { | ||
["cpu"] = "400m" | ||
["memory"] = 1024.mib | ||
} | ||
} | ||
} |
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,25 @@ | ||
import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/networking/v1/Ingress.pkl" as Ingress | ||
import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/apps/v1/Deployment.pkl" | ||
import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/core/v1/Service.pkl" | ||
import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/K8sResource.pkl" | ||
|
||
rule: Ingress.IngressRule = new { | ||
host = "www.test.aletheiafact.org" | ||
http { | ||
paths { | ||
new { | ||
path = "/" | ||
pathType = "Prefix" | ||
backend { | ||
service { | ||
name = "aletheia" | ||
port { | ||
name = "aletheia" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.