added heimdall and longhorn deplyoment

This commit is contained in:
2026-06-06 00:38:01 +02:00
parent 37395e3a4d
commit b61759c3c0
7 changed files with 3078 additions and 4 deletions
+6
View File
@@ -0,0 +1,6 @@
name: k8s-apps
description: Application workloads for the k3s homelab cluster
runtime:
name: nodejs
options:
packagemanager: npm
+133
View File
@@ -0,0 +1,133 @@
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";
const config = new pulumi.Config();
//fetch credentials from k8s-bootstrap
const bootstrapRef = new pulumi.StackReference(
`${pulumi.getOrganization()}/k8s-bootstrap/dev`,
);
const kubeconfig = bootstrapRef.requireOutput("kubeconfig");
const domain = config.require("domain");
const k8sProvider = new k8s.Provider("k3s", { kubeconfig });
const opts = (extras?: pulumi.ResourceOptions): pulumi.ResourceOptions => ({
provider: k8sProvider,
...extras,
});
const ns = new k8s.core.v1.Namespace(
"heimdall",
{ metadata: { name: "heimdall" } },
opts(),
);
const pvc = new k8s.core.v1.PersistentVolumeClaim(
"heimdall-config",
{
metadata: { name: "heimdall-config", namespace: ns.metadata.name },
spec: {
accessModes: ["ReadWriteOnce"],
storageClassName: "longhorn",
resources: { requests: { storage: "50Mi" } },
},
},
opts(),
);
const labels = { app: "heimdall" };
new k8s.apps.v1.Deployment(
"heimdall",
{
metadata: {
name: "heimdall",
namespace: ns.metadata.name,
annotations: { "pulumi.com/patchForce": "true" },
},
spec: {
replicas: 1,
selector: { matchLabels: labels },
template: {
metadata: { labels },
spec: {
containers: [
{
name: "heimdall",
image: "lscr.io/linuxserver/heimdall:latest",
env: [
{ name: "PUID", value: "1000" },
{ name: "PGID", value: "1000" },
],
ports: [{ containerPort: 80 }],
volumeMounts: [{ name: "config", mountPath: "/config" }],
},
],
volumes: [
{
name: "config",
persistentVolumeClaim: { claimName: pvc.metadata.name },
},
],
terminationGracePeriodSeconds: 5,
},
},
},
},
opts(),
);
const svc = new k8s.core.v1.Service(
"heimdall",
{
metadata: { name: "heimdall", namespace: ns.metadata.name },
spec: {
selector: labels,
ports: [{ port: 80, targetPort: 80 }],
type: "ClusterIP",
},
},
opts(),
);
const host = pulumi.interpolate`heimdall.${domain}`;
new k8s.networking.v1.Ingress(
"heimdall",
{
metadata: {
name: "heimdall",
namespace: ns.metadata.name,
annotations: {
"cert-manager.io/cluster-issuer": "letsencrypt-prod",
},
},
spec: {
ingressClassName: "traefik",
tls: [{ hosts: [host], secretName: "heimdall-tls" }],
rules: [
{
host,
http: {
paths: [
{
path: "/",
pathType: "Prefix",
backend: {
service: {
name: svc.metadata.name,
port: { number: 80 },
},
},
},
],
},
},
],
},
},
opts(),
);
export const ingressHost = host;
+2799
View File
File diff suppressed because it is too large Load Diff
+12
View File
@@ -0,0 +1,12 @@
{
"name": "k8s-apps",
"main": "index.ts",
"devDependencies": {
"@types/node": "^18",
"typescript": "^5.0.0"
},
"dependencies": {
"@pulumi/kubernetes": "^4.0.0",
"@pulumi/pulumi": "^3.113.0"
}
}
+18
View File
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"strict": true,
"outDir": "bin",
"target": "es2020",
"module": "nodenext",
"moduleResolution": "nodenext",
"sourceMap": true,
"experimentalDecorators": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.ts"
]
}