Documentation
¶
Index ¶
- Constants
- type API
- func (a *API) ImageImport(ctx context.Context, req *ImageImportRequest) (int, error)
- func (a *API) Join(ctx context.Context, req JoinRequest) (*JoinResponse, int, error)
- func (a *API) RegisterServer(server *http.ServeMux, middleware func(f http.HandlerFunc) http.HandlerFunc)
- func (a *API) RemoveFromDqlite(ctx context.Context, req RemoveFromDqliteRequest, token string) (int, error)
- type ImageImportRequest
- type JoinRequest
- type JoinResponse
- type ListControlPlaneNodeIPsFunc
- type RemoveFromDqliteRequest
- type WorkerOnlyField
Constants ¶
const (
// CAPIAuthTokenHeader is the header used to pass the CAPI auth token.
CAPIAuthTokenHeader = "capi-auth-token"
)
const HTTPPrefix = "/cluster/api/v2.0"
HTTPPrefix is the prefix for all v2 API routes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// Snap interacts with the MicroK8s snap.
Snap snap.Snap
// ListControlPlaneNodeIPs is used in v2/join to list the IP addresses of the
// known control plane nodes.
ListControlPlaneNodeIPs ListControlPlaneNodeIPsFunc
// LookupIP is net.LookupIP.
LookupIP func(string) ([]net.IP, error)
// InterfaceAddrs is net.InterfaceAddrs.
InterfaceAddrs func() ([]net.Addr, error)
// contains filtered or unexported fields
}
API implements the v2 API.
func (*API) ImageImport ¶
ImageImport implements "POST CLUSTER_API_V2/images/import"
func (*API) Join ¶
func (a *API) Join(ctx context.Context, req JoinRequest) (*JoinResponse, int, error)
Join implements "POST v2/join". Join returns the join response on success, otherwise an error and the HTTP status code.
func (*API) RegisterServer ¶
func (a *API) RegisterServer(server *http.ServeMux, middleware func(f http.HandlerFunc) http.HandlerFunc)
RegisterServer registers the Cluster API v2 endpoints on an HTTP server.
func (*API) RemoveFromDqlite ¶
func (a *API) RemoveFromDqlite(ctx context.Context, req RemoveFromDqliteRequest, token string) (int, error)
RemoveFromDqlite implements the "POST /v2/dqlite/remove" endpoint and removes a node from the dqlite cluster.
type ImageImportRequest ¶
type ImageImportRequest struct {
// Token is the certificate request token.
Token string
// ImageDataReader is an io.Reader that fetches the OCI image tarball bytes.
// ImageDataReader is a reader interface instead of a bytes buffer to avoid reading
// the contents of the image when the token is invalid.
ImageDataReader io.Reader
}
ImageImportRequest is a request for importing an image to the container runtime.
type JoinRequest ¶
type JoinRequest struct {
// ClusterToken is the token generated during "microk8s add-node".
ClusterToken string `json:"token"`
// RemoteHostName is the hostname of the joining host.
RemoteHostName string `json:"hostname"`
// ClusterAgentPort is the port number where the cluster-agent is listening on the joining node.
ClusterAgentPort string `json:"port"`
// WorkerOnly is true when joining a worker-only node.
WorkerOnly WorkerOnlyField `json:"worker"`
// CanHandleCustomEtcd is set by joining nodes that know how to deal with custom etcd endpoints being used by the kube-apiserver.
CanHandleCustomEtcd bool `json:"can_handle_custom_etcd"`
// HostPort is the hostname and port that accepted the request. This is retrieved directly from the *http.Request object.
HostPort string `json:"-"`
// RemoteAddress is the remote address from which the join request originates. This is retrieved directly from the *http.Request object.
RemoteAddress string `json:"-"`
// CanHandleCertificateAuth is set by joining nodes that know how to generate x509 certificates for cluster authentication instead of using auth tokens.
CanHandleCertificateAuth bool `json:"can_handle_x509_auth"`
}
JoinRequest is the request message for the v2/join API endpoint.
type JoinResponse ¶
type JoinResponse struct {
// CertificateAuthority is the root CertificateAuthority certificate for the Kubernetes cluster.
CertificateAuthority string `json:"ca"`
// CallbackToken is a callback token used to authenticate requests with the cluster agent on the joining node.
CallbackToken string `json:"callback_token"`
// APIServerPort is the port where the kube-apiserver is listening.
APIServerPort string `json:"apiport"`
// APIServerAuthorizationMode is the AuthorizationMode used by kube-apiserver.
APIServerAuthorizationMode string `json:"api_authz_mode"`
// KubeletArgs is a string with arguments for the kubelet service on the joining node.
KubeletArgs string `json:"kubelet_args"`
// HostNameOverride is the host name the joining node will be known as in the MicroK8s cluster.
HostNameOverride string `json:"hostname_override"`
// DqliteVoterNodes is a list of known dqlite voter nodes. Each voter is identified as "$IP_ADDRESS:$PORT".
// This is not included in the response when joining worker-only nodes.
DqliteVoterNodes []string `json:"voters,omitempty"`
// ServiceAccountKey is the private key used for signing ServiceAccount tokens.
// This is not included in the response when joining worker-only nodes.
ServiceAccountKey string `json:"service_account_key"`
// AdminToken is a static token used to authenticate in the MicroK8s cluster as "admin".
// This is not included in the response when joining worker-only nodes.
AdminToken string `json:"admin_token,omitempty"`
// CertificateAuthorityKey is the private key of the Certificate Authority.
// Note that this is defined as *string, since the Python code expects this to be explicitly None/nil/null for worker only nodes.
// This is not included in the response when joining worker-only nodes.
CertificateAuthorityKey *string `json:"ca_key"`
// DqliteClusterCertificate is the certificate for connecting to the Dqlite cluster.
// This is not included in the response when joining worker-only nodes.
DqliteClusterCertificate string `json:"cluster_cert,omitempty"`
// DqliteClusterKey is the key for connecting to the Dqlite cluster.
// This is not included in the response when joining worker-only nodes.
DqliteClusterKey string `json:"cluster_key,omitempty"`
// ControlPlaneNodes is a list of known control plane nodes running kube-apiserver.
// This is only included in the response when joining worker-only nodes.
ControlPlaneNodes []string `json:"control_plane_nodes"`
// ClusterCIDR is the cidr that is used by the cluster, defined in kube-proxy args.
ClusterCIDR string `json:"cluster_cidr,omitempty"`
// EtcdServers is the value of the kube-apiserver '--etcd-servers' argument, containing the list of etcd endpoints to use.
// This is only included in the response when a custom data store is configured.
EtcdServers string `json:"etcd_servers,omitempty"`
// EtcdCertificateAuthority is the contents of the file from the kube-apiserver '--etcd-cafile' argument, containing a CA for connecting to the etcd servers. Will be empty if not using TLS.
// This is only included in the response when a custom data store is configured.
EtcdCertificateAuthority string `json:"etcd_ca,omitempty"`
// EtcdClientCertificate is the contents of the file from the kube-apiserver '--etcd-certfile' argument, containing a certificate for connecting to the etcd servers. Will be empty if not using TLS.
// This is only included in the response when a custom data store is configured.
EtcdClientCertificate string `json:"etcd_cert,omitempty"`
// EtcdClientKey is the contents of the file from the kube-apiserver '--etcd-keyfile' argument, containing a private key for connecting to the etcd servers. Will be empty if not using TLS.
// This is only included in the response when a custom data store is configured.
EtcdClientKey string `json:"etcd_key,omitempty"`
}
JoinResponse is the response message for the v2/join API endpoint.
type ListControlPlaneNodeIPsFunc ¶
ListControlPlaneNodeIPsFunc returns a list of the known control plane nodes of a MicroK8s cluster.
type RemoveFromDqliteRequest ¶
type RemoveFromDqliteRequest struct {
// RemoveEndpoint is the endpoint of the node to remove from the dqlite cluster.
RemoveEndpoint string `json:"remove_endpoint"`
}
RemoveFromDqliteRequest represents a request to remove a node from the dqlite cluster.
type WorkerOnlyField ¶
type WorkerOnlyField bool
WorkerOnlyField is the "worker" field of the JoinRequest message.
func (*WorkerOnlyField) UnmarshalJSON ¶
func (v *WorkerOnlyField) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler. It handles boolean values, as well as the string value "as-worker".