
Kubernetes
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/edge | 1422 | 15 Sep 2025 | |
latest/edge | 1421 | 15 Sep 2025 | |
latest/edge | 1420 | 15 Sep 2025 | |
latest/edge | 1419 | 15 Sep 2025 | |
latest/edge | 578 | 19 Mar 2025 | |
latest/edge | 576 | 19 Mar 2025 | |
1.32/stable | 1386 | 09 Sep 2025 | |
1.32/stable | 1383 | 09 Sep 2025 | |
1.32/stable | 1382 | 09 Sep 2025 | |
1.32/stable | 1385 | 09 Sep 2025 | |
1.32/stable | 1384 | 09 Sep 2025 | |
1.32/stable | 1381 | 09 Sep 2025 | |
1.32/candidate | 1385 | 05 Sep 2025 | |
1.32/candidate | 1381 | 05 Sep 2025 | |
1.32/candidate | 1383 | 05 Sep 2025 | |
1.32/candidate | 1382 | 05 Sep 2025 | |
1.32/candidate | 1386 | 05 Sep 2025 | |
1.32/candidate | 1384 | 05 Sep 2025 | |
1.32/beta | 1406 | 11 Sep 2025 | |
1.32/beta | 1405 | 11 Sep 2025 | |
1.32/beta | 1404 | 11 Sep 2025 | |
1.32/beta | 1403 | 11 Sep 2025 | |
1.32/beta | 1402 | 11 Sep 2025 | |
1.32/beta | 1401 | 11 Sep 2025 | |
1.33/stable | 1350 | 04 Sep 2025 | |
1.33/stable | 1348 | 04 Sep 2025 | |
1.33/stable | 1351 | 04 Sep 2025 | |
1.33/stable | 1347 | 04 Sep 2025 | |
1.33/candidate | 1390 | 05 Sep 2025 | |
1.33/candidate | 1387 | 05 Sep 2025 | |
1.33/candidate | 1388 | 05 Sep 2025 | |
1.33/candidate | 1389 | 05 Sep 2025 | |
1.33/beta | 1390 | 05 Sep 2025 | |
1.33/beta | 1389 | 05 Sep 2025 | |
1.33/beta | 1388 | 05 Sep 2025 | |
1.33/beta | 1387 | 05 Sep 2025 | |
1.31/candidate | 142 | 11 Dec 2024 | |
1.31/candidate | 141 | 27 Nov 2024 | |
1.30/beta | 65 | 23 May 2024 |
juju deploy k8s --channel 1.32/stable
Deploy universal operators easily with Juju, the Universal Operator Lifecycle Manager.
Platform:
charms.k8s.v0.k8sd_api_manager
-
- Last updated 18 Jun 2025
- Revision Library version 0.8
Module for managing k8sd API interactions.
This module provides a high-level interface for interacting with K8sd. It simplifies tasks such as token management and component updates.
The core of the module is the K8sdAPIManager, which handles the creation and management of HTTP connections to interact with the k8sd API. This class utilises different connection factories (UnixSocketConnectionFactory and HTTPConnectionFactory) to establish connections through either Unix sockets or HTTP protocols.
Example usage for creating a join token for K8sd:
try:
factory = UnixSocketConnectionFactory('/path/to/socket')
api_manager = K8sdAPIManager(factory)
join_token = api_manager.create_join_token('node-name')
except K8sdAPIManagerError as e:
logger.error("An error occurred: %s", e.message)
Similarly, the module allows for requesting authentication tokens and managing K8s components.
Index
class ErrorCodes
Enumerate the response codes from the k8s api.
Attributes
class K8sdAPIManagerError
Description
Base exception for K8sd API Manager errors. None
class K8sdConnectionError
Description
Raised when there is a connection error. None
class InvalidResponseError
Raised when the response is invalid or unexpected.
Attributes
Methods
InvalidResponseError. __init__( self , code: int , msg: str , method , endpoint , reason , body )
Initialise the InvalidResponseError.
Arguments
http response code
Message associated with the error
The method used to make the request
The endpoint used to make the request
The reason for the error
The body of the response
class BaseRequestModel
Base model for k8s request responses.
Attributes
Methods
BaseRequestModel. check_status_code( cls , v )
Validate the status_code field.
Arguments
The value of the status_code field to validate.
Returns
The validated status code if it is 200.
BaseRequestModel. check_error_code( cls , v , info: ValidationInfo )
Validate the error_code field.
Arguments
The value of the error_code field to validate.
The validation information.
Returns
The validated error code if it is 0.
class EmptyResponse
Description
Response model for request that do not expect any return value. None
class TokenMetadata
Model representing metadata for a token.
Attributes
class AuthTokenResponse
Response model for Kubernetes authentication token requests.
Attributes
class CreateJoinTokenResponse
Response model for join token creation requests.
Attributes
class ClusterMember
Represents a member in the k8sd cluster.
Attributes
class DNSConfig
Configuration for the DNS settings of the cluster.
Attributes
class IngressConfig
Configuration for the ingress settings of the cluster.
Attributes
class LoadBalancerConfig
Configuration for the load balancer settings of the cluster.
Attributes
class LocalStorageConfig
Configuration for the local storage settings of the cluster.
Attributes
class NetworkConfig
Configuration for the network settings of the cluster.
Attributes
class GatewayConfig
Configuration for the gateway settings of the cluster.
Attributes
class MetricsServerConfig
Configuration for the metrics server settings of the cluster.
Attributes
class UserFacingClusterConfig
Aggregated configuration model for the user-facing aspects of a cluster.
Attributes
class UserFacingDatastoreConfig
Aggregated configuration model for the user-facing datastore aspects of a cluster.
Attributes
class BootstrapConfig
Configuration model for bootstrapping a Canonical K8s cluster.
Attributes
class CreateClusterRequest
Request model for creating a new Canonical Kubernetes cluster.
Attributes
class UpdateClusterConfigRequest
Request model for updating Cluster config.
Attributes
class NodeJoinConfig
Request model for the config on a node joining the cluster.
Attributes
class ControlPlaneNodeJoinConfig
Request model for the config on a control-plane node joining the cluster.
Attributes
class JoinClusterRequest
Request model for a node joining the cluster.
Attributes
Methods
JoinClusterRequest. serialize_token( self , token: SecretStr )
Serialize the token to a string.
Arguments
The token to serialize.
Returns
The serialized token.
JoinClusterRequest. serialize_config( self , config )
Serialize the config to a YAML string.
Arguments
The config to serialize.
Returns
The serialized config.
class DatastoreStatus
information regarding the active datastore.
Attributes
class ClusterStatus
Represents the overall status of the k8sd cluster.
Attributes
class ClusterMetadata
Metadata containing status information about the k8sd cluster.
Attributes
class GetClusterStatusResponse
Response model for getting the status of the k8sd cluster.
Attributes
class KubeConfigMetadata
Metadata containing kubeconfig.
Attributes
class GetKubeConfigResponse
Response model for getting the kubeconfig from the cluster.
Attributes
class RefreshCertificatesPlanMetadata
Metadata for the certificates plan response.
Description
Attributes: model_config: ConfigDict instance for the model. seed (int): The seed for the new certificates. certificate_signing_requests (Optional[list[str]]): List of names of the CertificateSigningRequests that need to be signed externally (for worker nodes).
class RefreshCertificatesPlanResponse
Response model for the refresh certificates plan.
Attributes
class RefreshCertificatesRunRequest
Request model for running the refresh certificates run.
Attributes
class RefreshCertificatesRunMetadata
Metadata for RefreshCertificatesRunResponse.
Description
Attributes: model_config: ConfigDict instance for the model. expiration_seconds (int): The duration of the new certificates (might not match the requested value).
class RefreshCertificatesRunResponse
Response model for the refresh certificates run.
Attributes
class GetClusterConfigMetadata
Metadata containing the cluster config.
Attributes
class GetClusterConfigResponse
Response model for the get cluster config endpoint.
Attributes
class NodeStatus
Represents the status of a node in the cluster.
Attributes
class GetNodeStatusMetadata
Metadata containing the node status.
Attributes
class GetNodeStatusResponse
Response model for the get node status endpoint.
Attributes
class UnixSocketHTTPConnection
Description
HTTP connection over a Unix socket. None
Methods
UnixSocketHTTPConnection. __init__( self , unix_socket: str , timeout: int )
Initialise the UnixSocketHTTPConnection.
Arguments
Path to the Unix socket.
Connection timeout in seconds.
UnixSocketHTTPConnection. connect( self )
Establish a connection to the server using a Unix socket.
class ConnectionFactory
Description
Abstract factory for creating connection objects. None
Methods
ConnectionFactory. create_connection( self )
Create a new connection instance.
class UnixSocketConnectionFactory
Description
Concrete factory for creating Unix socket connections. None
Methods
UnixSocketConnectionFactory. __init__( self , unix_socket: str , timeout: int )
Initialize a new instance of UnixSocketConnectionFactory.
Arguments
The file path to the Unix socket.
The timeout for the connection in seconds. Defaults to 30 seconds.
UnixSocketConnectionFactory. create_connection( self )
Create and manage a Unix socket HTTP connection.
Returns
The created Unix socket HTTP connection.
class HTTPConnectionFactory
Description
Concrete factory for creating HTTP connections. None
Methods
HTTPConnectionFactory. __init__( self , host: str , port , timeout: int )
Initialize a new instance of HTTPConnectionFactory.
Arguments
Hostname for the HTTP connection.
Port for the HTTP connection.
The timeout for the connection in seconds. Defaults to 30 seconds.
HTTPConnectionFactory. create_connection( self )
Create and manage an HTTP connection.
Returns
The created HTTP connection.
class K8sdAPIManager
Description
Manager for K8sd API interactions. None
Methods
K8sdAPIManager. __init__( self , factory: ConnectionFactory )
Initialise the K8sdAPIManager.
Arguments
An instance of a connection factory that will be used to create connections. This factory determines the type of connection (e.g., Unix socket or HTTP).
K8sdAPIManager. create_join_token( self , name: str , worker: bool )
Create a join token.
Arguments
Name of the node.
Whether the node should join as control-plane or worker.
Returns
The generated join token if successful.
K8sdAPIManager. join_cluster( self , config: JoinClusterRequest )
Join a node to the k8s cluster.
Arguments
JoinClusterRequest: config to join the cluster
K8sdAPIManager. remove_node( self , name: str , force: bool )
Remove a node from the cluster.
Arguments
Name of the node that should be removed.
Forcibly remove the node
K8sdAPIManager. update_cluster_config( self , config: UpdateClusterConfigRequest )
Enable or disable a k8s component.
Arguments
The cluster configuration.
K8sdAPIManager. get_cluster_config( self )
Retrieve the cluster configuration.
Returns
The cluster configuration.
Description
Worker nodes are not allowed to call this endpoint: https://github.com/canonical/k8s-snap/blob/0a5edd2/src/k8s/pkg/k8sd/api/endpoints.go#L121-L126
K8sdAPIManager. get_node_status( self )
Retrieve the status of the local node.
Returns
The status of the local node.
K8sdAPIManager. get_cluster_status( self )
Retrieve cluster status.
Returns
status of the cluster.
K8sdAPIManager. is_cluster_bootstrapped( self )
Check if K8sd has been bootstrapped.
Returns
True if the cluster has been bootstrapped, False otherwise.
K8sdAPIManager. is_cluster_ready( self )
Check if the Kubernetes cluster is ready.
Returns
True if the cluster is ready, False otherwise.
Description
The cluster is ready if at least one k8s node is in READY state.
K8sdAPIManager. check_k8sd_ready( self )
Check if k8sd is ready using various microcluster endpoints.
K8sdAPIManager. bootstrap_k8s_snap( self , request: CreateClusterRequest )
Bootstrap the k8s cluster.
Arguments
The request model to bootstrap the cluster.
K8sdAPIManager. request_auth_token( self , username: str , groups )
Request a Kubernetes authentication token.
Arguments
Username for which the token is requested.
Groups associated with the user.
Returns
The authentication token.
K8sdAPIManager. revoke_auth_token( self , token: str )
Revoke a Kubernetes authentication token.
Arguments
The authentication token.
K8sdAPIManager. get_kubeconfig( self , server )
Request a Kubernetes admin config.
Arguments
Optional server to replace in the kubeconfig endpoint
Returns
The authentication token.
K8sdAPIManager. refresh_certs( self , extra_sans , expiration_seconds )
Refresh the certificates for the cluster.
Arguments
List of extra SANs for the certificates.
The duration of the new certificates.