Connect to managed clusters (GKE, EKS, AKS)¶
This page shows how to run piceli release against a managed cluster whose
kubeconfig authenticates through an exec credential plugin
(gke-gcloud-auth-plugin, aws eks get-token, kubelogin, an OIDC login
plugin), and what Piceli does to keep that safe.
Maturity: preview. The [target] keys allow_exec, exec_sha256,
exec_pass_env and exec_timeout_seconds and the error codes listed here may
still change before 1.0. Scripts should match on the error codes.
How it works¶
An exec plugin is a local program that kubectl (and Piceli) runs to get a
short-lived credential. Running it is code execution with your cloud login,
so Piceli never does it implicitly:
Opt-in. A context whose user has an
execblock is refused (exec-auth-not-allowed) unless[target]setsallow_exec = true. The plugin does not run before that.Pinned. The command is resolved once to an absolute real path: a bare name such as
gke-gcloud-auth-pluginis looked up inPATH, a relative path is resolved from the kubeconfig’s directory, and symlinks are followed. Piceli records the file’s sha256 and, whenexec_sha256is set, refuses a different file (exec-pin-mismatch). The file is hashed again before every run, so a binary replaced during a run is refused too. Files writable by their group or other users are refused (exec-command-unsafe).Minimal environment. The plugin receives only:
PATHandHOMEfrom Piceli’s environment (plugins find their tools and their login cache through them);the variables you name in
exec_pass_env(for exampleAWS_PROFILE), copied from Piceli’s environment;the
enventries of the kubeconfig’sexecblock;LANG=CandKUBERNETES_EXEC_INFO(the Kubernetes exec protocol input, withinteractive: false, plus the server and CA when the kubeconfig setsprovideClusterInfo: true).
Nothing else is inherited: no cloud credentials in variables you did not name, no
KUBECONFIG.Non-interactive and bounded. stdin is closed, the run is stopped after
exec_timeout_seconds(default 60), and output is limited to 1 MB. Plugins that require a terminal (interactiveMode: Always) are refused. The plugin’s own messages (stderr) are shown on Piceli’s stderr, askubectldoes; its stdout, which carries the credential, is never printed or logged.In memory only. Tokens live in the client’s memory. Client certificates returned by a plugin are passed to OpenSSL through pipes, not files. The cluster CA is read from the kubeconfig in memory as well.
Refresh owned by Piceli. Before each API request Piceli checks the credential’s
expirationTimestampand re-runs the same pinned plugin when less thanmin(30 s, lifetime / 2)remains. A credential without an expiry is reused for the whole command.KubernetesProvideraccepts a credential-refresh hook only when Piceli’s exec source installed it on that exact client; any other refresh hook is still refused.
Still refused, with or without allow_exec:
legacy
auth-providerusers (gcp,oidc,azure):auth-provider-refused. They are deprecated upstream; every provider has an exec replacement (below);proxies (
proxy-url),insecure-skip-tls-verify, non-https servers, basic auth, and users that mixexecwith static credentials;exec
apiVersionclient.authentication.k8s.io/v1alpha1(onlyv1andv1beta1are accepted).
Prerequisites¶
A kubeconfig file generated by your provider’s CLI, saved as its own file (Piceli never reads
KUBECONFIGor~/.kube/config):Provider
Generate the kubeconfig
Plugin
GKE
KUBECONFIG=gke.kubeconfig gcloud container clusters get-credentials my-cluster --region europe-west1gke-gcloud-auth-pluginEKS
aws eks update-kubeconfig --name my-cluster --region eu-west-1 --kubeconfig eks.kubeconfigaws(eks get-token)AKS
az aks get-credentials -n my-cluster -g my-group -f aks.kubeconfig, thenkubelogin convert-kubeconfig -l azurecli --kubeconfig aks.kubeconfigkubeloginOIDC
Your identity provider’s instructions for an exec plugin such as kubelogin (oidc-login)
e.g.
kubectl-oidc_loginA current login for the plugin (
gcloud auth login,aws sso login,az login, or one interactive OIDC login), since Piceli runs it without a terminal.
Steps¶
Check that the context works and look at the
execblock Piceli will run:$ kubectl --kubeconfig gke.kubeconfig --context my-context get ns kube-system $ grep -A8 'exec:' gke.kubeconfig
Pin the plugin. Resolve the command the same way Piceli does and hash it:
$ realpath "$(command -v gke-gcloud-auth-plugin)" /opt/google-cloud-sdk/bin/gke-gcloud-auth-plugin $ shasum -a 256 /opt/google-cloud-sdk/bin/gke-gcloud-auth-plugin 9f2c… /opt/google-cloud-sdk/bin/gke-gcloud-auth-plugin
Allow it in
release.toml:[target] kubeconfig = "gke.kubeconfig" context = "my-context" namespace = "shop" allow_exec = true # run this context's exec plugin exec_sha256 = "sha256:9f2c…" # optional, recommended # exec_pass_env = ["CLOUDSDK_CONFIG"] # extra variables the plugin needs # exec_timeout_seconds = 60
For EKS with named profiles, pass the profile explicitly:
exec_pass_env = ["AWS_PROFILE"](or add it to the kubeconfig’senv).Plan, then apply the approved hash as usual:
$ piceli release plan --spec release.toml $ piceli release apply --spec release.toml --approve <plan_hash>
For a pipeline (
piceli deploy), set the same options on itsTargetinstead; they apply topiceli deploy,piceli status,piceli accessandpiceli release … --spec module.py:pipeline:target = Target.kubeconfig( "gke.kubeconfig", context="my-context", namespace="shop", allow_exec=True, exec_sha256="sha256:9f2c…", # exec_pass_env=["CLOUDSDK_CONFIG"], exec_timeout_seconds=60, )
Expected output: the same as with a static kubeconfig. When a plugin upgrade
changes its file, the next command refuses with exec-pin-mismatch and names
the new digest; update exec_sha256 after checking the upgrade was expected.
Reference¶
[target] keys (all optional; the exec_* keys require allow_exec = true):
Key |
Type |
Default |
Meaning |
|---|---|---|---|
|
bool |
|
Run the context’s exec plugin. |
|
|
none |
Expected digest of the resolved command file. |
|
list of names |
|
Extra variables copied from Piceli’s environment. |
|
number in (0, 300] |
|
Limit for one plugin run. |
piceli.pipeline.Target.kubeconfig(...) takes the same four options as
keyword arguments (allow_exec=True, exec_sha256=…, exec_pass_env=[…],
exec_timeout_seconds=…), validated the same way (pipeline-invalid
otherwise).
piceli status and piceli access use the target’s policy too (from
[target] or the pipeline’s Target). status runs the plugin through
Piceli’s own client; access resolves and pins it, then kubectl port-forward runs it itself with your environment (as for piceli observe). Without the opt-in both refuse the exec user
(exec-auth-not-allowed).
Python API: KubeconfigTarget(..., allow_exec=True, exec_sha256=...) with
build_provider, or api_client_from_kubeconfig(path, context, exec_policy=ExecPolicy(True)) from piceli.k8s.ops.provider_factory. The
built ProviderBinding.credential_plugin holds the resolved path, digest and
exec apiVersion (never arguments, environment or credentials).
What the pin covers: only the file the command resolves to. A plugin that
starts other programs (gke-gcloud-auth-plugin → gcloud, kubelogin -l azurecli → az, kubectl oidc-login → kubectl-oidc_login) runs them
from PATH unpinned; point command at the final binary where you can
(kubectl-oidc_login instead of kubectl). A user who can replace the file
between the hash and the run can still swap it; keep plugins in directories
only you (or root) can write.
If it fails¶
Code |
Meaning |
Fix |
|---|---|---|
|
The context uses an exec plugin and |
Review the |
|
The user has a legacy |
Regenerate the kubeconfig for the exec plugin (table above). |
|
The command is not in |
Install the plugin or fix |
|
Not an executable regular file, or writable by group/others. |
|
|
The file’s digest differs from |
Check the upgrade, then update |
|
|
Log in with the plugin first; use |
|
The plugin exited non-zero; its message is on stderr. |
Usually log in again ( |
|
The plugin did not finish in time. Safe to retry. |
Retry; check network access or raise |
|
The output is not a valid ExecCredential (format, apiVersion, PEM, expiry). |
Run the plugin by hand; upgrade it. |
|
The |
Regenerate the kubeconfig or fix |
piceli explain <code> prints the same entries; see Error codes.