primitives

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: Apache-2.0 Imports: 35 Imported by: 1

Documentation

Index

Constants

View Source
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"
	// VirtualMachineReservation type
	VirtualMachineReservation provision.ReservationType = "virtual_machine"
)
View Source
const FListElevated = "https://hub.grid.tf/tf-elevated/"

FListElevated url of privileged container

View Source
const VMREPO = "https://hub.grid.tf/tf-official-vms/"

VMREPO in which all the vm flists are stored

View Source
const VMTAG = "latest"

VMTAG the tag of the vm images

Variables

View Source
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

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

func ResultToSchemaType(r provision.Result) (*workloads.Result, error)

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, usableMemoryBytes 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 Units are in GiB

func (*Counters) CurrentWorkloads

func (c *Counters) CurrentWorkloads() directory.WorkloadAmount

CurrentWorkloads return the number of each workloads provisioned on the system

func (*Counters) Decrement

func (c *Counters) Decrement(r *provision.Reservation) error

Decrement is called by the provision.Engine when a reservation has been decommissioned

func (*Counters) Increment

func (c *Counters) Increment(r *provision.Reservation) error

Increment is called by the provision.Engine when a reservation has been provisionned

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 {
	VM `json:",inline"`

	// 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"`

	PlainClusterSecret string `json:"-"`

	DatastoreEndpoint     string `json:"datastore_endpoint"`
	DisableDefaultIngress bool   `json:"disable_default_ingress"`
}

Kubernetes reservation data

func K8SToProvisionType

func K8SToProvisionType(w workloads.Workloader) (Kubernetes, string, error)

K8SToProvisionType converts type to internal provision type

func (*Kubernetes) Validate added in v0.5.0

func (k *Kubernetes) Validate() error

Validate validates the vm configuration, master ip, clutser secret

type KubernetesCustomSize added in v0.5.0

type KubernetesCustomSize struct {
	CRU int64   `json:"cru"`
	MRU float64 `json:"mru"`
	SRU float64 `json:"sru"`
}

KubernetesCustomSize type

type KubernetesResult

type KubernetesResult struct {
	ID string `json:"id"`
	IP string `json:"ip"`
}

KubernetesResult result returned by k3s reservation

type Logs added in v0.4.9

type Logs struct {
	Type string   `json:"type"`
	Data LogsData `json:"data"`
}

Logs defines a custom backend with variable settings

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 Mount

type Mount struct {
	VolumeID   string `json:"volume_id"`
	Mountpoint string `json:"mountpoint"`
}

Mount defines a container volume mounted inside the container

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

func (*PublicIP) Valid added in v0.4.9

func (p *PublicIP) Valid() error

Valid validate public ip input

type PublicIPResult added in v0.4.9

type PublicIPResult struct {
	ID string `json:"id"`
	IP string `json:"ip"`
}

PublicIPResult result returned by publicIP reservation

type VM added in v0.5.0

type VM struct {
	// Size of the vm, this defines the amount of vCpu, memory, and the disk size
	// Docs: docs/kubernetes/sizes.md
	Size int64 `json:"size"`

	Custom VMCustomSize `json:"custom_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"`

	SSHKeys []string `json:"ssh_keys"`
	// PublicIP points to a reservation for a public ip
	PublicIP schema.ID `json:"public_ip"`

	// A name of a predefined list of VMs
	Name string `json:"name"`
}

VM reservation data

func VMToProvisionType added in v0.5.0

func VMToProvisionType(w workloads.Workloader) (VM, string, error)

VMToProvisionType converts type to internal provision type

func (*VM) Validate added in v0.5.0

func (k *VM) Validate() error

Validate validates the vm config, name, ip, size, and ssh keys

type VMCustomSize added in v0.5.0

type VMCustomSize struct {
	CRU int64   `json:"cru"`
	MRU float64 `json:"mru"`
	SRU float64 `json:"sru"`
}

VMCustomSize type

type VMInfo added in v0.5.0

type VMInfo struct {
	Initrd    string
	Kernel    string
	ImagePath string
}

VMInfo kernel initrd and the raw disk path of the vm

type VMResult added in v0.5.0

type VMResult struct {
	ID string `json:"id"`
	IP string `json:"ip"`
}

VMResult result returned by k3s 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

type ZDBResult

type ZDBResult struct {
	Namespace string
	IPs       []string
	Port      uint
}

ZDBResult is the information return to the BCDB after deploying a 0-db namespace

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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