services

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: BSD-3-Clause Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Terminate the TLS connection at the KraftCloud gateway using our wildcard
	// certificate issued for the kraft.cloud domain. The gateway forwards the
	// unencrypted traffic to your application.
	HandlerTLS = Handler("tls")

	// Enable HTTP mode on the load balancer to load balance on the level of
	// individual HTTP requests. In this mode, only HTTP connections are accepted.
	// If this option is not set the load balancer works in TCP mode and
	// distributes TCP connections.
	HandlerHTTP = Handler("http")

	// Redirect traffic from the source port to the destination port.
	HandlerRedirect = Handler("redirect")
)
View Source
const (
	// Endpoint is the public path for the services service.
	Endpoint = "/services"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler added in v0.3.0

type Handler string

Connection Handlers. KraftCloud uses connection handlers to decide how to forward connections from the Internet to your application. You configure the handlers for every published service port individually.

Currently, there is a set of constraints when publishing ports:

  • Port 80: Must have http and must not have tls set;
  • Port 443: Must have http and tls set;
  • The `redirect` handler can only be set on port 80 (HTTP) to redirect to port 443 (HTTPS);
  • All other ports must have tls and must not have http set.

func Handlers added in v0.3.0

func Handlers() []Handler

Handlers returns all possible service handlers.

type Service added in v0.3.0

type Service struct {
	// Public-facing port.
	Port int `json:"port"`

	// Application port to which inbound traffic is redirected.
	DestinationPort int `json:"destination_port,omitempty"`

	// List of handlers.
	Handlers []Handler `json:"handlers,omitempty"`
}

A service helps describe the the load balancing and autoscale groups.

type ServiceCreateRequest added in v0.3.0

type ServiceCreateRequest struct {
	// Services is a list of descriptiosn of exposed network services.
	Services []Service `json:"services"`
}

type ServiceGroup added in v0.3.0

type ServiceGroup struct {
	// The status of the service group. 'success' on success, or 'error' if the
	// request failed.
	Status string `json:"status,omitempty"`

	// UUID of the group.
	UUID string `json:"uuid,omitempty"`

	// Public DNS name under which the group is accessible from the Internet.
	DNS string `json:"dns,omitempty"`

	// Instances contains a list of UUID representing instances attached to this
	// group.
	Instances []string `json:"instances,omitempty"`

	// Services contains the descriptions of exposed network services.
	Services []Service `json:"services,omitempty"`

	// Persistent indicates if the group will stay alive even after the last
	// instance detached.
	Persistent bool `json:"persistent,omitempty"`

	// Date and time of creation in ISO8601.
	CreatedAt string `json:"created_at,omitempty"`
}

A service group has a public DNS name such as young-monkey-uq6dxq0u.fra0.kraft.cloud. When you assign an instance to a service group, the instance becomes accessible from the Internet using this DNS name. KraftCloud generates a random DNS name of that form for every service group.

Except for unencrypted HTTP traffic on port 80, KraftCloud accepts only TLS connections from the Internet. It uses Server Name Indication (SNI) to forward inbound traffic to your application.

By default, a service group does not publish any services. To allow traffic to pass to the instances in the service group, you specify the network ports to publish. For example, if you run a web server you would publish port 80 (HTTP) and/or port 443 (HTTPS).

type ServicesService added in v0.3.0

type ServicesService interface {
	client.ServiceClient[ServicesService]

	// Creates one or more service groups with the given configuration. Note that,
	// the service group properties like published ports can only be defined
	// during creation. They cannot be changed later.
	//
	// Each port in a service group can specify a list of handlers that determine
	// how traffic arriving at the port is handled. See Connection Handlers for a
	// complete overview.
	//
	// You can specify an array of service group descriptions to create multiple
	// groups with different properties with the same call.
	//
	// See: https://docs.kraft.cloud/003-rest-api-v1-services.html#creating-new-service-groups
	Create(ctx context.Context, req ServiceCreateRequest) (*ServiceGroup, error)

	// Returns the current status and the configuration of a service group.
	//
	// See: https://docs.kraft.cloud/003-rest-api-v1-services.html#getting-the-status-of-a-service-group
	Status(ctx context.Context, uuid string) (*ServiceGroup, error)

	// Lists all existing service groups. You can filter by persistence and DNS
	// name. The latter can be used to lookup the UUID of the service group that
	// owns a certain DNS name. The returned groups fulfill all provided filter
	// criteria. No particular value is assumed if a filter is not part of the
	// request.
	//
	// The array of groups in the response can be directly fed into the other
	// endpoints, for example, to delete (empty) groups.
	//
	// See: https://docs.kraft.cloud/003-rest-api-v1-services.html#list-existing-service-groups
	List(ctx context.Context) ([]ServiceGroup, error)

	// Deletes the specified service group. Fails if there are still instances
	// attached to group. After this call the UUID of the group is no longer
	// valid.
	//
	// This operation cannot be undone.
	//
	// See: https://docs.kraft.cloud/003-rest-api-v1-services.html#deleting-a-service-group
	Delete(ctx context.Context, uuid string) (*ServiceGroup, error)
}

func NewServicesClientFromOptions

func NewServicesClientFromOptions(opts *options.Options) ServicesService

NewServicesClientFromOptions instantiates a new image services client based on the provided pre-existing options.

Jump to

Keyboard shortcuts

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