This commit is contained in:
Toby
2026-01-27 17:35:45 -05:00
commit 2639af6531
176 changed files with 27104 additions and 0 deletions
@@ -0,0 +1,81 @@
# Kubernetes Authentication for Vault
# Enables pods to authenticate with Vault using service accounts
---
# ServiceAccount for Vault auth
apiVersion: v1
kind: ServiceAccount
metadata:
name: vault-auth
namespace: vault
---
# ClusterRoleBinding for token review
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: vault-tokenreview-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:auth-delegator
subjects:
- kind: ServiceAccount
name: vault-auth
namespace: vault
---
# Secret for SA token (K8s 1.24+)
apiVersion: v1
kind: Secret
metadata:
name: vault-auth-token
namespace: vault
annotations:
kubernetes.io/service-account.name: vault-auth
type: kubernetes.io/service-account-token
---
# Example: Application ServiceAccount
apiVersion: v1
kind: ServiceAccount
metadata:
name: myapp
namespace: myapp
---
# Example: Pod using Vault Agent Injector
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
namespace: myapp
spec:
replicas: 1
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
annotations:
# Vault Agent Injector annotations
vault.hashicorp.com/agent-inject: "true"
vault.hashicorp.com/role: "myapp"
vault.hashicorp.com/agent-inject-secret-config: "secret/data/myapp/config"
vault.hashicorp.com/agent-inject-template-config: |
{{- with secret "secret/data/myapp/config" -}}
DATABASE_URL={{ .Data.data.database_url }}
API_KEY={{ .Data.data.api_key }}
{{- end }}
spec:
serviceAccountName: myapp
containers:
- name: myapp
image: myapp:latest
# Secrets available at /vault/secrets/config
volumeMounts:
- name: secrets
mountPath: /vault/secrets
readOnly: true
@@ -0,0 +1,62 @@
# Vault Server Configuration
# /etc/vault.d/vault.hcl
# Cluster name
cluster_name = "production"
# Storage backend (Raft for HA)
storage "raft" {
path = "/opt/vault/data"
node_id = "vault-1"
retry_join {
leader_api_addr = "https://vault-2.example.com:8200"
}
retry_join {
leader_api_addr = "https://vault-3.example.com:8200"
}
}
# Listener configuration
listener "tcp" {
address = "0.0.0.0:8200"
cluster_address = "0.0.0.0:8201"
tls_cert_file = "/opt/vault/tls/vault.crt"
tls_key_file = "/opt/vault/tls/vault.key"
# TLS settings
tls_min_version = "tls12"
tls_cipher_suites = "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
}
# API address
api_addr = "https://vault.example.com:8200"
cluster_addr = "https://vault-1.example.com:8201"
# UI
ui = true
# Telemetry
telemetry {
prometheus_retention_time = "30s"
disable_hostname = true
}
# Audit logging
# Enable via API after init:
# vault audit enable file file_path=/var/log/vault/audit.log
# Seal configuration (Auto-unseal with AWS KMS)
# seal "awskms" {
# region = "us-east-1"
# kms_key_id = "alias/vault-unseal-key"
# }
# Performance settings
max_lease_ttl = "768h"
default_lease_ttl = "768h"
disable_mlock = false
disable_cache = false
# Plugin directory
plugin_directory = "/opt/vault/plugins"