Documentation
¶
Index ¶
- Constants
- Variables
- func LatestCaddyImage() (reference.NamedTagged, error)
- func MachineMatchesFilter(machine *pb.MachineMember, filter *api.MachineFilter) bool
- func PrintWarning(msg string)
- type Client
- func (cli *Client) Close() error
- func (cli *Client) CreateContainer(ctx context.Context, serviceID string, spec api.ServiceSpec, machineID string) (container.CreateResponse, error)
- func (cli *Client) CreateIngressRecords(ctx context.Context, serviceID string) ([]*pb.DNSRecord, error)
- func (cli *Client) CreateVolume(ctx context.Context, machineNameOrID string, opts volume.CreateOptions) (api.MachineVolume, error)
- func (cli *Client) GetDomain(ctx context.Context) (string, error)
- func (cli *Client) InspectContainer(ctx context.Context, serviceNameOrID, containerNameOrID string) (api.MachineServiceContainer, error)
- func (cli *Client) InspectImage(ctx context.Context, id string) ([]api.MachineImage, error)
- func (cli *Client) InspectMachine(ctx context.Context, nameOrID string) (*pb.MachineMember, error)
- func (cli *Client) InspectRemoteImage(ctx context.Context, id string) ([]api.MachineRemoteImage, error)
- func (cli *Client) InspectService(ctx context.Context, nameOrID string) (api.Service, error)
- func (cli *Client) InspectServiceFromStore(ctx context.Context, id string) (api.Service, error)
- func (cli *Client) ListMachines(ctx context.Context, filter *api.MachineFilter) (api.MachineMembersList, error)
- func (cli *Client) ListServices(ctx context.Context) ([]api.Service, error)
- func (cli *Client) ListVolumes(ctx context.Context, filter *api.VolumeFilter) ([]api.MachineVolume, error)
- func (cli *Client) NewCaddyDeployment(image string, placement api.Placement) (*deploy.Deployment, error)
- func (cli *Client) NewDeployment(spec api.ServiceSpec, strategy deploy.Strategy) *deploy.Deployment
- func (cli *Client) RemoveContainer(ctx context.Context, serviceNameOrID, containerNameOrID string, ...) error
- func (cli *Client) RemoveService(ctx context.Context, id string) error
- func (cli *Client) RemoveVolume(ctx context.Context, machineNameOrID, volumeName string, force bool) error
- func (cli *Client) RunService(ctx context.Context, spec api.ServiceSpec) (api.RunServiceResponse, error)
- func (cli *Client) ServiceOperationNameResolver(ctx context.Context, svc api.Service) (*MapNameResolver, error)
- func (cli *Client) StartContainer(ctx context.Context, serviceNameOrID, containerNameOrID string) error
- func (cli *Client) StopContainer(ctx context.Context, serviceNameOrID, containerNameOrID string, ...) error
- type Connector
- type MapNameResolver
- type User
Constants ¶
const ( CaddyServiceName = "caddy" // CaddyImage is the official Caddy Docker image on Docker Hub: https://hub.docker.com/_/caddy CaddyImage = "caddy" )
Variables ¶
var ErrNoReachableMachines = errors.New("no internet-reachable machines running service containers")
Functions ¶
func LatestCaddyImage ¶
func LatestCaddyImage() (reference.NamedTagged, error)
LatestCaddyImage returns the latest image of the official Caddy Docker image on Docker Hub. The latest image is determined by the latest version tag 2.x.x.
func MachineMatchesFilter ¶ added in v0.6.0
func MachineMatchesFilter(machine *pb.MachineMember, filter *api.MachineFilter) bool
func PrintWarning ¶ added in v0.6.0
func PrintWarning(msg string)
Types ¶
type Client ¶
type Client struct {
pb.MachineClient
pb.ClusterClient
// Docker is a namespaced client for the Docker service to distinguish Uncloud-specific service container operations
// from generic Docker operations.
Docker *docker.Client
// contains filtered or unexported fields
}
Client is a client for the machine API.
func New ¶
New creates a new client for the machine API. The connector is used to establish the connection either locally or remotely. The client is responsible for closing the connector.
func (*Client) CreateContainer ¶
func (cli *Client) CreateContainer( ctx context.Context, serviceID string, spec api.ServiceSpec, machineID string, ) (container.CreateResponse, error)
CreateContainer creates a new container for the given service on the specified machine.
func (*Client) CreateIngressRecords ¶
func (cli *Client) CreateIngressRecords(ctx context.Context, serviceID string) ([]*pb.DNSRecord, error)
CreateIngressRecords verifies which machines running the specified service (typically Caddy) are reachable from the internet, then creates DNS records for the cluster domain pointing to those machines. It tests each machine by sending HTTP requests to their public IPs. Only machines that respond correctly with their machine ID are included in the resulting DNS configuration. Returns the created DNS records or an error.
func (*Client) CreateVolume ¶ added in v0.6.0
func (cli *Client) CreateVolume( ctx context.Context, machineNameOrID string, opts volume.CreateOptions, ) (api.MachineVolume, error)
CreateVolume creates a new volume on the specified machine.
func (*Client) GetDomain ¶
GetDomain returns the cluster domain name or ErrNotFound if it hasn't been reserved yet.
func (*Client) InspectContainer ¶
func (cli *Client) InspectContainer( ctx context.Context, serviceNameOrID, containerNameOrID string, ) (api.MachineServiceContainer, error)
InspectContainer returns the information about the specified container within the service.
func (*Client) InspectImage ¶
func (*Client) InspectMachine ¶
func (*Client) InspectRemoteImage ¶
func (*Client) InspectService ¶
InspectService returns detailed information about a service and its containers. The nameOrID parameter can be either a service name or ID.
func (*Client) InspectServiceFromStore ¶
InspectServiceFromStore returns detailed information about a service and its containers from the distributed store. Due to eventual consistency of the store, the returned information may not reflect the most recent changes. The id parameter can be either a service ID or name.
func (*Client) ListMachines ¶
func (cli *Client) ListMachines(ctx context.Context, filter *api.MachineFilter) (api.MachineMembersList, error)
ListMachines returns a list of all machines registered in the cluster that match the filter.
func (*Client) ListServices ¶
ListServices returns a list of all services and their containers.
func (*Client) ListVolumes ¶ added in v0.6.0
func (cli *Client) ListVolumes(ctx context.Context, filter *api.VolumeFilter) ([]api.MachineVolume, error)
ListVolumes returns a list of all volumes on the cluster machines that match the filter.
func (*Client) NewCaddyDeployment ¶
func (cli *Client) NewCaddyDeployment(image string, placement api.Placement) (*deploy.Deployment, error)
NewCaddyDeployment creates a new deployment for a Caddy reverse proxy service. The service is deployed in global mode to all machines in the cluster. If the image is not provided, the latest version of the official Caddy Docker image is used.
func (*Client) NewDeployment ¶
func (cli *Client) NewDeployment(spec api.ServiceSpec, strategy deploy.Strategy) *deploy.Deployment
NewDeployment creates a new deployment for the given service specification. If strategy is nil, a default deploy.RollingStrategy will be used.
func (*Client) RemoveContainer ¶
func (cli *Client) RemoveContainer( ctx context.Context, serviceNameOrID, containerNameOrID string, opts container.RemoveOptions, ) error
RemoveContainer removes the specified container within the service.
func (*Client) RemoveService ¶
RemoveService removes all containers on all machines that belong to the specified service. The id parameter can be either a service ID or name.
func (*Client) RemoveVolume ¶ added in v0.6.0
func (cli *Client) RemoveVolume(ctx context.Context, machineNameOrID, volumeName string, force bool) error
RemoveVolume removes a volume from the specified machine.
func (*Client) RunService ¶
func (cli *Client) RunService(ctx context.Context, spec api.ServiceSpec) (api.RunServiceResponse, error)
func (*Client) ServiceOperationNameResolver ¶
func (cli *Client) ServiceOperationNameResolver(ctx context.Context, svc api.Service) (*MapNameResolver, error)
ServiceOperationNameResolver returns a machine and container name resolver for a service that can be used to format deployment operations.
func (*Client) StartContainer ¶
func (cli *Client) StartContainer(ctx context.Context, serviceNameOrID, containerNameOrID string) error
StartContainer starts the specified container within the service.
func (*Client) StopContainer ¶
func (cli *Client) StopContainer( ctx context.Context, serviceNameOrID, containerNameOrID string, opts container.StopOptions, ) error
StopContainer stops the specified container within the service.
type MapNameResolver ¶
type MapNameResolver struct {
// contains filtered or unexported fields
}
MapNameResolver resolves machine and container IDs to their names using a static map.
func NewNameResolver ¶
func NewNameResolver(machines, containers map[string]string) *MapNameResolver
func (*MapNameResolver) ContainerName ¶
func (r *MapNameResolver) ContainerName(containerID string) string
func (*MapNameResolver) MachineName ¶
func (r *MapNameResolver) MachineName(machineID string) string
type User ¶
type User struct {
// contains filtered or unexported fields
}