Documentation
¶
Index ¶
- Constants
- Variables
- func NetworkResourceToProvisionType(w workloads.Workloader) (pkg.NetResource, error)
- func ResultToSchemaType(r provision.Result) (*workloads.Result, error)
- func WireguardToProvisionType(p workloads.WireguardPeer) (pkg.Peer, error)
- func WorkloadToProvisionType(w workloads.Workloader) (*provision.Reservation, error)
- type Container
- type ContainerCapacity
- type ContainerResult
- type Counter
- type CounterUint64
- type Counters
- func (c *Counters) CheckMemoryRequirements(r *provision.Reservation, totalMemAvailable uint64) error
- func (c *Counters) CurrentUnits() directory.ResourceAmount
- func (c *Counters) CurrentWorkloads() directory.WorkloadAmount
- func (c *Counters) Decrement(r *provision.Reservation) error
- func (c *Counters) Increment(r *provision.Reservation) error
- type Debug
- type Kubernetes
- type KubernetesResult
- type Logs
- type LogsData
- type Mount
- type Network
- type Provisioner
- type PublicIP
- type PublicIPResult
- type Volume
- type VolumeResult
- type ZDB
- type ZDBResult
Constants ¶
const ( // ContainerReservation type ContainerReservation provision.ReservationType = "container" // VolumeReservation type VolumeReservation provision.ReservationType = "volume" // NetworkReservation type NetworkReservation provision.ReservationType = "network" // NetworkResourceReservation type NetworkResourceReservation provision.ReservationType = "network_resource" // ZDBReservation type ZDBReservation provision.ReservationType = "zdb" // DebugReservation type DebugReservation provision.ReservationType = "debug" // KubernetesReservation type KubernetesReservation provision.ReservationType = "kubernetes" // PublicIPReservation type PublicIPReservation provision.ReservationType = "public_ip" )
Variables ¶
var ErrUnsupportedWorkload = errors.New("workload type not supported")
ErrUnsupportedWorkload is return when a workload of a type not supported by provisiond is received from the explorer
var ProvisionOrder = map[provision.ReservationType]int{ DebugReservation: 0, NetworkReservation: 1, NetworkResourceReservation: 2, ZDBReservation: 3, VolumeReservation: 4, ContainerReservation: 5, KubernetesReservation: 6, PublicIPReservation: 7, }
ProvisionOrder is used to sort the workload type in the right order for provision engine
Functions ¶
func NetworkResourceToProvisionType ¶ added in v0.4.0
func NetworkResourceToProvisionType(w workloads.Workloader) (pkg.NetResource, error)
NetworkResourceToProvisionType converts type to internal provision type
func ResultToSchemaType ¶
ResultToSchemaType converts result to schema type
func WireguardToProvisionType ¶
func WireguardToProvisionType(p workloads.WireguardPeer) (pkg.Peer, error)
WireguardToProvisionType converts WireguardPeer1 to pkg.Peer
func WorkloadToProvisionType ¶
func WorkloadToProvisionType(w workloads.Workloader) (*provision.Reservation, error)
WorkloadToProvisionType converts from the explorer type to the internal provision.Reservation
Types ¶
type Container ¶
type Container struct {
// URL of the flist
FList string `json:"flist"`
// URL of the storage backend for the flist
FlistStorage string `json:"flist_storage"`
// Env env variables to container in format
Env map[string]string `json:"env"`
// Env env variables to container that the value is encrypted
// with the node public key. the env will be exposed to plain
// text to the entrypoint.
SecretEnv map[string]string `json:"secret_env"`
// Entrypoint the process to start inside the container
Entrypoint string `json:"entrypoint"`
// Interactivity enable Core X as PID 1 on the container
Interactive bool `json:"interactive"`
// Mounts extra mounts in the container
Mounts []Mount `json:"mounts"`
// Network network info for container
Network Network `json:"network"`
// ContainerCapacity is the amount of resource to allocate to the container
Capacity ContainerCapacity `json:"capacity"`
// Logs contains a list of endpoint where to send containerlogs
Logs []Logs `json:"logs,omitempty"`
// Stats container metrics backend
Stats []stats.Stats `json:"stats,omitempty"`
}
Container creation info
func ContainerToProvisionType ¶
func ContainerToProvisionType(w workloads.Workloader, reservationID string) (Container, string, error)
ContainerToProvisionType converts TfgridReservationContainer1 to Container
type ContainerCapacity ¶
type ContainerCapacity struct {
// Number of CPU
CPU uint `json:"cpu"`
// Memory in MiB
Memory uint64 `json:"memory"`
//DiskType is the type of disk to use for root fs
DiskType pkg.DeviceType `json:"disk_type"`
// DiskSize of the root fs in MiB
DiskSize uint64 `json:"disk_size"`
}
ContainerCapacity is the amount of resource to allocate to the container
type ContainerResult ¶
type ContainerResult struct {
ID string `json:"id"`
IPv6 string `json:"ipv6"`
IPv4 string `json:"ipv4"`
IPYgg string `json:"yggdrasil"`
}
ContainerResult is the information return to the BCDB after deploying a container
type Counter ¶
type Counter interface {
// Increment counter atomically by v
Increment(v uint64) uint64
// Decrement counter atomically by v
Decrement(v uint64) uint64
// Current returns the current value
Current() uint64
}
Counter interface
type CounterUint64 ¶
type CounterUint64 uint64
CounterUint64 value for safe increment/decrement
func (*CounterUint64) Current ¶
func (c *CounterUint64) Current() uint64
Current returns the current value
func (*CounterUint64) Decrement ¶
func (c *CounterUint64) Decrement(v uint64) uint64
Decrement counter atomically by one
func (*CounterUint64) Increment ¶
func (c *CounterUint64) Increment(v uint64) uint64
Increment counter atomically by one
type Counters ¶
type Counters struct {
SRU CounterUint64 // SSD storage in bytes
HRU CounterUint64 // HDD storage in bytes
MRU CounterUint64 // Memory storage in bytes
CRU CounterUint64 // CPU count absolute
// contains filtered or unexported fields
}
Counters tracks the amount of primitives workload deployed and the amount of resource unit used
func (*Counters) CheckMemoryRequirements ¶ added in v0.4.9
func (c *Counters) CheckMemoryRequirements(r *provision.Reservation, totalMemAvailable uint64) error
CheckMemoryRequirements checks memory requirements for a reservation and compares it to whats in the counters and what is the total memory on this node
func (*Counters) CurrentUnits ¶
func (c *Counters) CurrentUnits() directory.ResourceAmount
CurrentUnits return the number of each resource units reserved on the system
func (*Counters) CurrentWorkloads ¶
func (c *Counters) CurrentWorkloads() directory.WorkloadAmount
CurrentWorkloads return the number of each workloads provisioned on the system
type Debug ¶
type Debug struct {
Host string `json:"host"`
Port int `json:"port"`
Channel string `json:"channel"`
}
Debug provision schema
type Kubernetes ¶
type Kubernetes struct {
// Size of the vm, this defines the amount of vCpu, memory, and the disk size
// Docs: docs/kubernetes/sizes.md
Size uint8 `json:"size"`
// NetworkID of the network namepsace in which to run the VM. The network
// must be provisioned previously.
NetworkID pkg.NetID `json:"network_id"`
// IP of the VM. The IP must be part of the subnet available in the network
// resource defined by the networkID on this node
IP net.IP `json:"ip"`
// ClusterSecret is the hex encoded encrypted cluster secret.
ClusterSecret string `json:"cluster_secret"`
// MasterIPs define the URL's for the kubernetes master nodes. If this
// list is empty, this node is considered to be a master node.
MasterIPs []net.IP `json:"master_ips"`
// SSHKeys is a list of ssh keys to add to the VM. Keys can be either
// a full ssh key, or in the form of `github:${username}`. In case of
// the later, the VM will retrieve the github keys for this username
// when it boots.
SSHKeys []string `json:"ssh_keys"`
// PublicIP points to a reservation for a public ip
PublicIP schema.ID `json:"public_ip"`
PlainClusterSecret string `json:"-"`
}
Kubernetes reservation data
func K8SToProvisionType ¶
func K8SToProvisionType(w workloads.Workloader) (Kubernetes, string, error)
K8SToProvisionType converts type to internal provision type
type KubernetesResult ¶
KubernetesResult result returned by k3s reservation
type LogsData ¶ added in v0.4.9
type LogsData struct {
// Stdout is the redis url for stdout (redis://host/channel)
Stdout string `json:"stdout"`
// Stderr is the redis url for stderr (redis://host/channel)
Stderr string `json:"stderr"`
// SecretStdout like stdout but encrypted with node public key
SecretStdout string `json:"secret_stdout"`
// SecretStderr like stderr but encrypted with node public key
SecretStderr string `json:"secret_stderr"`
}
LogsData structure
type Network ¶
type Network struct {
NetworkID pkg.NetID `json:"network_id"`
// IP to give to the container
IPs []net.IP `json:"ips"`
PublicIP6 bool `json:"public_ip6"`
YggdrasilIP bool `json:"yggdrasil_ip"`
}
Network struct
type Provisioner ¶
type Provisioner struct {
Provisioners map[provision.ReservationType]provision.ProvisionerFunc
Decommissioners map[provision.ReservationType]provision.DecomissionerFunc
// contains filtered or unexported fields
}
Provisioner hold all the logic responsible to provision and decomission the different primitives workloads defined by this package
func NewProvisioner ¶
func NewProvisioner(cache provision.ReservationCache, zbus zbus.Client) *Provisioner
NewProvisioner creates a new 0-OS provisioner
func (*Provisioner) RuntimeUpgrade ¶ added in v0.4.0
func (p *Provisioner) RuntimeUpgrade(ctx context.Context)
RuntimeUpgrade runs upgrade needed when provision daemon starts
type PublicIP ¶ added in v0.4.9
type PublicIP struct {
// IP of the VM. The IP must be part of the subnet available in the network
// resource defined by the networkID on this node
IP net.IPNet `json:"ip"`
}
PublicIP structure
func PublicIPToProvisionType ¶ added in v0.4.9
func PublicIPToProvisionType(w workloads.Workloader) (PublicIP, string, error)
PublicIPToProvisionType converts type to internal provision type
type PublicIPResult ¶ added in v0.4.9
PublicIPResult result returned by publicIP reservation
type Volume ¶
type Volume struct {
// Size of the volume in GiB
Size uint64 `json:"size"`
// Type of disk underneath the volume
Type pkg.DeviceType `json:"type"`
}
Volume defines a mount point
func VolumeToProvisionType ¶
func VolumeToProvisionType(w workloads.Workloader) (Volume, string, error)
VolumeToProvisionType converts TfgridReservationVolume1 to Volume
type VolumeResult ¶
type VolumeResult struct {
ID string `json:"volume_id"`
}
VolumeResult is the information return to the BCDB after deploying a volume
type ZDB ¶
type ZDB struct {
Size uint64 `json:"size"`
Mode pkg.ZDBMode `json:"mode"`
Password string `json:"password"`
DiskType pkg.DeviceType `json:"disk_type"`
Public bool `json:"public"`
PlainPassword string `json:"-"`
}
ZDB namespace creation info
func ZDBToProvisionType ¶
func ZDBToProvisionType(w workloads.Workloader) (ZDB, string, error)
ZDBToProvisionType converts TfgridReservationZdb1 to ZDB