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
Overview
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.
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
For example:
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.
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