vault

by joaquinito2051

Helm chartv0.18.7App 1.0.1

A Helm chart for Vault, a tool for managing secrets

About this chart

Vault Helm Chart

This directory contains a Kubernetes chart to deploy a Vault server.

Prerequisites Details

  • Kubernetes 1.6+

Chart Details

This chart will do the following:

  • Implement a Vault deployment
  • Optionally, deploy a consul agent in the pod

Please note that a backend service for Vault (for example, Consul) must be deployed beforehand and configured with the vault.config option. YAML provided under this option will be converted to JSON for the final Vault config.json file.

See https://www.vaultproject.io/docs/configuration/ for more information.

Installing the Chart

To install the chart, use the following, this backs Vault with a Consul cluster:

$ helm install <helm-repo>/vault --set vault.dev=false --set vault.config.storage.consul.address="myconsul-svc-name:8500",vault.config.storage.consul.path="vault"

$ helm install incubator/vault --set vault.dev=false --set vault.config.storage.consul.address="myconsul-svc-name:8500",vault.config.storage.consul.path="vault" An alternative example using the Amazon S3 backend can be specified using:

vault:
  config:
    storage:
      s3:
        access_key: "AWS-ACCESS-KEY"
        secret_key: "AWS-SECRET-KEY"
        bucket: "AWS-BUCKET"
        region: "eu-central-1"

Configuration

The following table lists the configurable parameters of the Vault chart and their default values.

ParameterDescriptionDefault
imagePullSecretThe name of the secret to use if pulling from a private registrynil
image.pullPolicyContainer pull policyIfNotPresent
image.repositoryContainer image to usevault
image.tagContainer image tag to deploy.Chart.appVersion
vault.devUse Vault in dev modetrue (set to false in production)
vault.extraEnvExtra env vars for Vault pods{}
vault.extraContainersSidecar containers to add to the vault pod{}
vault.extraInitContainersInit containers to be added to the vault pod{}
vault.extraVolumesAdditional volumes to the controller pod{}
vault.extraVolumeMountsExtra volumes to mount to the controller pod{}
vault.existingConfigNameLocation of existing Vault configurationnil
vault.configVault configurationNo default backend
replicaCountk8s replicas3
resources.limits.cpuContainer requested CPUnil
resources.limits.memoryContainer requested memorynil
affinityAffinity settingsSee values.yaml
service.loadBalancerIPAssign a static IP to the loadbalancernil
service.loadBalancerSourceRangesIP whitelist for service type loadbalancer[]
service.annotationsAnnotations for service{}
service.externalPortExternal port for the service8200
service.portThe API port Vault is using8200
service.clusterExternalPortExternal cluster port for the servicenil
service.clusterPortThe cluster port Vault is using8201
annotationsAnnotations for deployment{}
labelsExtra labels for deployment{}
ingress.labelsLabels for ingress{}
podAnnotationsAnnotations for pods{}
podLabelsExtra labels for pods{}
serviceAccount.createSpecifies whether a ServiceAccount should be createdfalse
consulAgent.joinIf set, start start a consul agentnil
consulAgent.repositoryContainer image for consul agentconsul
consulAgent.tagContainer image tag for consul agent1.4.0
consulAgent.pullPolicyContainer pull policy for consul agentIfNotPresent
consulAgent.gossipKeySecretNamek8s secret containing gossip keynil (see values.yaml for details)
consulAgent.HttpPortHTTP port for consul agent API8500
consulAgent.resourcesContainer resources for consul agentnil
vaultExporter.enabledEnable or disable vault exporterfalse
vaultExporter.repositoryContainer image for vault exportergrapeshot/vault_exporter
vaultExporter.tagContainer image tag for vault exporterv0.1.2
vaultExporter.pullPolicyImage pull policy that sould be usedIfNotPresent
vaultExporter.vaultAddressVault address that exporter should use127.0.0.1:8200
vaultExporter.tlsCAFileVault TLS CA certificate mount path/vault/tls/ca.crt

Specify each parameter using the --set key=value[,key=value] argument to helm install.

Optional Consul Agent

Specify each parameter using the --set key=value[,key=value] argument to helm install.

If you are using the consul storage for vault, you might want a local consul agent to handle health checks. By setting consulAgent.join to your consul server, an agent will be started in the vault pod. In this case, you should configure vault to connect to consul over localhost. For example:

vault:
  dev: False
  config:
    storage:
      consul:
        address: "localhost:8500"
consulAgent:
  join: consul.service.consul

If you are using the stable/consul helm chart, consul communications are encrypted with a gossip key. You can configure a secret with the same format as that chart and specify it in the consulAgent.gossipKeySecretName parameter.

Optional Vault Exporter

If you want to monitor Vault with Prometheus you can simply enable the Vault exporter which then runs as a sidecar container within the same pod as Vault itself. To use the exporter just set vaultExporter.enabled to true and set the other variables according to your needs.

If your Vault is set up with TLS make sure to specify the CA certificate path properly. This is done through the parameter vaultExporter.tlsCAFile.

Using Vault

Once the Vault pod is ready, it can be accessed using a kubectl port-forward:

$ kubectl port-forward vault-pod 8200
$ export VAULT_ADDR=http://127.0.0.1:8200
$ vault status

Migrating Custom Secrets

Previous versions of this chart had a configuration option vault.customSecrets. Custom secrets should now be expressed with vault.extraVolumeMounts. For example:

vault:
  customSecrets:
    - secretName: vault-tls
      mountPath: /vault/tls

Would be expressed as:

vault:
  extraVolumes:
    - name: vault-tls
      secret:
        secretName: vault-tls
  extraVolumeMounts:
    - name: vault-tls
      mountPath: /vault/tls
      readOnly: true

Deploy vault with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has vault on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartvault is pinned at v0.18.7 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply