Walk through a practical example of setting up and using ESI Federation.
esi-cli
without having direct access to Vault.
cluster-main
): Hosts the ESI Federation Server and a Vault instance. Secrets are stored in Vault.client-cluster-alpha
): Hosts an application (Prometheus, in this example) that needs secrets from cluster-main
’s Vault. esi-cli
will be used to fetch these secrets.cluster-main
)ClusterSecretStore
for Vault:
A ClusterSecretStore
named vault-prod
is configured to connect to the local Vault instance.
KubernetesFederation
CR for the client cluster:
This CR registers client-cluster-alpha
with the Federation Server.
kubectl apply -f kf-client-cluster-alpha.yaml
D. Create Authorization
CR for the client’s Service Account:
This CR grants the prometheus-esi-client
ServiceAccount from client-cluster-alpha
permission to access the vault-prod
ClusterSecretStore.
kubectl apply -f auth-allow-alpha-monitoring.yaml
client-cluster-alpha
)prometheus-esi-client
ServiceAccount exists in the monitoring
namespace.
kubectl apply -f sa-prometheus-esi-client.yaml
B. Configure Application Pod to use esi-cli
:
The Prometheus application pod will use esi-cli
in an init container (or as the main container if Prometheus is launched by esi-cli
) to fetch secrets before Prometheus starts.
Here’s an example snippet of a Pod manifest using esi-cli
as an init container:
esi-cli
invocation if esi-cli
directly runs Prometheus:
prometheus-with-federated-secrets
pod starts on client-cluster-alpha
.esi-init
init container (or esi-cli
as main process) starts, using the prometheus-esi-client
ServiceAccount.esi-cli
sends its SA token (from system:serviceaccount:monitoring:prometheus-esi-client
) and its cluster’s CA cert to https://esi-federation.cluster-main.example.com
.cluster-main
validates the token using the JWKS from https://kubeapi.client-alpha.example.com
(derived from the KubernetesFederation
CR).Authorization
CR allow-alpha-monitoring
. It confirms that system:serviceaccount:monitoring:prometheus-esi-client
from client-cluster-alpha
(issuer https://kubernetes.default.svc.cluster.local
) is allowed to access vault-prod
.db-credentials.password
or api-keys.service-a-token
) from its vault-prod
store.esi-cli
on client-cluster-alpha
.esi-cli
injects the secrets as environment variables or files (e.g., sets MY_APP_DB_PASSWORD
or writes to /etc/secrets/service-a.token
).client-cluster-alpha
to consume secrets managed by cluster-main
’s Vault instance without client-cluster-alpha
(or its applications) needing any direct credentials or network access to Vault. The Federation Server acts as a secure intermediary.