inventory

package
v0.0.0-...-1f6a80c Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 27 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

Variables

View Source
var (

	//go:embed manifests/ovs-helper.yaml
	OVSHelperData []byte
)

Embed manifests for Kubernetes objects created by the controller.

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.

Types

type Component

type Component interface {
	Name() string
	Parse() error
	GenerateManifests(variables Variables, options ...GenerateManifestOption) ([]client.Object, error)
	// IsReady reports an object and a field in that object which is used to check the ready status of a Component.
	// Returns an error if the object 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
}

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 GenerateManifestOption

type GenerateManifestOption interface {
	Apply(*GenerateManifestOptions)
}

type GenerateManifestOptions

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

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 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 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 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 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 StubComponentWithObjs

func StubComponentWithObjs(name string, objs []*unstructured.Unstructured) StubComponent

func (StubComponent) GenerateManifests

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

func (StubComponent) IsReady

func (StubComponent) Name

func (s StubComponent) Name() string

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
	OVSHelper               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 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
	DPFProvisioningController DPFProvisioningVariables
	Networking                Networking
	DisableSystemComponents   map[string]bool
	ImagePullSecrets          []string
	Images                    map[string]string
	HelmCharts                map[string]string
	DPUDetectorCollectors     map[string]bool
}

Variables contains information required to generate manifests from the inventory.

func VariablesFromDPFOperatorConfig

func VariablesFromDPFOperatorConfig(defaults *release.Defaults, config *operatorv1.DPFOperatorConfig) Variables

Jump to

Keyboard shortcuts

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