inventory

package
v0.0.0-...-0697e84 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ApplySetToolingAnnotation is the key of the label that indicates which tool is used to manage this ApplySet.
	// Tooling should refuse to mutate ApplySets belonging to other tools.
	// The value must be in the format <toolname>/<semver>.
	// Example value: "kubectl/v1.27" or "helm/v3" or "kpt/v1.0.0"
	ApplySetToolingAnnotation = "applyset.kubernetes.io/tooling"

	// ApplySetToolingAnnotationValue signals that the DPF Operator controls the ApplySet.
	// TODO: consider having this version be dynamically populated.
	ApplySetToolingAnnotationValue = "dpf-operator/v0"

	// ApplySetParentIDLabel is the key of the label that makes object an ApplySet parent object.
	// Its value MUST use the format specified in v1ApplySetIDFormat below
	ApplySetParentIDLabel = "applyset.kubernetes.io/id"

	// ApplySetInventoryAnnotationKey is the key of the label which holds the inventory of the ApplySet in a
	// sorted list of Group Kind + Namespace Name.
	ApplySetInventoryAnnotationKey = "applyset.kubernetes.io/inventory"
)

Apply set implements the Kubernetes ApplySet spec to handle deletion of objects in the Kubernetes API. See https://github.com/kubernetes/enhancements/blob/master/keps/sig-cli/3659-kubectl-apply-prune/README.md kubectl's applyset file was used here as a reference implementation and some comments and code are directly copied from there. https://github.com/kubernetes/kubernetes/blob/ae945462fb2d12a4e38d074de8fe77267460624b/staging/src/k8s.io/kubectl/pkg/cmd/apply/applyset.go

View Source
const (
	// DPFProvisioningControllerName is the helm value for the Provisioning Controllers component name.
	DPFProvisioningControllerName = "dpf-provisioning-controller-manager"
)
View Source
const (
	// DPUServiceControllerName is the helm value for the DPUService Controllers component name.
	DPUServiceControllerName = "dpuservice-controller-manager"
)

Variables

This section is empty.

Functions

func ApplySetID

func ApplySetID(namespace string, component Component) string

ApplySetID is a unique ID for the ApplySet.

func ApplySetName

func ApplySetName(component Component) string

ApplySetName returns the constant name for an ApplySet given a component.

func InventoryStringFromObjects

func InventoryStringFromObjects(objs ...client.Object) string

InventoryStringFromObjects computes the applyset inventory annotation value from a slice of client.Object.

func ShouldSkipUpgradeCheck

func ShouldSkipUpgradeCheck(componentName operatorv1.ComponentName, upgradeFromVersion string) (bool, error)

ShouldSkipUpgradeCheck determines if a component's upgrade readiness check should be skipped based on whether the component existed in the version being upgraded from.

Types

type Component

type Component interface {
	// Name returns the name of the component.
	Name() operatorv1.ComponentName

	// Parse parses the component data into the relevant fields of the struct and performs some basic validations.
	// Returns an error if the data is invalid or if the component cannot be parsed.
	Parse() error

	// GenerateManifests generates Kubernetes manifests for the component.
	// The manifests are generated based on the provided variables.
	// Returns a slice of client.Object which can be applied to the cluster.
	// If the component is not ready for upgrade, it returns an error.
	GenerateManifests(ctx context.Context, variables Variables) ([]client.Object, error)

	// IsReadyForUpgrade reports an object and a field in that object which is used to check the ready status of a Component.
	// The version contains the version of the DPF Operator that is being upgraded from.
	// Returns an error if the object is not ready.
	IsReadyForUpgrade(ctx context.Context, c client.Client, config *operatorv1.DPFOperatorConfig) error

	// IsReady checks if the component is ready and its version is updated.
	// It checks the readiness of the component in the given namespace.
	// Returns an error if the component is not ready.
	IsReady(ctx context.Context, c client.Client, namespace string) error
}

Component describes the responsibilities of an item in the Inventory.

type DPFProvisioningVariables

type DPFProvisioningVariables struct {
	BFBPersistentVolumeClaimName   *string
	DMSTimeout                     *int
	BFCFGTemplateConfig            *string
	CustomCASecretName             *string
	InstallInterface               *operatorv1.ProvisioningInstallInterface
	MaxDPUParallelInstallations    *int32
	MultiDPUOperationsSyncWaitTime time.Duration
	MaxUnavailableDPUNodes         *int32
	Registry                       *operatorv1.RegistryConfiguration
	Replicas                       *int32
	OSInstallTimeout               *metav1.Duration
	NodeEffectRemovalTimeout       *metav1.Duration
	HostAgentDNSPolicy             *corev1.DNSPolicy
	DeploymentMode                 operatorv1.DeploymentMode
}

type Edits

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

Edits facilitates editing kubernetes objects

func NewEdits

func NewEdits() *Edits

NewEdits creates new edit.

func (*Edits) AddForAll

func (e *Edits) AddForAll(edits ...UnstructuredEdit) *Edits

AddForAll addds UnstructuredEdits that will be called on all objects during Apply call

func (*Edits) AddForKind

func (e *Edits) AddForKind(kind ObjectKind, edits ...UnstructuredEdit) *Edits

AddForKind adds UnstructuredEdits that will be called on all objects of the specified kind during Apply call

func (*Edits) AddForKindS

func (e *Edits) AddForKindS(kind ObjectKind, edits ...StructuredEdit) *Edits

AddForKindS addds StructuredEdits that will be called on objects with the specified type during Apply call objects are converted to concrete type before calling UnstructuredEdit

func (*Edits) Apply

func (e *Edits) Apply(objs []*unstructured.Unstructured) error

Apply applies in place Edits for objs, returns first error if occurred

type GroupKindNamespaceName

type GroupKindNamespaceName struct {
	Group     string
	Kind      string
	Namespace string
	Name      string
}

GroupKindNamespaceName contains information required to uniquely identify an object as part of an ApplySet.

func ParseGroupKindNamespaceName

func ParseGroupKindNamespaceName(s string) (GroupKindNamespaceName, error)

ParseGroupKindNamespaceName parses a string to a GroupKindNamespaceName.

func (GroupKindNamespaceName) String

func (g GroupKindNamespaceName) String() string

String is the format for a GroupKindNamespaceName in the value for ApplySetInventoryAnnotationKey.

type HelmChartSource

type HelmChartSource struct {
	Repo    string
	Chart   string
	Version string
}

func ParseHelmChartString

func ParseHelmChartString(repoChartVersion string) (*HelmChartSource, error)

type Networking

type Networking struct {
	ControlPlaneMTU int
	HighSpeedMTU    int
}

type NodeSRIOVDevicePluginControllerVariables

type NodeSRIOVDevicePluginControllerVariables struct {
	// DevicePluginImage is the container image for the SRIOV device plugin.
	DevicePluginImage string
	// DevicePluginInitImage is the container image for the init container.
	DevicePluginInitImage string
	// DefaultResourcePrefix is the default resource prefix for device plugin resources.
	DefaultResourcePrefix string
}

NodeSRIOVDevicePluginControllerVariables holds variables for the NodeSRIOVDevicePlugin controller.

type ObjectKind

type ObjectKind string

ObjectKind represents different Kind of Kubernetes Objects

const (
	NamespaceKind                      ObjectKind = "Namespace"
	CustomResourceDefinitionKind       ObjectKind = "CustomResourceDefinition"
	ClusterRoleKind                    ObjectKind = "ClusterRole"
	RoleBindingKind                    ObjectKind = "RoleBinding"
	ClusterRoleBindingKind             ObjectKind = "ClusterRoleBinding"
	MutatingWebhookConfigurationKind   ObjectKind = "MutatingWebhookConfiguration"
	ValidatingWebhookConfigurationKind ObjectKind = "ValidatingWebhookConfiguration"
	DeploymentKind                     ObjectKind = "Deployment"
	StatefulSetKind                    ObjectKind = "StatefulSet"
	DaemonSetKind                      ObjectKind = "DaemonSet"
	CertificateKind                    ObjectKind = "Certificate"
	IssuerKind                         ObjectKind = "Issuer"
	RoleKind                           ObjectKind = "Role"
	ServiceAccountKind                 ObjectKind = "ServiceAccount"
	ServiceKind                        ObjectKind = "Service"
	DPUServiceKind                     ObjectKind = "DPUService"
	DaemonsetKind                      ObjectKind = "DaemonSet"
)

func (ObjectKind) String

func (o ObjectKind) String() string

type OpenTelemetryCollectorVariables

type OpenTelemetryCollectorVariables struct {
	LoggingEndpoint string
}

type SFCControllerVariables

type SFCControllerVariables struct {
	SecureFlowDeletionTimeout time.Duration
}

type StructuredEdit

type StructuredEdit func(obj client.Object) error

StructuredEdit edits Structured object in place, returns error if occurred

func ArgsForDaemonSetContainerEdit

func ArgsForDaemonSetContainerEdit(containerName string, args []string) StructuredEdit

func EnvForDaemonSetContainerEdit

func EnvForDaemonSetContainerEdit(containerName string, envs []corev1.EnvVar) StructuredEdit

EnvForDaemonSetContainerEdit adds or overrides env vars for a specific container

func ImageForDaemonSetContainerEdit

func ImageForDaemonSetContainerEdit(containerName, imageName string) StructuredEdit

func ImageForDeploymentContainerEdit

func ImageForDeploymentContainerEdit(containerName, imageName string) StructuredEdit

func ImagePullSecretsEditForDaemonSetEdit

func ImagePullSecretsEditForDaemonSetEdit(pullSecrets ...string) StructuredEdit

ImagePullSecretsEditForDaemonSetEdit sets pullSecrets for DaemonSet object

func ImagePullSecretsEditForDeploymentEdit

func ImagePullSecretsEditForDeploymentEdit(pullSecrets ...string) StructuredEdit

ImagePullSecretsEditForDeploymentEdit sets pullSecrets for Deployment object

func NodeAffinityEdit

func NodeAffinityEdit(nodeAffinity *corev1.NodeAffinity) StructuredEdit

NodeAffinityEdit sets NodeAffinity for Deployment objs

func ReplicasEditForDeployment

func ReplicasEditForDeployment(replicas *int32) StructuredEdit

ReplicasEditForDeployment sets the number of replicas for a Deployment

func ResourcesEditForDaemonSet

func ResourcesEditForDaemonSet(containerName string, resources corev1.ResourceRequirements) StructuredEdit

ResourcesEditForDaemonSet sets resource requirements for a specific container in a DaemonSet

func ResourcesEditForDeployment

func ResourcesEditForDeployment(containerName string, resources corev1.ResourceRequirements) StructuredEdit

ResourcesEditForDeployment sets resource requirements for a specific container in a Deployment

func TolerationsEdit

func TolerationsEdit(tolerations []corev1.Toleration) StructuredEdit

TolerationsEdit sets Tolerations for Deployment objs

type StubComponent

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

StubComponent is a type for testing GenerateManifests and ApplySet behavior.

func (StubComponent) GenerateManifests

func (s StubComponent) GenerateManifests(_ context.Context, vars Variables) ([]client.Object, error)

func (StubComponent) IsReady

func (StubComponent) IsReadyForUpgrade

func (StubComponent) Name

func (StubComponent) Parse

func (s StubComponent) Parse() error

type SystemComponents

type SystemComponents struct {
	DPUService                      Component
	DPFProvisioning                 Component
	ServiceFunctionChainSet         Component
	Multus                          Component
	SRIOVDevicePlugin               Component
	NVIPAM                          Component
	OvsCni                          Component
	Flannel                         Component
	SfcController                   Component
	KamajiClusterManager            Component
	StaticClusterManager            Component
	DPUDetector                     Component
	CNIInstaller                    Component
	NodeSRIOVDevicePluginController Component
	KubeStateMetrics                Component
	NodeProblemDetector             Component
	OpenTelemetryCollector          Component
}

SystemComponents holds kubernetes object manifests to be deployed by the operator.

func New

func New() *SystemComponents

New returns a new SystemComponents inventory with data preloaded but parsing not completed.

func (*SystemComponents) AllComponents

func (s *SystemComponents) AllComponents() []Component

AllComponents returns all Components deployed by the DPF Operator.

func (*SystemComponents) EnabledComponents

func (s *SystemComponents) EnabledComponents(vars Variables) []Component

EnabledComponents returns the set of components which is not disabled.

func (*SystemComponents) ParseAll

func (s *SystemComponents) ParseAll() error

ParseAll creates Kubernetes objects for all manifests related to the DPFOperator.

func (*SystemComponents) SystemDPUServices

func (s *SystemComponents) SystemDPUServices() []Component

SystemDPUServices returns DPUService Components deployed by the DPF Operator.

type UnstructuredEdit

type UnstructuredEdit func(un *unstructured.Unstructured) error

UnstructuredEdit edits Unstructured in place, returns error if occurred

func DPUServiceNADMTUEdit

func DPUServiceNADMTUEdit(mtu int) UnstructuredEdit

DPUServiceNADMTUEdit sets the MTU for a given DPUServiceNAD

func LabelsEdit

func LabelsEdit(labelsToAdd map[string]string) UnstructuredEdit

LabelsEdit adds the passed labels to the passed object. Labels passed here overwrite any existing label.

func NamespaceEdit

func NamespaceEdit(namespace string) UnstructuredEdit

NamespaceEdit sets namespace for object

func OwnerReferenceEdit

func OwnerReferenceEdit(owner metav1.Object, scheme *runtime.Scheme) UnstructuredEdit

OwnerReferenceEdit adds the given owner to the ownerReference list of the passed object

type Variables

type Variables struct {
	Namespace                        string
	DPUCNIBinPath                    string
	DPUCNIConfPath                   string
	DPUOpenvSwitchRunPath            string
	DPUOpenvSwitchBinPath            string
	DPUOpenvSwitchSharedLibPath      string
	DPUOpenvSwitchSharedLib64Path    *string
	FlannelSkipCNIConfigInstallation bool
	DisableDPUReadyTaints            bool
	FlannelPodCIDR                   string
	DPUClusters                      []*dpucluster.Config
	DPFProvisioningController        DPFProvisioningVariables
	SFCController                    SFCControllerVariables
	NodeSRIOVDevicePluginController  NodeSRIOVDevicePluginControllerVariables
	OpenTelemetryCollector           OpenTelemetryCollectorVariables
	Networking                       Networking
	DisableSystemComponents          map[operatorv1.ComponentName]bool
	ImagePullSecrets                 []string
	Images                           map[string]string
	HelmCharts                       map[operatorv1.ComponentName]string
	KubernetesAPIServerVIP           *string
	KubernetesAPIServerPort          *int
	Resources                        map[string]corev1.ResourceRequirements
	Replicas                         map[operatorv1.ComponentName]*int32
	ArgoCDNamespace                  string
}

Variables contains information required to generate manifests from the inventory.

func VariablesFromDPFOperatorConfig

func VariablesFromDPFOperatorConfig(defaults *release.Defaults, config *operatorv1.DPFOperatorConfig, dpuClusters []*dpucluster.Config) Variables

Jump to

Keyboard shortcuts

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