Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99cf885600 | ||
|
|
33f72fb88c | ||
|
|
01999ce28f | ||
|
|
8e87e33937 | ||
|
|
1c1a1b2441 |
No files matched your search
@@ -0,0 +1,99 @@
|
|||||||
|
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 }}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
name: openbao
|
||||||
|
description: Openbao stack for centralized ha secret management
|
||||||
|
runtime:
|
||||||
|
name: nodejs
|
||||||
|
options:
|
||||||
|
packagemanager: npm
|
||||||
|
stackConfigDir: ../.pulumi-config/06-openbao
|
||||||
@@ -0,0 +1,260 @@
|
|||||||
|
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
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"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