-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
17 changed files
with
586 additions
and
7 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,43 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
harbor_credential_path="$1" | ||
|
||
function get_docker_credentials() { | ||
local harbor_credential_path="$1" | ||
|
||
local username="$(yq -r '.name' -oj "$harbor_credential_path")" | ||
local secret="$(yq -r '.secret' -oj "$harbor_credential_path")" | ||
echo "$username:$secret" | ||
} | ||
|
||
credentials="$(get_docker_credentials "$harbor_credential_path")" | ||
encoded_credentials="$(echo -n "$credentials" | base64)" | ||
|
||
auth_settings=$(cat <<EOF | ||
{ | ||
"auths": { | ||
"registry.niaefeup.pt": { | ||
"auth": "$encoded_credentials" | ||
} | ||
} | ||
} | ||
EOF | ||
) | ||
|
||
encoded_auth_settings="$(echo "$auth_settings" | base64 -w 0)" | ||
|
||
cat <<EOF | ||
--- | ||
kind: Secret | ||
apiVersion: v1 | ||
metadata: | ||
namespace: <FILL-IN> | ||
name: harbor-pull-secret | ||
annotations: | ||
replicator.v1.mittwald.de/replicate-to: "<FILL-IN>" | ||
type: kubernetes.io/dockerconfigjson | ||
data: | ||
.dockerconfigjson: $encoded_auth_settings | ||
EOF |
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
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
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
// ementas is an example pulumi service | ||
// import "./services/ementas/index.js"; | ||
import "#resources/replicator/charts.js"; | ||
import "./services/tts/index.js"; | ||
|
||
import { CommitSignal } from "./utils/pending.js"; | ||
CommitSignal.globalParent.resolve(); |
104 changes: 104 additions & 0 deletions
104
services/pulumi/niployments/services/tts/common/backend.ts
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,104 @@ | ||
import * as pulumi from "@pulumi/pulumi"; | ||
import * as k8s from "@pulumi/kubernetes"; | ||
import { Prefixer } from "#utils/prefixer.js"; | ||
|
||
export class TTSBackend extends pulumi.ComponentResource { | ||
public readonly name: pulumi.Output<string>; | ||
public readonly port = pulumi.output(80); | ||
|
||
constructor( | ||
name: string, | ||
args: { | ||
namespace: pulumi.Input<string>; | ||
branch: pulumi.Input<"main" | "develop">; | ||
envSecretRef: pulumi.Input<string>; | ||
}, | ||
opts?: pulumi.ComponentResourceOptions, | ||
) { | ||
super("niployments:tts:TTSBackend", name, opts); | ||
|
||
const prefixer = new Prefixer(name); | ||
|
||
const backendLabels = { app: "tts-backend" }; | ||
const backendPort = 8000; | ||
|
||
const deployment = new k8s.apps.v1.Deployment( | ||
prefixer.deployment(), | ||
{ | ||
metadata: { | ||
namespace: args.namespace, | ||
}, | ||
spec: { | ||
replicas: 1, | ||
selector: { | ||
matchLabels: backendLabels, | ||
}, | ||
template: { | ||
metadata: { | ||
labels: backendLabels, | ||
}, | ||
spec: { | ||
containers: [ | ||
{ | ||
name: "tts-be", | ||
image: pulumi.interpolate`registry.niaefeup.pt/niaefeup/tts-be:${args.branch}`, | ||
imagePullPolicy: "Always", | ||
resources: { | ||
limits: { | ||
memory: "128Mi", | ||
cpu: "500m", | ||
}, | ||
}, | ||
ports: [ | ||
{ | ||
containerPort: backendPort, | ||
}, | ||
], | ||
envFrom: [ | ||
{ | ||
secretRef: { | ||
name: args.envSecretRef, | ||
} | ||
}, | ||
] | ||
}, | ||
], | ||
imagePullSecrets: [ | ||
{ | ||
name: "harbor-pull-secret", | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ parent: this }, | ||
); | ||
|
||
const service = new k8s.core.v1.Service( | ||
prefixer.service(), | ||
{ | ||
metadata: { | ||
namespace: args.namespace, | ||
}, | ||
spec: { | ||
ports: [ | ||
{ | ||
port: this.port, | ||
targetPort: backendPort, | ||
}, | ||
], | ||
selector: backendLabels, | ||
}, | ||
}, | ||
{ parent: this, dependsOn: [deployment] }, | ||
); | ||
|
||
this.name = service.metadata.name; | ||
|
||
this.registerOutputs({ | ||
serviceName: this.name, | ||
servicePort: this.port, | ||
}); | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
services/pulumi/niployments/services/tts/common/frontend.ts
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,96 @@ | ||
import * as pulumi from "@pulumi/pulumi"; | ||
import * as k8s from "@pulumi/kubernetes"; | ||
import { Prefixer } from "#utils/prefixer.js"; | ||
|
||
export class TTSFrontend extends pulumi.ComponentResource { | ||
public readonly name: pulumi.Output<string>; | ||
public readonly port = pulumi.output(80); | ||
|
||
constructor( | ||
name: string, | ||
args: { | ||
namespace: pulumi.Input<string>; | ||
branch: pulumi.Input<"main" | "develop">; | ||
}, | ||
opts?: pulumi.ComponentResourceOptions, | ||
) { | ||
super("niployments:tts:TTSFrontend", name, opts); | ||
|
||
const prefixer = new Prefixer(name); | ||
|
||
const frontendLabels = { app: "tts-frontend" }; | ||
const frontendPort = 80; | ||
|
||
const deployment = new k8s.apps.v1.Deployment( | ||
prefixer.deployment(), | ||
{ | ||
metadata: { | ||
namespace: args.namespace, | ||
}, | ||
spec: { | ||
replicas: 1, | ||
selector: { | ||
matchLabels: frontendLabels, | ||
}, | ||
template: { | ||
metadata: { | ||
labels: frontendLabels, | ||
}, | ||
spec: { | ||
containers: [ | ||
{ | ||
name: "tts-fe", | ||
image: pulumi.interpolate`registry.niaefeup.pt/niaefeup/tts-fe:${args.branch}`, | ||
imagePullPolicy: "Always", | ||
resources: { | ||
limits: { | ||
memory: "128Mi", | ||
cpu: "500m", | ||
}, | ||
}, | ||
ports: [ | ||
{ | ||
containerPort: frontendPort, | ||
}, | ||
], | ||
}, | ||
], | ||
imagePullSecrets: [ | ||
{ | ||
name: "harbor-pull-secret", | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ parent: this }, | ||
); | ||
|
||
const service = new k8s.core.v1.Service( | ||
prefixer.service(), | ||
{ | ||
metadata: { | ||
namespace: args.namespace, | ||
}, | ||
spec: { | ||
ports: [ | ||
{ | ||
port: this.port, | ||
targetPort: frontendPort, | ||
}, | ||
], | ||
selector: frontendLabels, | ||
}, | ||
}, | ||
{ parent: this, dependsOn: [deployment] }, | ||
); | ||
|
||
this.name = service.metadata.name; | ||
|
||
this.registerOutputs({ | ||
serviceName: this.name, | ||
servicePort: this.port, | ||
}); | ||
} | ||
} |
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 @@ | ||
// import "./production/index.js"; | ||
import "./staging/index.js"; |
Oops, something went wrong.