Kubernetes Connector
The Kubernetes connector is a platform-agnostic connector that you can use to connect to any Kubernetes cluster.
You can use the Kubernetes Connector to securely perform kubernetes operations in CICD pipelines, or use it in kubernetes workloads to perform kubernetes operations without credentials.
Additionally, you can centralize the management of kubernetes access configurations across namespaces, avoiding the need to repeat the kubernetes credentials in each namespace.
TOC
OverviewIntegration RequirementsCreating a simple Kubernetes connectorFields ReferenceCapabilities of Kubernetes ConnectorAuthenticationUsing Bearer Token-based AuthenticationToken Permissions RequiredToken GenerationProxy and Kubeconfig ConfigurationProxy Addresskubeconfig configuration fileUsing Connectors CSI Driver to mount kubeconfig fileFurther ReadingReferencesOverview
This document covers:
- Integration Requirements: Prerequisites for target Kubernetes clusters
- Creating Kubernetes connector
- Advanced Features: Proxy capabilities and configuration capabilities about Kubernetes connector
Integration Requirements
Target Kubernetes clusters must meet the following prerequisites:
- CNCF Certification: The cluster must be CNCF Certified Kubernetes compliant
Creating a simple Kubernetes connector
Here's how to create a basic Kubernetes Connector:
Fields Reference
spec.connectorClassName:
k8s (constant), specifies the ConnectorClass name for Kubernetes integration.
spec.address:
Target Kubernetes cluster API server endpoint, for example: https://192.168.1.100:6443.
It also supports url with path, for example: https://192.168.1.100:6443/kubernetes/global, it is useful when the kubernetes cluster API server is exposed behind a proxy.
spec.auth:
specifies the authentication method of the kubernetes cluster.
-
spec.auth.name: should bebearerTokenAuthfor kubernetes connector. -
spec.auth.secretRef: specifies the secret that contains the authentication information of the kubernetes cluster, the secret should be created in the same namespace as the connector.
For more information about authentication, see Authentication.
Optional Metadata fields:
-
cpaas.io/description: Description information for the kubernetes connector, for example:
Capabilities of Kubernetes Connector
Authentication
The Kubernetes connector supports the following authentication types:
bearerTokenAuth: Bearer token-based authentication, corresponding secret type:connectors.cpaas.io/bearer-token
Using Bearer Token-based Authentication
If the secret is not correct, the status.conditions field in the kubernetes connector will show the error message.
For comprehensive status information, see Connector Status Documentation.
Token Permissions Required
The required permissions for the configured token depend on how you intend to use it in your Pods/Pipelines.
For example:
- If you need to create workloads (Deployments, Jobs, etc.) using this connector, the token must have
createpermissions for the corresponding resources in the target cluster. - If you only need to read cluster information, the token only requires
getandlistpermissions for the relevant resources.
For security best practices, we recommend creating tokens with minimal required permissions. When additional privileges are needed, create separate Connectors with more privileged tokens and use namespace isolation to control which users can access each Connector.
Token Generation
Bearer tokens are typically generated from ServiceAccounts in the target Kubernetes cluster. You can create a ServiceAccount with appropriate RBAC permissions and use its token. For detailed information about ServiceAccount tokens and RBAC configuration, see the Kubernetes Authentication documentation.
If you are using an API endpoint provided by the Alauda Container Platform to access your cluster (e.g., https://platform.example.com/kubernetes/global), you must configure an ACP platform token instead of a token generated directly from the Kubernetes cluster. For information about platform tokens, see the Alauda Container Platform API documentation.
Proxy and Kubeconfig Configuration
To provide clients with the ability to access kubernetes resources without credentials, the Kubernetes connector provides a proxy server to automatically inject authentication information.
Clients can use this proxy server to access kubernetes resources without needing to configure credentials on the client side.
To simplify usage, the Kubernetes connectorclass provides kubeconfig files that can be mounted into Pods via CSI. In the Pod, when executing kubernetes operations, the proxy service can be automatically inject authentication information.
Proxy Address
Upon Connector creation, the system automatically provisions a proxy service for the target cluster.
The proxy endpoint is recorded in status.proxy.httpAddress:
For example:
kubeconfig configuration file
The Kubernetes connector provides the following configuration:
kubeconfig:
- Provides a
kubeconfigconfiguration file. Combined with the connector-csi-driver, this configuration file will be mounted into the Pod, allowing access to the kubernetes cluster through the proxy without needing to configure credentials on the client side.
Example of the configuration file generated in the Pod:
Key Fields:
server: Target Kubernetes API server endpointproxy-url: Connector proxy address with embedded proxy authenticationcertificate-authority-data: Proxy server certificate for TLS validation
For detailed proxy mechanics, see How It Works in the Quick Start guide.
Using Connectors CSI Driver to mount kubeconfig file
The Kubernetes connector provides a kubeconfig configuration file that can be mounted into the Pod via Connector CSI Driver.
For example:
parameter descriptions:
csi.readOnly: Fixed valuetruecsi.driver: The Connector CSI Driver, fixed asconnectors-csi.csi.volumeAttributes: CSI Volume attributesconnector.name: Name of the Kubernetes Connectorconnector.namespace: Namespace of the Kubernetes Connector; if not specified, the Pod's namespace is usedconfiguration.names: Configuration name, provide by the Kubernetes Connector. As above,kubeconfigis supported.
For detailed information about how to use the kubeconfig file in the Pod by connectors-csi-driver, please refer to Using Kubernetes Connectors in kubernetes jobs