- What's New
- Product Bulletin
- Service Overview
- Billing
- Getting Started
-
User Guide
-
UCS Clusters
- Overview
- Huawei Cloud Clusters
-
On-Premises Clusters
- Overview
- Service Planning for On-Premises Cluster Installation
- Registering an On-Premises Cluster
- Installing an On-Premises Cluster
- Managing an On-Premises Cluster
- Attached Clusters
- Multi-Cloud Clusters
- Single-Cluster Management
- Fleets
-
Cluster Federation
- Overview
- Enabling Cluster Federation
- Using kubectl to Connect to a Federation
- Upgrading a Federation
-
Workloads
- Workload Creation
-
Container Settings
- Setting Basic Container Information
- Setting Container Specifications
- Setting Container Lifecycle Parameters
- Setting Health Check for a Container
- Setting Environment Variables
- Configuring a Workload Upgrade Policy
- Configuring a Scheduling Policy (Affinity/Anti-affinity)
- Configuring Scheduling and Differentiation
- Managing a Workload
- ConfigMaps and Secrets
- Services and Ingresses
- MCI
- MCS
- DNS Policies
- Storage
- Namespaces
- Multi-Cluster Workload Scaling
- Adding Labels and Taints to a Cluster
- RBAC Authorization for Cluster Federations
- Image Repositories
- Permissions
-
Policy Center
- Overview
- Basic Concepts
- Enabling Policy Center
- Creating and Managing Policy Instances
- Example: Using Policy Center for Kubernetes Resource Compliance Governance
-
Policy Definition Library
- Overview
- k8spspvolumetypes
- k8spspallowedusers
- k8spspselinuxv2
- k8spspseccomp
- k8spspreadonlyrootfilesystem
- k8spspprocmount
- k8spspprivilegedcontainer
- k8spsphostnetworkingports
- k8spsphostnamespace
- k8spsphostfilesystem
- k8spspfsgroup
- k8spspforbiddensysctls
- k8spspflexvolumes
- k8spspcapabilities
- k8spspapparmor
- k8spspallowprivilegeescalationcontainer
- k8srequiredprobes
- k8srequiredlabels
- k8srequiredannotations
- k8sreplicalimits
- noupdateserviceaccount
- k8simagedigests
- k8sexternalips
- k8sdisallowedtags
- k8sdisallowanonymous
- k8srequiredresources
- k8scontainerratios
- k8scontainerrequests
- k8scontainerlimits
- k8sblockwildcardingress
- k8sblocknodeport
- k8sblockloadbalancer
- k8sblockendpointeditdefaultrole
- k8spspautomountserviceaccounttokenpod
- k8sallowedrepos
- Configuration Management
- Traffic Distribution
- Observability
- Container Migration
- Pipeline
- Error Codes
-
UCS Clusters
- Best Practices
-
API Reference
- Before You Start
- Calling APIs
-
API
- UCS Cluster
-
Fleet
- Adding a Cluster to a Fleet
- Removing a Cluster from a Fleet
- Registering a Fleet
- Deleting a Fleet
- Querying a Fleet
- Adding Clusters to a Fleet
- Updating Fleet Description
- Updating Permission Policies Associated with a Fleet
- Updating the Zone Associated with the Federation of a Fleet
- Obtaining the Fleet List
- Enabling Fleet Federation
- Disabling Cluster Federation
- Querying Federation Enabling Progress
- Creating a Federation Connection and Downloading kubeconfig
- Creating a Federation Connection
- Downloading Federation kubeconfig
- Permissions Management
- Using the Karmada API
- Appendix
-
FAQs
- About UCS
-
Billing
- How Is UCS Billed?
- What Status of a Cluster Will Incur UCS Charges?
- Why Am I Still Being Billed After I Purchase a Resource Package?
- How Do I Change the Billing Mode of a Cluster from Pay-per-Use to Yearly/Monthly?
- What Types of Invoices Are There?
- Can I Unsubscribe from or Modify a Resource Package?
-
Permissions
- How Do I Configure Access Permissions for Each Function of the UCS Console?
- What Can I Do If an IAM User Cannot Obtain Cluster or Fleet Information After Logging In to UCS?
- How Do I Restore ucs_admin_trust I Deleted or Modified?
- What Can I Do If I Cannot Associate the Permission Policy with a Fleet or Cluster?
- How Do I Clear RBAC Resources After a Cluster Is Unregistered?
- Policy Center
-
Fleets
- What Can I Do If Cluster Federation Verification Fails to Be Enabled for a Fleet?
- What Can I Do If an Abnormal, Federated Cluster Fails to Be Removed from the Fleet?
- What Can I Do If an Nginx Ingress Is in the Unready State After Being Deployed?
- What Can I Do If "Error from server (Forbidden)" Is Displayed When I Run the kubectl Command?
- Huawei Cloud Clusters
- Attached Clusters
-
On-Premises Clusters
- What Can I Do If an On-Premises Cluster Fails to Be Connected?
- How Do I Manually Clear Nodes of an On-Premises Cluster?
- How Do I Downgrade a cgroup?
- What Can I Do If the VM SSH Connection Times Out?
- How Do I Expand the Disk Capacity of the CIA Add-on in an On-Premises Cluster?
- What Can I Do If the Cluster Console Is Unavailable After the Master Node Is Shut Down?
- What Can I Do If a Node Is Not Ready After Its Scale-Out?
- How Do I Update the CA/TLS Certificate of an On-Premises Cluster?
- What Can I Do If an On-Premises Cluster Fails to Be Installed?
- Multi-Cloud Clusters
-
Cluster Federation
- What Can I Do If the Pre-upgrade Check of the Cluster Federation Fails?
- What Can I Do If a Cluster Fails to Be Added to a Federation?
- What Can I Do If Status Verification Fails When Clusters Are Added to a Federation?
- What Can I Do If an HPA Created on the Cluster Federation Management Plane Fails to Be Distributed to Member Clusters?
- What Can I Do If an MCI Object Fails to Be Created?
- What Can I Do If I Fail to Access a Service Through MCI?
- What Can I Do If an MCS Object Fails to Be Created?
- What Can I Do If an MCS or MCI Instance Fails to Be Deleted?
- Traffic Distribution
- Container Intelligent Analysis
- General Reference
Copied.
Using Workload Identities to Securely Access Cloud Services
Application Scenarios
With workload identities, your workloads in a cluster can access cloud services like IAM users without using the AK/SK, reducing security risks.
This section describes how to use workload identities in UCS.
Solution Process
Figure 1 shows the process of using workload identities.
- Assign authorization in advance.
- Obtain the JSON Web Key Set (JWKS) issued by the private key of an on-premises cluster from UCS. The JWKS is used to verify the token issued by this cluster for a ServiceAccount.
- Create an identity provider (IdP) for the on-premises cluster in IAM.
- Add the public key of this cluster for the IdP. When a workload uses a token to send requests, IAM will use this public key to verify the token.
- Add a rule to map the ServiceAccount to the IAM account. After the configuration, the ServiceAccount has the permissions of the IAM account.
- Configure the token.
- Deploy a workload and configure a ServiceAccount.
- Mount the token of the ServiceAccount to the workload.
- Verify the token.
- Call the IAM API to obtain the IAM token.
- Use the IAM token to access cloud services.
Obtaining the JWKS of an On-Premises Cluster
- Use kubectl to access the on-premises cluster.
- Run the following command to obtain the public key:
kubectl get --raw /openid/v1/jwks
A json string is returned, containing the public key of the on-premises cluster for accessing the IdP.
{ "keys": [ { "kty": "RSA", "e": "AQAB", "use": "sig", "kid": "Ew29q....", "alg": "RS256", "n": "peJdm...." } ] }
Creating an IdP
- Log in to the IAM console, create an IdP, and select OpenID Connect for Protocol.
Figure 2 Creating an IdP
- Click OK. Then, modify the IdP information as described in Table 1. If you need an identity conversion rule, click Create Rule.
Figure 3 Modifying IdP informationFigure 4 Creating an identity conversion rule
Table 1 IdP parameters Parameter
Description
Access Type
Select Programmatic access.
Configuration Information
- Identity Provider URL: Enter https://kubernetes.default.svc.cluster.local.
- Client ID: Enter ucs-cluster-identity.
- Signing Key: Enter the JWKS of the on-premises cluster obtained in Obtaining the JWKS of an On-Premises Cluster.
Identity Conversion Rules
An identity conversion rule maps the ServiceAccount of a workload to an IAM user group.
For example, create a ServiceAccount named xxx in namespace default of the cluster and map it to user group demo. If you use the IdP ID to access cloud services, you have the permissions of the demo user group.
Value format: system:serviceaccount:Namespace:ServiceAccountName.
- Click OK.
Obtaining an IAM Token
- Create a ServiceAccount, whose name must be the value of ServiceAccountName set in 2.
apiVersion: v1 kind: ServiceAccount metadata: name: test_sa_name # The value must be the same as that in the identity conversion rule.
- Add the ServiceAccount and volume configurations to the workload.
apiVersion: apps/v1 kind: Deployment metadata: name: nginx spec: replicas: 1 selector: matchLabels: app: nginx version: v1 template: metadata: labels: app: nginx version: v1 spec: containers: - name: container-1 image: nginx:latest volumeMounts - mountPath: "/var/run/secrets/tokens" # Mount the ServiceAccountToken generated by Kubernetes to /var/run/secrets/tokens/token_path. name: token-volume imagePullSecrets: - name: default-secret serviceAccountName: test_sa_name # Name of the ServiceAccount created in the previous step volumes: - name: token-volume projected: defaultMode: 420 sources: - serviceAccountToken: audience: ucs-cluster-identity # The value must be the client ID of the IdP. expirationSeconds: 7200 # Expiration time path: token_path # Path name, which can be customized
- After the creation, log in to the container to obtain the token.
- Construct request body data. For details, see Obtaining a Project ID.
{ "auth" : { "id_token" : { "id" : "eyJhbGciOiJSUzIXXXXX" // Token obtained in the previous step }, "scope": { "project" : { "id" : "05495693df80d3c92fa1c01795c2be02", // Project ID "name" : "cn-north-7" } } } }
- Call the IAM API to obtain the IAM token. For details about the IAM endpoint, see Regions and Endpoints.
curl -i --location --request POST 'https://{{iam endpoint}}/v3.0/OS-AUTH/id-token/tokens' --header 'X-Idp-Id: {{workload_identity}}' --header 'Content-Type: application/json' --data @token_body.json
- Replace {workload_identity} with the name of the IdP registered in 1. In this example, the name is ucs-cluster-identity.
- token_body.json is the constructed request body data file.
- Obtain the IAM token from the response body. The value of X-Subject-Token in the response header is the IAM token.
Using an IAM Token to Access Cloud Services
This section uses LTS as an example.
- Before using an IAM token to access LTS, you need to configure permissions for the user group.
- To call LTS, you need to add the LTS FullAccess permissions to the user group.
- Run the following command to call the service API:
curl --location --request GET 'https://ltsperform.cn-north-7.myhuaweicloud.com/v2/{{Project ID}}/groups/{{Log group ID}}/streams' \--header 'Content-Type: application/json;charset=utf-8' \--header 'X-Auth-Token: {{IAM token obtained in the previous step}}' \--data-raw ''
The value of {Log group ID} can be obtained in LTS.
The following figure shows the expected result.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot