v1

package
v0.0.0-...-71cdb78 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const HTTPPrefix = "/cluster/api/v1.0"

HTTPPrefix is the prefix for all v1 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

	// LookupIP is net.LookupIP.
	LookupIP func(string) ([]net.IP, error)
}

API implements the v1 API.

func (*API) Configure

func (a *API) Configure(ctx context.Context, req ConfigureRequest) error

Configure implements "POST /CLUSTER_API_V1/configure".

func (*API) Join

func (a *API) Join(ctx context.Context, request JoinRequest) (*JoinResponse, error)

Join implements "POST /CLUSTER_API_V1/join".

func (*API) RegisterServer

func (a *API) RegisterServer(server *http.ServeMux, middleware func(f http.HandlerFunc) http.HandlerFunc)

RegisterServer registers the Cluster API v1 endpoints on an HTTP server.

func (*API) SignCert

func (a *API) SignCert(ctx context.Context, req SignCertRequest) (*SignCertResponse, error)

SignCert implements "POST CLUSTER_API_V1/sign-cert".

func (*API) Upgrade

func (a *API) Upgrade(ctx context.Context, req UpgradeRequest) error

Upgrade implements "POST v1/upgrade".

type APIServerAuthMode

type APIServerAuthMode string

APIServerAuthMode is used to define which mode should be used for authenticating to the kube-apiserver.

var (
	// APIServerAuthModeCert instructs the client to configure and use x509 certificates to authenticate with kube-apiserver.
	APIServerAuthModeCert APIServerAuthMode = "Cert"
	// APIServerAuthModeToken instructs the client to configure and use static tokens to authenticate with kube-apiserver.
	APIServerAuthModeToken APIServerAuthMode = "Token"
)

type ConfigureAddonRequest

type ConfigureAddonRequest struct {
	// Name is the name of the addon.
	Name string `json:"name"`
	// Enable is true if we want to enable the addon.
	Enable bool `json:"enable"`
	// Disable is true if we want to disable the addon.
	Disable bool `json:"disable"`
}

ConfigureAddonRequest is a configuration request for a MicroK8s addon.

type ConfigureRequest

type ConfigureRequest struct {
	// CallbackToken is the callback token used to authenticate the request.
	CallbackToken string `json:"callback"`

	// ConfigureServices is a list of configuration updates for the MicroK8s services.
	ConfigureServices []ConfigureServiceRequest `json:"service"`

	// ConfigureAddons is a list of addons to manage
	ConfigureAddons []ConfigureAddonRequest `json:"addon"`
}

ConfigureRequest is the request message for the v1/configure endpoint.

type ConfigureServiceRequest

type ConfigureServiceRequest struct {
	// Name is the service name.
	Name string `json:"name"`
	// UpdateArguments is a map of arguments to be updated.
	UpdateArguments []map[string]string `json:"arguments_update"`
	// RemoveArguments is a list of arguments to remove.
	RemoveArguments []string `json:"arguments_remove"`
	// Restart defines whether the service should be restarted.
	Restart RestartServiceField `json:"restart"`
}

ConfigureServiceRequest is a configuration request for MicroK8s.

type JoinRequest

type JoinRequest struct {
	// ClusterToken is the token generated during "microk8s add-node".
	ClusterToken string `json:"token"`
	// HostName is the hostname of the joining host.
	HostName string `json:"hostname"`
	// ClusterAgentPort is the port number where the cluster-agent is listening on the joining node.
	ClusterAgentPort string `json:"port"`
	// CallbackToken is a token that this node can use to authenticate with the cluster-agent on the joining node.
	CallbackToken string `json:"callback"`
	// 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 worker 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 data for the join API endpoint.

type JoinResponse

type JoinResponse struct {
	// CertificateAuthority is the root CertificateAuthority certificate for the Kubernetes cluster.
	CertificateAuthority string `json:"ca"`
	// EtcdEndpoint is the endpoint where the etcd server is running, typically https://0.0.0.0:12379.
	// Note that "0.0.0.0" in the response will be replaced with the IP used to join the new node.
	EtcdEndpoint string `json:"etcd"`
	// APIServerAuthMode instructs the client with auth mode to configure for talking to the kube-apiserver.
	APIServerAuthMode APIServerAuthMode `json:"api_authn_mode"`
	// APIServerPort is the port where the kube-apiserver is listening.
	APIServerPort string `json:"apiport"`
	// KubeProxyToken is a token used to authenticate kube-proxy on the joining node.
	KubeProxyToken string `json:"kubeproxy"`
	// KubeletToken is a token used to authenticate kubelet on the joining node.
	KubeletToken string `json:"kubelet"`
	// 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"`
	// ClusterCIDR is the cidr that is used by the cluster, defined in kube-proxy args.
	ClusterCIDR string `json:"cluster_cidr,omitempty"`
}

JoinResponse is the response data for the join API endpoint.

type RestartServiceField

type RestartServiceField bool

RestartServiceField is the "restart" field of the ConfigureServiceRequest message.

func (*RestartServiceField) UnmarshalJSON

func (v *RestartServiceField) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler. It handles both boolean values, as well as the string value "yes".

type SignCertRequest

type SignCertRequest struct {
	// Token is the certificate request token.
	Token string `json:"token"`
	// CertificateSigningRequest is the signing request file contents.
	CertificateSigningRequest string `json:"request"`
}

SignCertRequest is the request message for the sign-cert endpoint.

type SignCertResponse

type SignCertResponse struct {
	// Certificate is the contents of the signed certificate.
	Certificate string `json:"certificate"`
}

SignCertResponse is the response message for the sign-cert endpoint.

type UpgradeRequest

type UpgradeRequest struct {
	// CallbackToken is the callback token used to authenticate the request.
	CallbackToken string `json:"callback"`
	// UpgradeName is the name of the upgrade to perform. Upgrades are listed in the `upgrade-scripts` directory,
	// for example "000-switch-to-calico".
	UpgradeName string `json:"upgrade"`
	// UpgradePhase is the current phase of the upgrade to perform. We do cluster upgrades with a 2-phase commit
	// mechanism. This can be "prepare", "commit", or "rollback".
	UpgradePhase string `json:"phase"`
}

UpgradeRequest is the request message for the v1/upgrade endpoint.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL