inventory

package
v0.1.0-latest-stable Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 44 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"
)
View Source
const DefaultFlannelPodCIDR = "10.244.0.0/14"

DefaultFlannelPodCIDR is the range DPU cluster Pods get their addresses from. Flannel allocates out of it and the DPU cluster control plane hands node podCIDRs out of it, so the two have to agree, which is why the cluster manager builds TenantControlPlanes with this same range.

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 DPUMonitoringSecretName

func DPUMonitoringSecretName(clusterName, clusterNamespace string) string

DPUMonitoringSecretName returns the name of the Secret holding the ServiceAccount token used to scrape the control plane of the given DPU cluster.

The Secret is created in the namespace of the DPUCluster rather than in the DPF operator namespace, because Prometheus resolves the credentials referenced by a ServiceMonitor in the namespace of that ServiceMonitor, and the cluster manager creates the control plane ServiceMonitors alongside the DPUCluster.

The cluster manager uses this to reference the Secret from the ServiceMonitor it creates, so this is the single source of truth for the name.

func GetCoreDNSWorkloadLabels

func GetCoreDNSWorkloadLabels(clusterName, clusterNamespace string) map[string]string

GetCoreDNSWorkloadLabels returns the labels identifying the host cluster CoreDNS objects serving a DPUCluster. The rendered objects carry a hashed name, so they are found by label instead.

func InventoryStringFromObjects

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

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

func IsDPUClusterServedByHostDNS

func IsDPUClusterServedByHostDNS(cluster *provisioningv1.DPUCluster) bool

IsDPUClusterServedByHostDNS reports whether a DPUCluster has its DNS served from the host cluster. That takes a Kamaji cluster, because the kamaji cluster manager is what points the DPU cluster DNS Service at the host, and a keepalived VIP, because that is the address DPU nodes reach the CoreDNS NodePort on. Any other DPUCluster keeps serving DNS itself.

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 CoreDNSVariables

type CoreDNSVariables struct {
	UpstreamNameservers string
}

CoreDNSVariables contains values passed to the CoreDNS chart.

type DPFProvisioningVariables

type DPFProvisioningVariables struct {
	BFBPersistentVolumeClaimName       *string
	DMSTimeout                         *int
	BFCFGTemplateConfig                *string
	CustomCASecretName                 *string
	ProvisioningIssuerCASecretName     *string
	InstallInterface                   *operatorv1.ProvisioningInstallInterface
	MaxDPUParallelInstallations        *int32
	MultiDPUOperationsSyncWaitTime     time.Duration
	MaxUnavailableDPUNodes             *int32
	Registry                           *operatorv1.RegistryConfiguration
	Replicas                           *int32
	OSInstallRetries                   int32
	OSInstallTimeout                   *metav1.Duration
	NodeJoinTokenTTL                   *metav1.Duration
	FirmwareUpdateTimeout              *metav1.Duration
	PreInstallAgentRegistrationTimeout *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 KataContainersVariables

type KataContainersVariables struct {
	Shims                    []string
	ContainerdConfigFileName string
	NodeSelector             map[string]string
}

KataContainersVariables holds variables specific to the Kata Containers component.

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 OpenTelemetryCollectorGenericVariables

type OpenTelemetryCollectorGenericVariables struct {
	Endpoint  string
	Transport string
	CACert    string
}

type OpenTelemetryCollectorVariables

type OpenTelemetryCollectorVariables struct {
	Metrics OpenTelemetryCollectorGenericVariables
	Logging OpenTelemetryCollectorGenericVariables
}

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
	RemoveOVSCNI                    Component
	Multus                          Component
	SRIOVDevicePlugin               Component
	NVIPAM                          Component
	Flannel                         Component
	SfcController                   Component
	KamajiClusterManager            Component
	StaticClusterManager            Component
	DPUDetector                     Component
	CNIInstaller                    Component
	NodeSRIOVDevicePluginController Component
	KubeStateMetrics                Component
	DPUMonitoring                   Component
	NodeProblemDetector             Component
	OpenTelemetryCollector          Component
	KataContainers                  Component
	SPIFFECSIDriver                 Component
	VaultKMS                        Component
	SpireAgentRBAC                  Component
	CoreDNS                         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
	DPULinkerCachePath                     *string
	DPUOptLibraryPath                      *string
	FlannelSkipCNIConfigInstallation       bool
	DisableDPUReadyTaints                  bool
	DisableHostNetworkReadyNoExecuteTaints bool
	FlannelPodCIDR                         string
	DPUClusters                            []*dpucluster.Config
	DPFProvisioningController              DPFProvisioningVariables
	SFCController                          SFCControllerVariables
	NodeSRIOVDevicePluginController        NodeSRIOVDevicePluginControllerVariables
	OpenTelemetryCollector                 OpenTelemetryCollectorVariables
	CoreDNS                                CoreDNSVariables
	Networking                             Networking
	KataContainers                         KataContainersVariables
	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
	VaultKMS                               *operatorv1.VaultKMSConfiguration
	SpiffeEnabled                          bool
}

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