memberlistkeys

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package memberlistkeys handles the keys used to authenticate and encrypt the gossip traffic of the memberlist cluster formed by the antrea-agents. The keys are stored in a Secret, which is created by antrea-controller and read by every antrea-agent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatKeys

func FormatKeys(keys [][]byte) []byte

FormatKeys encodes keys so that they can be stored in the Secret. It is the inverse of ParseKeys.

func GenerateKey

func GenerateKey() ([]byte, error)

GenerateKey returns a new random key, suitable for use as a memberlist key.

func ParseKeys

func ParseKeys(data []byte) ([][]byte, error)

ParseKeys decodes the keys stored in the Secret. Keys are base64-encoded, one per line; empty lines are ignored, which makes it possible to format the Secret data with a trailing newline. The first key is the primary key.

An error is returned if no key could be found, or if any key is invalid: we deliberately do not skip invalid keys, as silently ignoring one could lead to a Node using a different primary key than the rest of the cluster, which would partition the memberlist cluster.

Types

type Provisioner

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

Provisioner makes sure that the Secret holding the memberlist keys exists and holds at least one valid key, generating a random one if needed. It watches the Secret and reconciles it again if it is deleted or if its keys are removed.

func NewProvisioner

func NewProvisioner(client clientset.Interface, namespace string) *Provisioner

func (*Provisioner) EnsureSecret

func (p *Provisioner) EnsureSecret(ctx context.Context) error

EnsureSecret makes sure that the Secret holding the memberlist keys exists and holds at least one valid key, generating a random one if needed.

An existing key is never modified: this makes it possible to provision the Secret ahead of the Antrea installation, and guarantees that a key chosen by the user - or the key which the cluster is already using - is preserved across restarts and upgrades. A key is only written when the Secret does not exist yet, or when it does not hold any key at all, and the keys which were last observed in the Secret are restored when we still have them, so that deleting the Secret does not rekey the cluster. If the Secret holds data which cannot be parsed, an error is returned and the Secret is left untouched, so that a typo cannot silently rekey a working cluster.

func (*Provisioner) Run

func (p *Provisioner) Run(ctx context.Context)

Run provisions the memberlist key and keeps the Secret holding it in sync until ctx is done. Failing to provision the key is not fatal for antrea-controller: it only prevents the antrea-agents from securing their gossip traffic, so we keep retrying in the background and log the errors instead of terminating.

type SecretWatcher

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

SecretWatcher watches the Secret which holds the memberlist keys and delivers them to a single handler. antrea-controller creates the Secret if it does not exist yet, so on a freshly installed cluster the first delivery can be delayed until the Secret appears.

func NewSecretWatcher

func NewSecretWatcher(client clientset.Interface, namespace string) *SecretWatcher

func (*SecretWatcher) Watch

func (w *SecretWatcher) Watch(stopCh <-chan struct{}, onKeys func(keys [][]byte))

Watch registers onKeys and starts watching the Secret, until stopCh is closed. It does not block: onKeys is invoked from the watch goroutine with the current keys as soon as the Secret holds valid ones - which may be before Watch returns - and again after every change, always with at least one key. Watch must be called at most once.

Jump to

Keyboard shortcuts

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