Vault Installation
This content is not available in your language yet.
Vault is a Centralised Secret Management
Prerequisites
Section titled “Prerequisites”Kubernetes Cluster
Section titled “Kubernetes Cluster”Vault will be installed on 🟢 Management Kubernetes Cluster
- 📥Ingress Service provided as Kubernetes Ingress Class (
IngressClass) - 🛡️TLS Certificate for Vault provided as Kubernetes Secret
- Vault will be exposed as HTTPS with Kubernetes Ingress.
- 💿Persistence Storage as Kubernetes Storage Class (
StorageClass)
Application Dependencies
Section titled “Application Dependencies”Vault depends on multiple dependencies to be up and running but only the following will be provisioned and/or managed by you.
- 📦S3 API-compatible Object Storage ;i.e
SeaweedFS- 🪣S3 Bucket: A Unit of Logical Storage with 🌏Region specified.
- Vault uses 1 bucket.
- For Unseal Key and Root Token Storage after initialised, Auto-Unseal Process.
- Vault uses 1 bucket.
- 🔑Credentials to Access S3 Bucket: Access Key, Secret Key.
- Create/Gather a Dedicated Access Key/Secret Key for Vault to access to its buckets.
- 🪣S3 Bucket: A Unit of Logical Storage with 🌏Region specified.
Complete Prerequisites
Section titled “Complete Prerequisites”Kubernetes Cluster
Section titled “Kubernetes Cluster”Prepare Shell Variables
Section titled “Prepare Shell Variables”Ensure you have defined and loaded your Global Shell Variables as described in Shell Variables.
-
Connect to
🟢 ManagementKubernetes Cluster ; i.e w/ Kubeconfig FileEnsure you have defined and loaded your Global Shell Variables as described in Shell Variables.
Terminal window source $HOME/opstella-installation/shell-values/kubernetes/management_cluster.vars.shsource $HOME/opstella-installation/shell-values/tools/vault.vars.shTerminal window export KUBECONFIG="$HOME/opstella-installation/kubeconfigs/management_cluster.yaml" -
Export Required Shell Variables
Ensure
VAULT_DOMAINis defined as per the Shell Variables guide.Ensure
K8S_INTERNAL_DOMAIN,K8S_INGRESSCLASS_NAME,K8S_STORAGECLASS_NAME,K8S_INGRESS_TLS_CERTIFICATE_SECRET_NAMEare defined as per the Shell Variables guide. Additionally, export the following variables:Terminal window # Infrastructure Configurationexport VAULT_S3_DOMAIN="seaweedfs-api.${BASE_DOMAIN}"export VAULT_S3_BUCKET_NAME="vault"export VAULT_S3_BUCKET_REGION="us-east-1"export VAULT_S3_ACCESS_KEY="vault"export VAULT_S3_ACCESS_SECRET="${SEAWEEDFS_HA_S3_VAULT_PASSWORD}" -
Create Kubernetes Secret for 🛡️ TLS Certificate for Vault in Namespace
devsecops-system.Create one using from
.crtand.keyfile.Terminal window kubectl create secret tls $K8S_INGRESS_TLS_CERTIFICATE_SECRET_NAME \--cert=/path/to/cert/file --key=/path/to/key/file \--namespace devsecops-system💡 Should return
secret/wildcard-...-tls createdmessage.
Application Dependencies
Section titled “Application Dependencies”S3 API-compatible Object Storage
Section titled “S3 API-compatible Object Storage”Set S3 API-compatible Object Storage Information for Vault.
Pre-Installation
Section titled “Pre-Installation”Prepare Vault Auto-Unsealing Configurations
Section titled “Prepare Vault Auto-Unsealing Configurations”-
Install Script Artifact as Kubernetes ConfigMap
You will be creating Kubernetes ConfigMap named
vault-init-scriptfrom Provision AssetsTerminal window # Create Kubernetes ConfigMapkubectl create configmap vault-init-script -n devsecops-system \--from-file=$HOME/opstella-installation/assets/scripts/vault-init.sh💡 Should return
configmap/vault-init-script createdmessage. -
Create S3 Endpoint and Credentials as Kubernetes Secret
S3 Endpoint here will need to specify protocol, will use HTTPS by default.
Terminal window kubectl apply --namespace devsecops-system -f - <<EOFapiVersion: v1kind: Secrettype: Opaquemetadata:name: vault-s3-credentialsstringData:VAULT_AUTO_UNSEAL_METHOD: MINIOVAULT_S3_URL: https://${VAULT_S3_DOMAIN}VAULT_S3_ACCESS_KEY: ${VAULT_S3_ACCESS_KEY}VAULT_S3_ACCESS_SECRET: ${VAULT_S3_ACCESS_SECRET}VAULT_S3_BUCKET_NAME: ${VAULT_S3_BUCKET_NAME}EOF -
Create Kubernetes Service to Point to the First Vault Pod
By create Kubernetes Service with label/selector to pod name.
Terminal window kubectl apply --namespace devsecops-system -f - <<EOFapiVersion: v1kind: Servicemetadata:name: vault-main-headlessspec:clusterIP: Noneselector:statefulset.kubernetes.io/pod-name: vault-0ports:- name: httpprotocol: TCPport: 8200targetPort: 8200- name: https-internalprotocol: TCPport: 8201targetPort: 8201EOF
Prepare Vault Configurations
Section titled “Prepare Vault Configurations”-
Create Helm Values Configurations
Terminal window cat <<EOF > $HOME/opstella-installation/helm-values/vault-full-values.yaml# Application: Enabled Web Interfaceui:enabled: true# Application: Disable Built-in Injector (use ESO+Reloader instead)injector:enabled: falseserver:# Kubernetes/Application: Enabled PersistencedataStorage:enabled: truestorageClass: ${K8S_STORAGECLASS_NAME}# OPSTELLA_CUSTOMIZE/Kubernetes/Application: Auto Unsealing Script, Run after server startedextraArgs: '| /vault/userconfig/scripts/vault-init.sh'# Application: Enabled High Availability (Odd Number of Pods)ha:enabled: truereplicas: 3raft:enabled: truesetNodeId: trueconfig: |ui = truelistener "tcp" {tls_disable = 1address = "[::]:8200"cluster_address = "[::]:8201"# Enable unauthenticated metrics access (necessary for Prometheus Operator)telemetry {unauthenticated_metrics_access = "true"}}storage "raft" {path = "/vault/data"}service_registration "kubernetes" {}# Kubernetes: Config Kubernetes Security ContextstatefulSet:securityContext:pod:fsGroup: 10000runAsGroup: 10000runAsUser: 10000runAsNonRoot: trueseccompProfile:type: RuntimeDefaultcontainer:runAsGroup: 10000runAsUser: 10000runAsNonRoot: trueseccompProfile:type: RuntimeDefault### CONTAINER ONLY KEYS ###privileged: falseallowPrivilegeEscalation: falsecapabilities:drop: ["ALL"]### CONTAINER ONLY KEYS #### Kubernetes: Expose through Ingressingress:enabled: trueingressClassName: ${K8S_INGRESSCLASS_NAME}hosts:- host: ${VAULT_DOMAIN}paths: ["/"]tls:- secretName: ${K8S_INGRESS_TLS_CERTIFICATE_SECRET_NAME}hosts:- ${VAULT_DOMAIN}# Kubernetes: Velero VPC Backup AnnotationconfigAnnotation: trueannotations:backup.velero.io/backup-volumes: data# OPSTELLA_CUSTOMIZE/Kubernetes/Application: Auto Unsealing Script# Provide a S3(-compatible) Connection with CredentialsextraSecretEnvironmentVars:- envName: VAULT_AUTO_UNSEAL_METHODsecretName: vault-s3-credentialssecretKey: VAULT_AUTO_UNSEAL_METHOD- envName: VAULT_S3_URLsecretName: vault-s3-credentialssecretKey: VAULT_S3_URL- envName: VAULT_S3_ACCESS_KEYsecretName: vault-s3-credentialssecretKey: VAULT_S3_ACCESS_KEY- envName: VAULT_S3_ACCESS_SECRETsecretName: vault-s3-credentialssecretKey: VAULT_S3_ACCESS_SECRET- envName: VAULT_S3_BUCKET_NAMEsecretName: vault-s3-credentialssecretKey: VAULT_S3_BUCKET_NAME# OPSTELLA_CUSTOMIZE/Kubernetes/Application: Auto Unsealing Script# Mount the script from Kubernetes ConfigMapvolumes:- name: vault-scriptsconfigMap:name: vault-init-scriptdefaultMode: 0770volumeMounts:- mountPath: /vault/userconfig/scriptsname: vault-scriptsEOF
Installation
Section titled “Installation”-
Add Vault Helm Repository
Terminal window helm repo add hashicorp https://helm.releases.hashicorp.comhelm repo update -
Install Vault
-
Install a Helm Release with specific Helm Chart Version
--version 0.30.1(App Version: 1.20.0)Terminal window helm install vault hashicorp/vault --version 0.30.1 \--namespace devsecops-system \-f $HOME/opstella-installation/helm-values/vault-full-values.yaml
-
Post-Installation
Section titled “Post-Installation”Gather Credentials from Auto-Unsealing Process
Section titled “Gather Credentials from Auto-Unsealing Process”Credentials of Hashicorp Vault will be store on the provided S3-API Compatible Object Storage.
- 🗝️ Vault Unseal Key
- 🗝️ Vault Root Token
- Initial Credentials for Access to Vault.
- Also required for integrating with Opstella.
You can gather it by visiting the Console or Admin Panal of your provided S3-API Compatible Object Storage or Using mc CLI to get the file.
- In case using SeaweedFS Admin Panal
-
Go to
https://seaweedfs-admin.${BASE_DOMAIN}and login with credentials -
Go to Bucket Name
vault. -
You should see files.
rootToken.txtunsealKey.txt
-
Download all of the files.
-
Copy the token from
rootToken.txtto replaceCHANGEMEand run the command to set the variable.export VAULT_TOKEN="CHANGEME"
Next Steps: Setup Single Sign-On with Opstella
Vault Testing
Section titled “Vault Testing”-
Get Pod Status - Vault
Terminal window kubectl get pods -n devsecops-systemVault should be
RunningNAME READY STATUS RESTARTS AGE... (deducted)vault-0 1/1 Running 0 XdXhvault-1 1/1 Running 0 XdXhvault-2 1/1 Running 0 XdXh -
Visit
https://${VAULT_DOMAIN}- It should be accessible.
- TLS Certificate should be valid and coresponding to your TLS Certificate Installed

-
Login with Root Token
- Try to login with Root Token, if success then it works.
Finished?
Use the below navigation to proceed