Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ae597cfc4 |
No files matched your search
@@ -1,99 +0,0 @@
|
|||||||
name: Deploy Openbao
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths:
|
|
||||||
- "06-openbao/**"
|
|
||||||
- ".gitea/workflows/06-deploy-openbao.yaml"
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths:
|
|
||||||
- "06-openbao/**"
|
|
||||||
- ".gitea/workflows/**"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
preview:
|
|
||||||
name: Pulumi Preview
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
steps:
|
|
||||||
- name: Checkout Code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: "24"
|
|
||||||
|
|
||||||
- name: Checkout Stack Config
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: kasun/homelab-pulumi-config
|
|
||||||
ref: main
|
|
||||||
token: ${{ secrets.PULUMI_CONFIG_REPO_TOKEN }}
|
|
||||||
path: .pulumi-config
|
|
||||||
persist-credentials: false
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
|
||||||
run: npm ci
|
|
||||||
working-directory: 06-openbao
|
|
||||||
|
|
||||||
- name: Preview
|
|
||||||
uses: pulumi/actions@v5
|
|
||||||
with:
|
|
||||||
command: preview
|
|
||||||
stack-name: dev
|
|
||||||
work-dir: 06-openbao
|
|
||||||
cloud-url: ${{ secrets.PULUMI_BACKEND_URL }}
|
|
||||||
env:
|
|
||||||
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
name: Pulumi Deploy
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
|
||||||
steps:
|
|
||||||
- name: Checkout Code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: "24"
|
|
||||||
|
|
||||||
- name: Checkout Stack Config
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: kasun/homelab-pulumi-config
|
|
||||||
ref: main
|
|
||||||
token: ${{ secrets.PULUMI_CONFIG_REPO_TOKEN }}
|
|
||||||
path: .pulumi-config
|
|
||||||
persist-credentials: false
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
|
||||||
run: npm ci
|
|
||||||
working-directory: 06-openbao
|
|
||||||
|
|
||||||
- name: Refresh State
|
|
||||||
uses: pulumi/actions@v5
|
|
||||||
with:
|
|
||||||
command: refresh
|
|
||||||
stack-name: dev
|
|
||||||
work-dir: 06-openbao
|
|
||||||
cloud-url: ${{ secrets.PULUMI_BACKEND_URL }}
|
|
||||||
env:
|
|
||||||
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
|
|
||||||
|
|
||||||
- name: Deploy
|
|
||||||
uses: pulumi/actions@v5
|
|
||||||
with:
|
|
||||||
command: up
|
|
||||||
stack-name: dev
|
|
||||||
work-dir: 06-openbao
|
|
||||||
cloud-url: ${{ secrets.PULUMI_BACKEND_URL }}
|
|
||||||
env:
|
|
||||||
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
|
|
||||||
@@ -74,11 +74,10 @@ function k3sInstallScript(
|
|||||||
return pulumi.interpolate`set -euo pipefail; IFS= read -r K3S_TOKEN || true; export K3S_TOKEN; curl -sfL ${k3sInstallerUrl} | sudo --preserve-env=K3S_TOKEN INSTALL_K3S_VERSION='${k3sVersion}' ${installEnv} sh -s - ${installArgs}`;
|
return pulumi.interpolate`set -euo pipefail; IFS= read -r K3S_TOKEN || true; export K3S_TOKEN; curl -sfL ${k3sInstallerUrl} | sudo --preserve-env=K3S_TOKEN INSTALL_K3S_VERSION='${k3sVersion}' ${installEnv} sh -s - ${installArgs}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Control-plane VIP — floating IP for API server access, ARP-announced by
|
// Kubernetes API address (port 6443), used by kubectl, Pulumi and joining nodes.
|
||||||
// kube-vip on whichever master is alive. Added as a TLS SAN on master-1's
|
// pfSense holds this IP, and HAProxy forwards connections to the masters, so
|
||||||
// cert below, then used (instead of master1Ip) for every other node's join
|
// the API doesn't depend on a single master.
|
||||||
// URL and for the exported kubeconfig, so the cluster stays reachable
|
// This isn't kubeVipAddress in 03-k8s-infra, which is Traefik's IP for web apps.
|
||||||
// through the loss of any single master.
|
|
||||||
const controlPlaneVipAddress = config.requireSecret("controlPlaneVipAddress");
|
const controlPlaneVipAddress = config.requireSecret("controlPlaneVipAddress");
|
||||||
|
|
||||||
// VM IDs and CI runner SSH key — read from proxmox-infra stack outputs
|
// VM IDs and CI runner SSH key — read from proxmox-infra stack outputs
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ const truenasNfsPath = config.requireSecret("truenasNfsPath");
|
|||||||
const cloudflareToken = config.requireSecret("cloudflareApiToken");
|
const cloudflareToken = config.requireSecret("cloudflareApiToken");
|
||||||
const letsencryptEmail = config.requireSecret("letsencryptEmail");
|
const letsencryptEmail = config.requireSecret("letsencryptEmail");
|
||||||
|
|
||||||
|
// Traefik's IP for web apps (ports 80 and 443). kube-vip announces it on the
|
||||||
|
// LAN, and the app domains in pfSense's DNS Resolver must point to it.
|
||||||
|
// This isn't the Kubernetes API address. That's controlPlaneVipAddress in
|
||||||
|
// 02-k8s-bootstrap, which is provided by pfSense and HAProxy.
|
||||||
const kubeVipAddress = config.requireSecret("kubeVipAddress");
|
const kubeVipAddress = config.requireSecret("kubeVipAddress");
|
||||||
const kubeVipInterface = config.require("kubeVipInterface");
|
const kubeVipInterface = config.require("kubeVipInterface");
|
||||||
|
|
||||||
@@ -547,6 +551,7 @@ const kubeVipCloudProvider = new k8s.apps.v1.Deployment(
|
|||||||
opts({ dependsOn: [cloudProviderClusterRoleBinding, kubeVipPool] }),
|
opts({ dependsOn: [cloudProviderClusterRoleBinding, kubeVipPool] }),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Assigns kubeVipAddress to the Traefik Service that k3s creates.
|
||||||
new k8s.core.v1.ServicePatch(
|
new k8s.core.v1.ServicePatch(
|
||||||
"traefik-vip",
|
"traefik-vip",
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
name: openbao
|
|
||||||
description: Openbao stack for centralized ha secret management
|
|
||||||
runtime:
|
|
||||||
name: nodejs
|
|
||||||
options:
|
|
||||||
packagemanager: npm
|
|
||||||
stackConfigDir: ../.pulumi-config/06-openbao
|
|
||||||
@@ -1,260 +0,0 @@
|
|||||||
import * as pulumi from "@pulumi/pulumi";
|
|
||||||
import * as k8s from "@pulumi/kubernetes";
|
|
||||||
|
|
||||||
const bootstrapRef = new pulumi.StackReference(
|
|
||||||
`${pulumi.getOrganization()}/k8s-bootstrap/dev`,
|
|
||||||
);
|
|
||||||
const appsRef = new pulumi.StackReference(
|
|
||||||
`${pulumi.getOrganization()}/k8s-apps/dev`,
|
|
||||||
);
|
|
||||||
|
|
||||||
const kubeconfig = bootstrapRef.requireOutput("kubeconfig");
|
|
||||||
const domain = appsRef.requireOutput("domain");
|
|
||||||
const openbaoHost = pulumi.interpolate`bao.${domain}`;
|
|
||||||
|
|
||||||
const k8sProvider = new k8s.Provider("k3s", {
|
|
||||||
kubeconfig,
|
|
||||||
clusterIdentifier: "homelab-k3s",
|
|
||||||
});
|
|
||||||
|
|
||||||
const opts = (extras?: pulumi.ResourceOptions): pulumi.ResourceOptions => ({
|
|
||||||
provider: k8sProvider,
|
|
||||||
...extras,
|
|
||||||
});
|
|
||||||
|
|
||||||
const openbaoNs = new k8s.core.v1.Namespace(
|
|
||||||
"openbao",
|
|
||||||
{ metadata: { name: "openbao" } },
|
|
||||||
{ provider: k8sProvider, protect: true },
|
|
||||||
);
|
|
||||||
|
|
||||||
const selfsigned = new k8s.apiextensions.CustomResource(
|
|
||||||
"openbao-selfsigned",
|
|
||||||
{
|
|
||||||
apiVersion: "cert-manager.io/v1",
|
|
||||||
kind: "Issuer",
|
|
||||||
metadata: {
|
|
||||||
name: "openbao-selfsigned",
|
|
||||||
namespace: openbaoNs.metadata.name,
|
|
||||||
},
|
|
||||||
spec: {
|
|
||||||
selfSigned: {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
opts(),
|
|
||||||
);
|
|
||||||
|
|
||||||
const caCert = new k8s.apiextensions.CustomResource(
|
|
||||||
"openbao-ca",
|
|
||||||
{
|
|
||||||
apiVersion: "cert-manager.io/v1",
|
|
||||||
kind: "Certificate",
|
|
||||||
metadata: { name: "openbao-ca", namespace: openbaoNs.metadata.name },
|
|
||||||
spec: {
|
|
||||||
secretName: "openbao-ca",
|
|
||||||
commonName: "openbao-ca",
|
|
||||||
isCA: true,
|
|
||||||
issuerRef: { name: "openbao-selfsigned", kind: "Issuer" },
|
|
||||||
duration: "87600h",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
opts({ dependsOn: [selfsigned] }),
|
|
||||||
);
|
|
||||||
|
|
||||||
const caIssuer = new k8s.apiextensions.CustomResource(
|
|
||||||
"openbao-ca-issuer",
|
|
||||||
{
|
|
||||||
apiVersion: "cert-manager.io/v1",
|
|
||||||
kind: "Issuer",
|
|
||||||
metadata: { name: "openbao-ca", namespace: openbaoNs.metadata.name },
|
|
||||||
spec: {
|
|
||||||
ca: { secretName: "openbao-ca" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
opts({ dependsOn: [caCert] }),
|
|
||||||
);
|
|
||||||
|
|
||||||
const serverCert = new k8s.apiextensions.CustomResource(
|
|
||||||
"openbao-server-tls",
|
|
||||||
{
|
|
||||||
apiVersion: "cert-manager.io/v1",
|
|
||||||
kind: "Certificate",
|
|
||||||
metadata: {
|
|
||||||
name: "openbao-server-tls",
|
|
||||||
namespace: openbaoNs.metadata.name,
|
|
||||||
},
|
|
||||||
spec: {
|
|
||||||
secretName: "openbao-server-tls",
|
|
||||||
dnsNames: [
|
|
||||||
"openbao-0.openbao-internal",
|
|
||||||
"openbao-1.openbao-internal",
|
|
||||||
"openbao-2.openbao-internal",
|
|
||||||
"openbao-active.openbao.svc",
|
|
||||||
"localhost",
|
|
||||||
],
|
|
||||||
ipAddresses: ["127.0.0.1"],
|
|
||||||
issuerRef: { name: "openbao-ca", kind: "Issuer" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
opts({ dependsOn: [caIssuer] }),
|
|
||||||
);
|
|
||||||
|
|
||||||
const serversTransport = new k8s.apiextensions.CustomResource(
|
|
||||||
"openbao-servers-transport",
|
|
||||||
{
|
|
||||||
apiVersion: "traefik.io/v1alpha1",
|
|
||||||
kind: "ServersTransport",
|
|
||||||
metadata: {
|
|
||||||
name: "openbao-servers-transport",
|
|
||||||
namespace: openbaoNs.metadata.name,
|
|
||||||
},
|
|
||||||
spec: {
|
|
||||||
serverName: "openbao-active.openbao.svc",
|
|
||||||
rootCAs: [{ secret: "openbao-server-tls" }],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
opts({ dependsOn: [serverCert] }),
|
|
||||||
);
|
|
||||||
|
|
||||||
new k8s.helm.v3.Release(
|
|
||||||
"openbao",
|
|
||||||
{
|
|
||||||
name: "openbao",
|
|
||||||
chart: "openbao",
|
|
||||||
repositoryOpts: { repo: "https://openbao.github.io/openbao-helm" },
|
|
||||||
namespace: "openbao",
|
|
||||||
version: "0.30.8",
|
|
||||||
// Pods stay unready until they are initialised and unsealed by hand.
|
|
||||||
skipAwait: true,
|
|
||||||
values: {
|
|
||||||
global: {
|
|
||||||
tlsDisable: false,
|
|
||||||
},
|
|
||||||
injector: {
|
|
||||||
enabled: false,
|
|
||||||
},
|
|
||||||
server: {
|
|
||||||
podManagementPolicy: "Parallel",
|
|
||||||
resources: {
|
|
||||||
requests: { cpu: "100m", memory: "256Mi" },
|
|
||||||
limits: { memory: "512Mi" },
|
|
||||||
},
|
|
||||||
volumes: [
|
|
||||||
{ name: "server-tls", secret: { secretName: "openbao-server-tls" } },
|
|
||||||
],
|
|
||||||
volumeMounts: [
|
|
||||||
{
|
|
||||||
name: "server-tls",
|
|
||||||
mountPath: "/openbao/userconfig/openbao-server-tls",
|
|
||||||
readOnly: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
extraEnvironmentVars: {
|
|
||||||
BAO_CACERT: "/openbao/userconfig/openbao-server-tls/ca.crt",
|
|
||||||
},
|
|
||||||
service: {
|
|
||||||
active: {
|
|
||||||
annotations: {
|
|
||||||
"traefik.ingress.kubernetes.io/service.serverstransport":
|
|
||||||
"openbao-openbao-servers-transport@kubernetescrd",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ingress: {
|
|
||||||
enabled: true,
|
|
||||||
ingressClassName: "traefik",
|
|
||||||
annotations: { "cert-manager.io/cluster-issuer": "letsencrypt-prod" },
|
|
||||||
hosts: [{ host: openbaoHost, paths: ["/"] }],
|
|
||||||
tls: [{ secretName: "openbao-ingress-tls", hosts: [openbaoHost] }],
|
|
||||||
},
|
|
||||||
networkPolicy: {
|
|
||||||
enabled: true,
|
|
||||||
ingress: [
|
|
||||||
{
|
|
||||||
from: [
|
|
||||||
{
|
|
||||||
namespaceSelector: {
|
|
||||||
matchLabels: {
|
|
||||||
"kubernetes.io/metadata.name": "kube-system",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
podSelector: {
|
|
||||||
matchLabels: { "app.kubernetes.io/name": "traefik" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
ports: [{ port: 8200, protocol: "TCP" }],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
from: [
|
|
||||||
{
|
|
||||||
podSelector: {
|
|
||||||
matchLabels: {
|
|
||||||
"app.kubernetes.io/name": "openbao",
|
|
||||||
"app.kubernetes.io/instance": "openbao",
|
|
||||||
component: "server",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
ports: [
|
|
||||||
{ port: 8200, protocol: "TCP" },
|
|
||||||
{ port: 8201, protocol: "TCP" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
ha: {
|
|
||||||
enabled: true,
|
|
||||||
replicas: 3,
|
|
||||||
apiAddr: "https://$(BAO_K8S_POD_NAME).openbao-internal:8200",
|
|
||||||
raft: {
|
|
||||||
enabled: true,
|
|
||||||
setNodeId: true,
|
|
||||||
config: `ui = true
|
|
||||||
|
|
||||||
listener "tcp" {
|
|
||||||
address = "[::]:8200"
|
|
||||||
cluster_address = "[::]:8201"
|
|
||||||
tls_cert_file = "/openbao/userconfig/openbao-server-tls/tls.crt"
|
|
||||||
tls_key_file = "/openbao/userconfig/openbao-server-tls/tls.key"
|
|
||||||
tls_auto_reload = true
|
|
||||||
}
|
|
||||||
|
|
||||||
storage "raft" {
|
|
||||||
path = "/openbao/data"
|
|
||||||
|
|
||||||
retry_join {
|
|
||||||
leader_api_addr = "https://openbao-0.openbao-internal:8200"
|
|
||||||
leader_ca_cert_file = "/openbao/userconfig/openbao-server-tls/ca.crt"
|
|
||||||
}
|
|
||||||
retry_join {
|
|
||||||
leader_api_addr = "https://openbao-1.openbao-internal:8200"
|
|
||||||
leader_ca_cert_file = "/openbao/userconfig/openbao-server-tls/ca.crt"
|
|
||||||
}
|
|
||||||
retry_join {
|
|
||||||
leader_api_addr = "https://openbao-2.openbao-internal:8200"
|
|
||||||
leader_ca_cert_file = "/openbao/userconfig/openbao-server-tls/ca.crt"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
service_registration "kubernetes" {}
|
|
||||||
|
|
||||||
audit "file" "stdout" {
|
|
||||||
options {
|
|
||||||
file_path = "stdout"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
dataStorage: {
|
|
||||||
enabled: true,
|
|
||||||
storageClass: "local-path",
|
|
||||||
size: "2Gi",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
opts({ dependsOn: [serversTransport], protect: true }),
|
|
||||||
);
|
|
||||||
Generated
-1499
File diff suppressed because it is too large.
Load diff
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "openbao",
|
|
||||||
"main": "index.ts",
|
|
||||||
"scripts": {
|
|
||||||
"typecheck": "tsc --noEmit"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/node": "^24.19.4",
|
|
||||||
"typescript": "^6.0.3"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@pulumi/kubernetes": "^4.31.1",
|
|
||||||
"@pulumi/pulumi": "^3.278.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"strict": true,
|
|
||||||
"outDir": "bin",
|
|
||||||
"target": "es2024",
|
|
||||||
"module": "nodenext",
|
|
||||||
"moduleResolution": "nodenext",
|
|
||||||
"sourceMap": true,
|
|
||||||
"experimentalDecorators": true,
|
|
||||||
"pretty": true,
|
|
||||||
"noFallthroughCasesInSwitch": true,
|
|
||||||
"noImplicitReturns": true,
|
|
||||||
"forceConsistentCasingInFileNames": true
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"index.ts"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user