🔐 Vault Integration: Protecting Secret-Zero in a Homelab

This document outlines the current state of my hybrid Kubernetes–HashiCorp Vault solution, implemented in Python via the SecretManager repository. It assumes:

There are ongoing challenges around Certificate Authority (CA) compliance, server certificate generation, and Python compatibility. Until MicroK8s updates its snap to produce RFC 5280-compliant CAs, the automation remains somewhat convoluted. The manual process to work through issues is reflected here.


🧭 Overview of the Current Flow

🖥️ Ansible Host

  1. Inventory Definition
[vault]
moria     ansible_host=192.168.86.9  vmid=106 type=lxc
  1. Role: certificate-authority
  1. Role: generate-keys

🖥️ Proxmox-VE Node

  1. Role: proxmox-container

🔐 Vault Container

  1. Role: copy-ca-to-host
  1. Role: vault-install
  1. Role: vault-configure
  1. Role: vault-initialize

🧬 MicroK8S (before cluster is formed)

  1. Role: microk8s-install

🧠 Final Configuration (from Ansible host)

  1. Role: vault-configure-for-kubevault using the initial root token, configures vault for Kubernetes authentication and Transit AES-256 encryption/decryption as a Service.

✅ Result

At this point, the SecretManager examples should function as designed:

These demonstrate secure, Vault-backed encryption workflows integrated with Kubernetes workloads.


🔭 Future Improvements

🖼️ End-to-End Playbook Flow

The following diagram illustrates the full automation sequence defined in playbooks/00_proxmox.yaml, from CA creation to Vault initialization:

graph TD
  A[Ansible Host: certificate-authority] --> B[Ansible Host: generate-keys]
  B --> C[Ansible Host: Clear known_hosts]
  C --> D[Proxmox Node: proxmox-node-setup]
  D --> E[Proxmox Node: proxmox-template]
  E --> F[Proxmox Node: proxmox-clone]
  F --> G[Proxmox Node: proxmox-vm]
  G --> H[Proxmox Node: proxmox-container: Vault]
  H --> I[Ansible Host: pause for Vault container startup]
  I --> J[Vault Container: copy-ca-to-host]
  J --> K[Vault Container: update-all]
  K --> L[Vault Container: vault-install]
  L --> M[Vault Container: vault-configure]
  M --> N[Vault Container: vault-initialize]

This playbook coordinates tasks across:


In vault.md

Vault is provisioned via Ansible and integrated with MicroK8s for Kubernetes-based authentication. See microk8s.md for cluster setup and secretmanager.md for secrets templating and consumption.

In microk8s.md

This role configures MicroK8s to authenticate with Vault and enables secrets encryption via Vault Transit. See vault.md for Vault provisioning and secretmanager.md for secrets usage patterns.

In secretmanager.md

Secrets are encrypted using Vault Transit and consumed by microservices deployed in MicroK8s. See vault.md for encryption setup and microk8s.md for cluster integration.