fix: Gitea | add ssh tcp ingress route for traefik
This commit is contained in:
@@ -2,9 +2,14 @@ import * as fs from "fs";
|
|||||||
import { HelmProvider } from "@cdktf/provider-helm/lib/provider";
|
import { HelmProvider } from "@cdktf/provider-helm/lib/provider";
|
||||||
import { Release } from "@cdktf/provider-helm/lib/release";
|
import { Release } from "@cdktf/provider-helm/lib/release";
|
||||||
import { Construct } from "constructs";
|
import { Construct } from "constructs";
|
||||||
|
import { Manifest } from "@cdktf/provider-kubernetes/lib/manifest";
|
||||||
|
import { KubernetesProvider } from "@cdktf/provider-kubernetes/lib/provider";
|
||||||
|
|
||||||
type GiteaServerOptions = {
|
type GiteaServerOptions = {
|
||||||
provider: HelmProvider;
|
providers: {
|
||||||
|
helm: HelmProvider;
|
||||||
|
kubernetes: KubernetesProvider;
|
||||||
|
};
|
||||||
name: string;
|
name: string;
|
||||||
namespace: string;
|
namespace: string;
|
||||||
r2Endpoint: string;
|
r2Endpoint: string;
|
||||||
@@ -14,8 +19,11 @@ export class GiteaServer extends Construct {
|
|||||||
constructor(scope: Construct, id: string, options: GiteaServerOptions) {
|
constructor(scope: Construct, id: string, options: GiteaServerOptions) {
|
||||||
super(scope, id);
|
super(scope, id);
|
||||||
|
|
||||||
|
const { kubernetes, helm } = options.providers;
|
||||||
|
|
||||||
new Release(this, id, {
|
new Release(this, id, {
|
||||||
...options,
|
...options,
|
||||||
|
provider: helm,
|
||||||
repository: "https://dl.gitea.com/charts",
|
repository: "https://dl.gitea.com/charts",
|
||||||
chart: "gitea",
|
chart: "gitea",
|
||||||
createNamespace: true,
|
createNamespace: true,
|
||||||
@@ -31,5 +39,31 @@ export class GiteaServer extends Construct {
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
new Manifest(this, `${id}-ssh-ingress`, {
|
||||||
|
provider: kubernetes,
|
||||||
|
manifest: {
|
||||||
|
apiVersion: "traefik.io/v1alpha1",
|
||||||
|
kind: "IngressRouteTCP",
|
||||||
|
metadata: {
|
||||||
|
name: "gitea-ssh-ingress",
|
||||||
|
namespace: options.namespace,
|
||||||
|
},
|
||||||
|
spec: {
|
||||||
|
entryPoints: ["ssh"],
|
||||||
|
routes: [
|
||||||
|
{
|
||||||
|
match: "HostSNI(`*`)",
|
||||||
|
services: [
|
||||||
|
{
|
||||||
|
name: `${options.name}-ssh`,
|
||||||
|
port: 22,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,3 +16,13 @@ topologySpreadConstraints:
|
|||||||
labelSelector:
|
labelSelector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: traefik
|
app: traefik
|
||||||
|
additionalArguments:
|
||||||
|
- "--entryPoints.ssh.address=:22/tcp"
|
||||||
|
ports:
|
||||||
|
ssh:
|
||||||
|
name: ssh
|
||||||
|
port: 22
|
||||||
|
exposedPort: 22
|
||||||
|
expose:
|
||||||
|
default: true
|
||||||
|
protocol: TCP
|
||||||
|
|||||||
5
main.ts
5
main.ts
@@ -142,7 +142,10 @@ class Homelab extends TerraformStack {
|
|||||||
const gitea = new GiteaServer(this, "gitea-server", {
|
const gitea = new GiteaServer(this, "gitea-server", {
|
||||||
name: "gitea",
|
name: "gitea",
|
||||||
namespace,
|
namespace,
|
||||||
provider: helm,
|
providers: {
|
||||||
|
helm,
|
||||||
|
kubernetes,
|
||||||
|
},
|
||||||
r2Endpoint: `${env.ACCOUNT_ID}.r2.cloudflarestorage.com`,
|
r2Endpoint: `${env.ACCOUNT_ID}.r2.cloudflarestorage.com`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user