Summary
Add kube-rs as a dependency and implement shared Kubernetes client for all K8s runtime implementations.
Parent Epic
Part of #1 - Production Kubernetes & Container Support
Motivation
The k8s-job and k8s-service runtimes both need to interact with the Kubernetes API. A shared client implementation ensures:
- Consistent authentication handling
- Connection pooling and efficiency
- Proper error handling
- Unified configuration
Implementation Details
Dependencies
[dependencies]
kube = { version = "0.87", features = ["runtime", "client", "derive"] }
k8s-openapi = { version = "0.20", features = ["v1_28"] }
Client Initialization
pub struct KubeClientProvider {
client: Option<Client>,
}
impl KubeClientProvider {
pub async fn get_client(&self) -> Result<Client, KubeError> {
// Try in-cluster config first
// Fall back to kubeconfig
// Cache and reuse client
}
}
Authentication Methods
-
In-cluster (default when running in K8s)
- ServiceAccount token from
/var/run/secrets/kubernetes.io/serviceaccount/token
- CA cert from
/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
-
Kubeconfig (for local development)
- Default:
~/.kube/config
- Override via
KUBECONFIG env var
- Context selection via config
Features Required
Acceptance Criteria
Configuration
# gateway.yaml
kubernetes:
context: my-cluster # optional, for kubeconfig
namespace: default # default namespace
timeout_seconds: 30
References
Summary
Add kube-rs as a dependency and implement shared Kubernetes client for all K8s runtime implementations.
Parent Epic
Part of #1 - Production Kubernetes & Container Support
Motivation
The k8s-job and k8s-service runtimes both need to interact with the Kubernetes API. A shared client implementation ensures:
Implementation Details
Dependencies
Client Initialization
Authentication Methods
In-cluster (default when running in K8s)
/var/run/secrets/kubernetes.io/serviceaccount/token/var/run/secrets/kubernetes.io/serviceaccount/ca.crtKubeconfig (for local development)
~/.kube/configKUBECONFIGenv varFeatures Required
Acceptance Criteria
Configuration
References