fullnode

package
v0.12.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ChainHomeDir is the abs filepath for the chain's home directory.
	ChainHomeDir = workDir + "/cosmos"
)

Variables

This section is empty.

Functions

func BuildConfigMaps

func BuildConfigMaps(crd *cosmosv1.CosmosFullNode, p2p ExternalAddresses) ([]diff.Resource[*corev1.ConfigMap], error)

BuildConfigMaps creates a ConfigMap with configuration to be mounted as files into containers. Currently, the config.toml (for Tendermint) and app.toml (for the Cosmos SDK).

func BuildNodeKeySecrets added in v0.12.0

func BuildNodeKeySecrets(existing []*corev1.Secret, crd *cosmosv1.CosmosFullNode) ([]diff.Resource[*corev1.Secret], error)

BuildNodeKeySecrets builds the node key secrets for the given CRD. If the secret already has a node key, it is reused. Returns an error if a new node key cannot be serialized. (Should never happen.)

func BuildPVCs

BuildPVCs outputs desired PVCs given the crd.

func BuildPods

func BuildPods(crd *cosmosv1.CosmosFullNode, cksums ConfigChecksums) ([]diff.Resource[*corev1.Pod], error)

BuildPods creates the final state of pods given the crd.

func BuildServices

func BuildServices(crd *cosmosv1.CosmosFullNode) []diff.Resource[*corev1.Service]

BuildServices returns a list of services given the crd.

Creates a single RPC service, likely for use with an Ingress.

Creates 1 p2p service per pod. P2P diverges from traditional web and kubernetes architecture which calls for a single p2p service backed by multiple pods. Pods may be in various states even with proper readiness probes. Therefore, we do not want to confuse or disrupt peer exchange (PEX) within tendermint. If using a single p2p service, an outside peer discovering a pod out of sync it could be interpreted as byzantine behavior if the peer previously connected to a pod that was in sync through the same external address.

func DownloadGenesisCommand

func DownloadGenesisCommand(cfg cosmosv1.ChainSpec) (string, []string)

DownloadGenesisCommand returns a proper genesis command for use in an init container.

The general strategy is if the user does not configure an external genesis file, use the genesis from the <chain-binary> init command. If the user supplies a custom script, we use that. Otherwise, we use attempt to download and extract the file.

func DownloadSnapshotCommand

func DownloadSnapshotCommand(cfg cosmosv1.ChainSpec) (string, []string)

DownloadSnapshotCommand returns a command and args for downloading and restoring from a snapshot.

func PVCName

func PVCName(pod *corev1.Pod) string

PVCName returns the primary PVC holding the chain data associated with the pod.

func ResetStatus

func ResetStatus(crd *cosmosv1.CosmosFullNode)

ResetStatus is used at the beginning of the reconcile loop. It resets the crd's status to a fresh state.

Types

type Client

type Client interface {
	client.Reader
	client.Writer

	Scheme() *runtime.Scheme
}

Client is a controller client. It is a subset of client.Client.

type ConfigChecksums added in v0.12.0

type ConfigChecksums map[client.ObjectKey]string

type ConfigMapControl

type ConfigMapControl struct {
	// contains filtered or unexported fields
}

ConfigMapControl creates or updates configmaps.

func NewConfigMapControl

func NewConfigMapControl(client Client) ConfigMapControl

NewConfigMapControl returns a valid ConfigMapControl.

func (ConfigMapControl) Reconcile

Reconcile creates or updates configmaps containing items that are mounted into pods as files. The ConfigMap is never deleted unless the CRD itself is deleted.

type DiskUsageCollector added in v0.10.0

type DiskUsageCollector struct {
	// contains filtered or unexported fields
}

func NewDiskUsageCollector added in v0.10.0

func NewDiskUsageCollector(diskClient DiskUsager, lister Reader) *DiskUsageCollector

func (DiskUsageCollector) CollectDiskUsage added in v0.10.0

func (c DiskUsageCollector) CollectDiskUsage(ctx context.Context, crd *cosmosv1.CosmosFullNode) ([]PVCDiskUsage, error)

CollectDiskUsage retrieves the disk usage information for all pods belonging to the specified CosmosFullNode.

It returns a slice of PVCDiskUsage objects representing the disk usage information for each PVC or an error if fetching disk usage via all pods was unsuccessful.

type DiskUsager added in v0.10.0

type DiskUsager interface {
	DiskUsage(ctx context.Context, host string) (healthcheck.DiskUsageResponse, error)
}

DiskUsager fetches disk usage statistics

type ExternalAddresses

type ExternalAddresses map[string]string

ExternalAddresses keys are instance names and values are public IPs or hostnames.

func CollectP2PAddresses

CollectP2PAddresses collects external addresses from p2p services.

func (ExternalAddresses) Incomplete

func (addrs ExternalAddresses) Incomplete() bool

Incomplete returns true if any instances do not have a public IP or hostname.

type Lister

type Lister interface {
	List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
}

Lister can list resources, subset of client.Client.

type NodeKeyControl added in v0.12.0

type NodeKeyControl struct {
	// contains filtered or unexported fields
}

NodeKeyControl reconciles node keys for a CosmosFullNode. Node keys are saved as secrets and later mounted into pods.

func NewNodeKeyControl added in v0.12.0

func NewNodeKeyControl(client Client) NodeKeyControl

func (NodeKeyControl) Reconcile added in v0.12.0

func (control NodeKeyControl) Reconcile(ctx context.Context, reporter kube.Reporter, crd *cosmosv1.CosmosFullNode) kube.ReconcileError

Reconcile is the control loop for node keys. The secrets are never deleted.

type PVCAutoScaler added in v0.10.0

type PVCAutoScaler struct {
	// contains filtered or unexported fields
}

func NewPVCAutoScaler added in v0.10.0

func NewPVCAutoScaler(client StatusSyncer) *PVCAutoScaler

func (PVCAutoScaler) SignalPVCResize added in v0.10.0

func (scaler PVCAutoScaler) SignalPVCResize(ctx context.Context, crd *cosmosv1.CosmosFullNode, results []PVCDiskUsage) (bool, error)

SignalPVCResize patches the CosmosFullNode.status.selfHealing with the new calculated PVC size as a resource quantity. Assumes CosmosfullNode.spec.selfHealing.pvcAutoScaling is set or else this method may panic. The CosmosFullNode controller is responsible for increasing the PVC disk size.

Returns true if the status was patched.

Returns false and does not patch if: 1. The PVCs do not need resizing 2. The status already has >= calculated size. 3. The maximum size has been reached. It will patch up to the maximum size.

Returns an error if patching unsuccessful.

type PVCControl

type PVCControl struct {
	// contains filtered or unexported fields
}

PVCControl reconciles volumes for a CosmosFullNode. Unlike StatefulSet, PVCControl will update volumes by deleting and recreating volumes.

func NewPVCControl

func NewPVCControl(client Client) PVCControl

NewPVCControl returns a valid PVCControl

func (PVCControl) Reconcile

func (control PVCControl) Reconcile(ctx context.Context, reporter kube.Reporter, crd *cosmosv1.CosmosFullNode) (bool, kube.ReconcileError)

Reconcile is the control loop for PVCs. The bool return value, if true, indicates the controller should requeue the request.

type PVCDiskUsage added in v0.10.0

type PVCDiskUsage struct {
	Name        string // pvc name
	PercentUsed int
	Capacity    resource.Quantity
}

type PeerCollector added in v0.12.0

type PeerCollector struct {
	// contains filtered or unexported fields
}

PeerCollector finds and collects

func NewPeerCollector added in v0.12.0

func NewPeerCollector(client Lister, tmClient cosmos.TendermintStatuser) *PeerCollector

func (PeerCollector) CollectAddresses added in v0.12.0

func (collector PeerCollector) CollectAddresses(ctx context.Context, crd *cosmosv1.CosmosFullNode) ([]string, error)

CollectAddresses queries pods for their tendermint/cometbft peer addresses and returns them in <node_id>@<ip:port> format. Any error can be treated as transient and retried.

type PodBuilder

type PodBuilder struct {
	// contains filtered or unexported fields
}

PodBuilder builds corev1.Pods

func NewPodBuilder

func NewPodBuilder(crd *cosmosv1.CosmosFullNode) PodBuilder

NewPodBuilder returns a valid PodBuilder.

Panics if any argument is nil.

func (PodBuilder) Build

func (b PodBuilder) Build() (*corev1.Pod, error)

Build assigns the CosmosFullNode crd as the owner and returns a fully constructed pod.

func (PodBuilder) WithOrdinal

func (b PodBuilder) WithOrdinal(ordinal int32) PodBuilder

WithOrdinal updates adds name and other metadata to the pod using "ordinal" which is the pod's ordered sequence. Pods have deterministic, consistent names similar to a StatefulSet instead of generated names.

type PodControl

type PodControl struct {
	// contains filtered or unexported fields
}

PodControl reconciles pods for a CosmosFullNode.

func NewPodControl

func NewPodControl(client Client, filter PodFilter) PodControl

NewPodControl returns a valid PodControl.

func (PodControl) Reconcile

func (pc PodControl) Reconcile(ctx context.Context, reporter kube.Reporter, crd *cosmosv1.CosmosFullNode, cksums ConfigChecksums) (bool, kube.ReconcileError)

Reconcile is the control loop for pods. The bool return value, if true, indicates the controller should requeue the request.

type PodFilter added in v0.8.0

type PodFilter interface {
	SyncedPods(ctx context.Context, log kube.Logger, candidates []*corev1.Pod) []*corev1.Pod
}

type Reader added in v0.10.0

type Reader = client.Reader

Reader lists and gets objects.

type ServiceControl

type ServiceControl struct {
	// contains filtered or unexported fields
}

ServiceControl creates or updates Services.

func NewServiceControl

func NewServiceControl(client Client) ServiceControl

func (ServiceControl) Reconcile

Reconcile creates or updates services. Some services, like P2P, reserve public addresses of which should not change. Therefore, services are never deleted unless the CRD itself is deleted.

type StatusClient added in v0.10.0

type StatusClient struct {
	// contains filtered or unexported fields
}

func NewStatusClient added in v0.10.0

func NewStatusClient(c client.Client) *StatusClient

func (*StatusClient) SyncUpdate added in v0.10.0

func (client *StatusClient) SyncUpdate(ctx context.Context, key client.ObjectKey, update func(status *cosmosv1.FullNodeStatus)) error

SyncUpdate synchronizes updates to a CosmosFullNode's status subresource per client.ObjectKey. There are several controllers that update a fullnode's status to signal the fullnode controller to take action and update the cluster state.

This method minimizes accidentally overwriting status fields by several actors.

Server-side-apply, in theory, would be a solution. During testing, however, it resulted in many conflict errors and would require non-trivial migration to clear existing deployment's metadata.managedFields.

type StatusPatcher added in v0.10.0

type StatusPatcher interface {
	Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error
}

StatusPatcher patches the status subresource of a resource.

type StatusSyncer added in v0.10.0

type StatusSyncer interface {
	SyncUpdate(ctx context.Context, key client.ObjectKey, update func(status *cosmosv1.FullNodeStatus)) error
}

Jump to

Keyboard shortcuts

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