pub fn build_kubeconfig_yaml(
cluster_name: &str,
server: &str,
ca_data_b64: Option<&str>,
sa_name: &str,
token: &str,
allow_insecure: bool,
) -> Result<String>Expand description
Build a kubeconfig YAML string for the given service account token.
When ca_data_b64 is Some(...) the CA data is embedded and TLS
verification is enforced. When ca_data_b64 is None the function
refuses to produce output unless allow_insecure is true; in that case
it sets insecure-skip-tls-verify: true on the cluster entry.
Refusing insecure output by default prevents a bootstrap run against a KUBECONFIG that lacks CA data from silently distributing kubeconfigs that skip TLS verification (MITM risk against the child-cluster scout).
§Arguments
cluster_name- Name of the cluster entry in the kubeconfigserver- Kubernetes API server URL (e.g.https://192.0.2.1:6443)ca_data_b64- Base64-encoded PEM CA certificate, orNoneto skip TLS verifysa_name- Name of the service account / kubeconfig user entrytoken- Bearer token for the service accountallow_insecure- Must betrueto allow emittinginsecure-skip-tls-verifywhenca_data_b64isNone. Intended to be wired to an explicit CLI opt-out flag (e.g.--insecure-skip-tls-verify).
§Errors
- Returns an error if
ca_data_b64isNoneandallow_insecureisfalse. - Returns an error if YAML serialization fails.