The vault-sync-operator needs to know how to connect to your Vault server. This guide shows how to configure the Vault address for different deployment scenarios.
The default configuration assumes Vault is running inside the cluster with a service named vault. However, Vault is often running:
The Helm chart makes the Vault address easily configurable:
# values.yaml
vault:
address: "http://192.168.1.100:8200" # Your Vault server address
role: "vault-sync-operator"
authPath: "kubernetes"
Deploy with custom address:
helm install vault-sync-operator ./charts/vault-sync-operator \
--namespace vault-sync-operator-system \
--create-namespace \
--set vault.address="http://192.168.1.100:8200"
For kustomize deployments, edit config/manager/manager.yaml:
env:
- name: VAULT_ADDR
value: "http://192.168.1.100:8200" # Change this to your Vault server address
- name: VAULT_ROLE
value: "vault-sync-operator"
- name: VAULT_AUTH_PATH
value: "kubernetes"
Or use a kustomize patch:
# config/manager/vault-address-patch.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
namespace: system
spec:
template:
spec:
containers:
- name: manager
env:
- name: VAULT_ADDR
value: "http://192.168.1.100:8200"
Add to config/default/kustomization.yaml:
patches:
- path: manager_auth_proxy_patch.yaml
- path: ../manager/vault-address-patch.yaml # Add this line
For manual deployments, edit deploy/manual/03-deployment.yaml:
env:
- name: VAULT_ADDR
value: "http://192.168.1.100:8200" # Change this to your Vault server address
- name: VAULT_ROLE
value: "vault-sync-operator"
- name: VAULT_AUTH_PATH
value: "kubernetes"
You can also patch the deployment after it’s deployed:
# Using kubectl patch
kubectl patch deployment vault-sync-operator-controller-manager \
-n vault-sync-operator-system \
--type='merge' \
-p='{"spec":{"template":{"spec":{"containers":[{"name":"manager","env":[{"name":"VAULT_ADDR","value":"http://192.168.1.100:8200"}]}]}}}}'
# Using kubectl set env
kubectl set env deployment/vault-sync-operator-controller-manager \
-n vault-sync-operator-system \
VAULT_ADDR=http://192.168.1.100:8200
# VM with IP address
VAULT_ADDR="http://192.168.1.100:8200"
# VM with hostname
VAULT_ADDR="http://vault.example.com:8200"
# With custom port
VAULT_ADDR="http://192.168.1.100:8201"
# HTTPS with valid certificate
VAULT_ADDR="https://vault.example.com:8200"
# HTTPS with custom port
VAULT_ADDR="https://192.168.1.100:8201"
# Service in same namespace
VAULT_ADDR="http://vault:8200"
# Service in different namespace
VAULT_ADDR="http://vault.vault-system.svc.cluster.local:8200"
# Service with custom name
VAULT_ADDR="http://hashicorp-vault:8200"
# Behind load balancer
VAULT_ADDR="http://vault-lb.example.com:8200"
# Cloud load balancer
VAULT_ADDR="https://vault-12345.elb.amazonaws.com:8200"
After configuring the address, test connectivity:
# Test from the operator pod
kubectl exec -n vault-sync-operator-system deployment/vault-sync-operator-controller-manager -- \
curl -s $VAULT_ADDR/v1/sys/health
# Test from a debug pod
kubectl run debug --image=curlimages/curl --rm -it --restart=Never -- \
curl -s http://192.168.1.100:8200/v1/sys/health
# Check for connection errors
kubectl logs -n vault-sync-operator-system deployment/vault-sync-operator-controller-manager | grep -i vault
# Look for specific error patterns
kubectl logs -n vault-sync-operator-system deployment/vault-sync-operator-controller-manager | grep -E "(connection|refused|timeout|unreachable)"
# Check if port is open
kubectl run netcat --image=busybox --rm -it --restart=Never -- \
nc -zv 192.168.1.100 8200
# Check DNS resolution
kubectl run dns-test --image=busybox --rm -it --restart=Never -- \
nslookup vault.example.com
# Check network policies
kubectl get networkpolicies -A
# Check firewall rules on VM
sudo ufw status
# Check iptables rules
sudo iptables -L
# Test TLS connection
kubectl run tls-test --image=curlimages/curl --rm -it --restart=Never -- \
curl -v https://vault.example.com:8200/v1/sys/health
# Skip TLS verification for testing (not recommended for production)
kubectl run tls-test --image=curlimages/curl --rm -it --restart=Never -- \
curl -k https://vault.example.com:8200/v1/sys/health
# Vault running on host machine (VM)
VAULT_ADDR="http://192.168.1.100:8200"
# Vault running on same VM as k3s
VAULT_ADDR="http://localhost:8200"
# Vault running on docker on the VM
VAULT_ADDR="http://172.17.0.1:8200"
# Vault dev server on host
VAULT_ADDR="http://host.docker.internal:8200"
# Port forwarded Vault
VAULT_ADDR="http://localhost:8200"
# Production Vault with TLS
VAULT_ADDR="https://vault.prod.example.com:8200"
# Vault behind load balancer
VAULT_ADDR="https://vault-api.example.com"
# values-production.yaml
vault:
address: "https://vault.prod.example.com:8200"
role: "vault-sync-operator"
authPath: "kubernetes"
image:
repository: ghcr.io/danieldonoghue/vault-sync-operator
tag: "latest"
pullPolicy: IfNotPresent
controllerManager:
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 10m
memory: 64Mi
# vault-config-patch.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
namespace: system
spec:
template:
spec:
containers:
- name: manager
env:
- name: VAULT_ADDR
value: "https://vault.prod.example.com:8200"
- name: VAULT_ROLE
value: "vault-sync-operator"
- name: VAULT_AUTH_PATH
value: "kubernetes"
Common kubectl commands for Vault address configuration:
# Get current Vault address
kubectl get deployment vault-sync-operator-controller-manager -n vault-sync-operator-system -o jsonpath='{.spec.template.spec.containers[0].env[?(@.name=="VAULT_ADDR")].value}'
# Update Vault address
kubectl set env deployment/vault-sync-operator-controller-manager -n vault-sync-operator-system VAULT_ADDR=http://192.168.1.100:8200
# Restart deployment after configuration change
kubectl rollout restart deployment/vault-sync-operator-controller-manager -n vault-sync-operator-system
# Check deployment status
kubectl rollout status deployment/vault-sync-operator-controller-manager -n vault-sync-operator-system