alibabacloud-idaas-ack-m2m-federated-credential
Latest: v0.0.1
- Added a workflow for configuring IDaaS EIAM OIDC federation for workloads in existing Alibaba Cloud ACK clusters.
- Covers account and RAM access checks, Kubernetes access and RBAC, and choosing how to run Kubernetes commands.
- Supports projected ServiceAccount tokens and existing RRSA webhook injection; can create or reuse OIDC trust sources and M2M clients.
- Includes optional PAM cloud-role access, token and STS credential verification, and approved test-resource cleanup.
IDaaS EIAM federation for ACK workloads
Select the cloud account and determine RAM access
- Select the account. At the start of a run, ask whether to use the current Alibaba Cloud CLI account, switch to another existing profile, or sign in to a new account. Use an account choice explicitly supplied for this run. You can inspect local profile names and status with
aliyun configure listwithout making a cloud call. If the user requests a new login, complete credential setup first. See the CLI setup guide. - Verify the selected identity and explain RAM access. Use STS
GetCallerIdentitywith the selected credential chain. When the identity type is unknown or an owning account is expected, run STS by itself before deciding whether to show a policy. Stop before resource calls if the returned account or principal conflicts with the user's selection. For the target Alibaba Cloud owning account (IdentityType=Account), state that no additional RAM grant is required and continue. For a RAM user or role, give the RAM access request below before any ACK or EIAM calls. If the user already identified the selection as a RAM user or role, give the request before STS. Repeat the applicable checks when the selected identity changes. - Give RAM users and roles one authorization request for the complete Skill. Use the complete custom policy JSON. Include discovery, both token sources, temporary kubeconfig, RRSA and webhook preparation, federation, PAM role authorization and STS verification, and cleanup in the initial request, even when the user starts with M2M only. Scope it to the approved resources and provide complete JSON to save in Script Editor and attach to the selected CLI identity. Get separate confirmation at execution time for cloud writes, including the exact PAM role grant and cleanup.
If the user says the selected account has no access, provide the entire checklist and grant instructions before running the workflow. If a later permission check fails, identify the missing grant from the checklist and wait for confirmation before retrying.
In the initial authorization message, show the RAM permissions section first, with the complete policy JSON and custom grant steps. After the RAM section, show a separate ACK Kubernetes RBAC section in the user's language with these choices.
- Reuse an existing namespace. Use scoped RBAC for the selected namespace and the workload actions the user intends to perform.
- Skill creates a new test namespace. Grant cluster-level
create namespacesand arrange a namespace-scoped workload binding before starting. An administrator applies the workload binding after namespace creation.
Direct the administrator to the scoped ACK grant steps. Apply the guidance to the actual identity that runs kubectl in Workbench or over direct public or private access. Existing permissions that pass the requested checks are sufficient. In a dedicated test cluster, document the optional ACK presets if the user asks for them. For cloud-only work, use the RAM request alone.
After showing the RAM and, when applicable, RBAC instructions, stop for a user choice such as Permissions are ready, continue discovery or Set up permissions first. Wait for the choice before calling ACK or EIAM or offering region choices, including when the selected RAM user or role was already granted access. For the confirmed owning-account path, indicate that the RAM grant step is complete and continue with discovery.
Prepare Kubernetes access
After cloud discovery, offer choices for how to run Kubernetes commands: Skill runs on this machine, User runs in ACK Workbench, or User runs in their own terminal. In localized questions and options, name the actor explicitly as the Skill or the user. Avoid first- and second-person pronouns for execution responsibility. For direct access, offer the selected cluster's available public and private API Server endpoints as choices. Use connection selection and kubeconfig discovery before asking for a file or context. Alibaba Cloud CLI calls to ACK or EIAM use RAM permissions. At the Kubernetes stage, check the actual Kubernetes identity and its existing access before requesting grants. Report each applicable access check as verified, blocked, or pending.
- Agent-run public or private direct access. Identify the terminal or runner and its actual kubeconfig identity. For public access, tell the customer which environment will connect, the API Server endpoint it uses, and the exact access-control resource to check. Report connectivity for the tested environment. Public API Server access guide
- User-run Kubernetes. Identify the account or RAM role signed in to ACK Workbench or the identity in the user's chosen terminal. Provide copy-ready commands for that terminal. The agent may use a separate CLI identity for OpenAPI calls. User-run Kubernetes workflow
- ACK Kubernetes RBAC. Explain that the owning Alibaba Cloud account has default Kubernetes access with its own kubeconfig. A RAM user or role needs grants on the selected cluster, including when it can already obtain a kubeconfig or access another cluster. Verify using the same identity and context that will run kubectl. For a known workload, start with
geton the named namespace, ServiceAccount and Pod, pluspods/execon the selected Pod for the in-Pod checks. Request list or workload preparation permissions only when that operation is needed. Check and grant ACK RBAC
Offer Select an existing namespace or Skill creates a new test namespace in the user's language. For the new path, use agent-run kubectl. If a user-run path was selected, let the user choose a direct connection for the agent. Check create namespaces for the agent's identity before any write. If it is denied, give the administrator the scoped grant instructions for that identity. After namespace creation, verify the workload binding before creating the ServiceAccount or Pod. Permissions by workload path
As soon as the cluster and scope are known, check the applicable Kubernetes access before workload discovery, preparation or verification. For an authentication failure, verify the kubeconfig. For an RBAC denial, report the operator, cluster, resource and verb, and give the ACK administrator the steps to grant that access. Repeat the check with the same Kubernetes identity after the grant. Continue when the existing or updated access passes.
Other prerequisites
Run the helper on Linux or macOS with Alibaba Cloud CLI 3.5.1 or later and Python 3.9 or later. The Kubernetes execution terminal needs compatible kubectl and a usable kubeconfig. See preparation and troubleshooting and required RAM and Kubernetes permissions.
- An existing ACK managed cluster running Kubernetes 1.22 or later with RRSA OIDC enabled, and a running Pod using the intended namespace and ServiceAccount. It needs an explicit token projection or the existing ACK webhook token mount. An active RRSA webhook is required for the webhook path. The verification container must have Python 3.
- A running EIAM Enterprise instance with a valid license and machine identity management (M2M) enabled. Use the EIAM instance selection below.
- An authenticated Alibaba Cloud CLI identity with the OpenAPI permissions for the chosen operations. The selected Pod needs network access to the EIAM token endpoint and, for STS verification, the regional EIAM Developer API and STS endpoints.
- For the default M2M check, the built-in PAM feature grant is sufficient. For a caller-supplied business scope, get the exact already authorized scope. For optional STS, ask the user to select an existing enabled Alibaba Cloud role managed in PAM.
For federation preflight, configuration and verification, the cloud CLI identity needs ram:GetOIDCProvider on the selected ACK cluster's RRSA provider. This applies to direct kubectl and user-run Workbench. Once the cluster is selected, give the user the exact provider ARN, the identity that needs access and, if the existing policy lacks it, the ready-to-copy RAM policy for their RAM administrator.
If a prerequisite fails, identify the affected resource. For a selected ACK cluster, offer to enable RRSA or install the missing injection webhook as described below. Use the customer's environment preparation process for provisioning clusters, RAM roles and workloads. Use the generic Kubernetes federation skill for non-ACK clusters and the ACK RRSA guide for direct RRSA-to-STS without EIAM.
Observability, CLI and credentials
Before cloud calls, read the version from this Skill's references/manifest.json and generate one fresh 32-character lowercase hexadecimal session ID. Keep it for the workflow through cleanup. Pass it to scripts/ack.py as ACK_SKILL_SESSION_ID or --session-id. The helper constructs the User-Agent for every Alibaba Cloud API command. For direct aliyun API calls, including cluster preparation, set --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-idaas-ack-m2m-federated-credential/{session-id} skill-version/{skill-version}" using the actual values.
Check aliyun version for 3.5.1 or later. Use the selected credential chain and keep credential values out of commands, logs and chat. If credentials or tools are unavailable, stop and share the CLI setup guide. Update a needed plugin only if it is missing or incompatible.
Discover and confirm
Validate supplied values and check for create/reuse conflicts before checking tools or calling a cloud API for that operation. Report all incompatible fields together and ask for the missing or corrected values. If the user asks only for preparation or declines execution, end with the readiness or validation result. For execution, show discovered candidates and ask about unresolved choices. Obtain explicit confirmation of the exact write scope and resource choices before configuration, role authorization or cleanup.
Follow command examples and API behavior. Use acceptance criteria to check the result of the selected stage. For the verified token exchange request/response fields, see data-plane API contracts.
When the EIAM target is unknown, show the official EIAM regions as choices. Suggest the ACK region when EIAM supports it. After the user selects a region, use instance discovery to show the visible instance descriptions, IDs and statuses as choices. Use an exact region and ID if the user already supplied them. If instance listing is blocked, explain the required grant and offer console selection as a fallback. Prefer choices from discovered results for existing resources throughout the workflow.
- Use
discoverto list valid ACK regions, then show the managed clusters for the chosen region. Let the user choose by name and ID. With a known region and cluster ID, start with the cluster checks directly. Select Cloud CLI credentials withALIBABA_CLOUD_PROFILEso the ACK API'sprofilequery parameter remains available for its own filtering. - For the selected cluster, check RRSA OIDC. Check
ack-pod-identity-webhookfor existing webhook-injected Pods. A missing webhook leaves explicit token projection available. If the selected path is missing a prerequisite, show the cluster name, ID, region and exact change and ask for approval. Use cluster preparation for the API calls, status checks and console links. - In an existing namespace, offer an existing Pod or a new Pod. Read the ServiceAccount and token source for an existing Pod. For a new workload, use explicit ServiceAccount token projection. Namespace, ServiceAccount and Pod creation use Kubernetes permissions. Skip RAM role lookup, creation and binding on this path. In the Skill creates a new test namespace path, collect the new namespace, Pod and dedicated ServiceAccount names and the approved image together. Confirm the names are unused and create all three as new objects. On a name conflict, ask for a new name before continuing. For agent-run Kubernetes, use
workloadsfor lists and exact reads for supplied names. Follow the new-namespace procedure. - Run
preflightfor the selected cluster, namespace, ServiceAccount, Pod and container. Pass--token-source projectedfor explicit projection through preflight, configure and verify. Existing webhook workloads use the defaultwebhookmode. Preflight checks ACK and EIAM readiness, the mounted token claims and EIAM reachability. In the user-run workflow, verify Kubernetes metadata and run the generated probe in Workbench, then collect the JSON result. Repeat preflight if the Pod or its binding changes. - Explain the naming rules when asking for new names. Collect the trust source and M2M application choices and the credential name, then check each new name before asking for confirmation. If a name fails validation, identify that field and ask only for its replacement. Preserve the user's application display name, including capitalization. Explain any feature grant on a reused M2M app. Never assume that a resource belongs to the current session from its name.
Configure and verify
- Create a private local state file location. Use the same session ID, account, instance, cluster, namespace and ServiceAccount throughout. With approval, run
configure. The default validation path uses--pam-feature. A pre-authorized business scope uses the configuration without that flag. The workflow uses ACK issuer discovery, audiencests.aliyuncs.com, andstructured/kubernetesverification binding the namespace and ServiceAccount. Reuse a trust source only after matching its settings. Record actual IDs and ownership and check the EIAM readback. - Run
verifyfor M2M. The probe executes inside the chosen Pod, uses the mounted Token as the client assertion, and reports only verification status and safe request information. For a caller-supplied business scope pass--scope. In the user-run workflow, forward the generated command, then wait for the returned probe JSON before reporting verification. An EIAM configuration readback or successful Token mount alone cannot establish M2M issuance. - For optional STS, use
rolesto list the managed Alibaba Cloud accounts in PAM and let the user select one. List the existing enabled user roles for that account and let the user select a target by name and ARN. Confirm the exact role, M2M application, and single-role data rule before writing. Rungrantwith--expected-role-arnset to that confirmed ARN, thenverify --sts. The final identity check must identify the target role. The target role is distinct from the RRSA injection role. If the user also requests business API validation, use only the explicitly authorized read-only operation and honor the selected role's scope. - Report the selected resources, verified stages, relevant request IDs and any unfinished step. Keep JWTs, bearer tokens, AKs, secrets, kubeconfig and STS components out of the conversation and command output.
Recovery and cleanup
On failure, report the first error, request ID when available, and IDs already recorded. Permission or parameter errors stop the operation. For a timeout or incomplete write, check exact resource names and existing associations before attempting another write. A pending create in the state file must be reconciled before continuing. Report omitted checks as pending.
Use cleanup only after confirming the exact state-owned IDs. It removes rule associations first, disables resources before deletion, and verifies absence. It preserves reused applications, trust sources, cluster resources and target roles. For a reused client, manage any feature permission granted to it through the customer's normal authorization process. See the API workflow and ownership rules.
