common

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 24 Imported by: 8

Documentation

Index

Constants

View Source
const (
	ResourceNamePrefixEnv   = "RESOURCE_NAME_PREFIX"
	ImagePullSecretEnv      = "IMAGE_PULL_SECRET"
	NSMRegistryServiceEnv   = "NSM_REGISTRY_SERVICE"
	LogLevelEnv             = "LOG_LEVEL"
	NspServiceAccountEnv    = "NSP_SERVICE_ACCOUNT"
	FeServiceAccountEnv     = "FE_SERVICE_ACCOUNT"
	GRPCHealthRPCTimeoutEnv = "GRPC_PROBE_RPC_TIMEOUT" // RPC timeout of grpc_health_probes run from code
	ConduitMTU              = "CONDUIT_MTU"            // Control default Conduit MTU

	Registry        = "registry.nordix.org"
	Organization    = "cloud-native/meridio"
	OrganizationNsm = "cloud-native/nsm"
	Tag             = "latest"

	BusyboxImage = "busybox"
	BusyboxTag   = "1.29"

	SubnetPoolIpv4          = "172.16.0.0/16"
	SubnetPoolIpv6          = "fd00::/48"
	ConduitPrefixLengthIpv4 = "20"
	ConduitPrefixLengthIpv6 = "56"
	NodePrefixLengthIpv4    = "24"
	NodePrefixLengthIpv6    = "64"

	NspPort        = 7778
	NspTargetPort  = 7778
	IpamPort       = 7777
	IpamTargetPort = 7777
	VlanNsePort    = 5003

	IpamSvcName             = "ipam-service"
	NspSvcName              = "nsp-service"
	PodDisruptionBudgetName = "pdb"
	LBName                  = "stateless-lb-frontend"
	ProxyName               = "proxy"
	IpamName                = "ipam"
	NseName                 = "nse-vlan"
	NspName                 = "nsp"
	NspServiceAccountName   = "meridio-sa"
	CMName                  = "meridio-configuration"

	NetworkServiceName = "external-vlan"

	ResourceRequirementKey          = "resource-template"
	ResourceRequirementTemplatePath = "template/resource"
)
View Source
const (
	NetworkAttachmentAnnot = "k8s.v1.cni.cncf.io/networks"
)

Variables

View Source
var (
	LivenessTimer = probeTimer{
					// contains filtered or unexported fields
	}

	ReadinessTimer = probeTimer{
					// contains filtered or unexported fields
	}

	StartUpTimer = probeTimer{
					// contains filtered or unexported fields
	}
)

Functions

func CompileEnvironmentVariables

func CompileEnvironmentVariables(allEnv []corev1.EnvVar, operatorEnv []corev1.EnvVar) []corev1.EnvVar

func ConfigMapName

func ConfigMapName(trench *meridiov1.Trench) string

func FEServiceAccountName

func FEServiceAccountName() string

func GetConduitMTU added in v1.0.12

func GetConduitMTU() string

func GetContainerResourceRequirements

func GetContainerResourceRequirements(containerName, templateName string) (*corev1.ResourceRequirements, error)

GetContainerResourceRequirements - Reads and searches template resource requirements for container. (A template resource requirement with param 'templateName' must exist for a match)

func GetDaemonsetModel

func GetDaemonsetModel(f string) (*appsv1.DaemonSet, error)

func GetDeploymentModel

func GetDeploymentModel(f string) (*appsv1.Deployment, error)

func GetGRPCProbeRPCTimeout added in v1.0.6

func GetGRPCProbeRPCTimeout() string

func GetIPFamily

func GetIPFamily(cr *meridiov1.Trench) string

func GetImagePullSecrets

func GetImagePullSecrets() []corev1.LocalObjectReference

func GetLoadBalancerSysCtl

func GetLoadBalancerSysCtl(cr *meridiov1.Trench) string

func GetLogLevel

func GetLogLevel() string

func GetNSMRegistryService

func GetNSMRegistryService() string

func GetPodDisruptionBudgetModel

func GetPodDisruptionBudgetModel(f string) (*policyv1.PodDisruptionBudget, error)

func GetPodDisruptionBudgetVersion

func GetPodDisruptionBudgetVersion(client client.Client) (string, error)

func GetPrefixedName

func GetPrefixedName(resourceName string) string

func GetProbe

func GetProbe(timer probeTimer, command []string) *corev1.Probe

func GetProbeCommand

func GetProbeCommand(spiffe bool, addr, svc string) []string

func GetProxySysCtl

func GetProxySysCtl(cr *meridiov1.Trench) string

func GetResourceRequirementAnnotation

func GetResourceRequirementAnnotation(from *metav1.ObjectMeta) (string, bool)

GetResourceRequirementAnnotation - Gets ResourceRequirementKey annotation based on param 'from'

func GetRoleBindingModel

func GetRoleBindingModel(f string) (*rbacv1.RoleBinding, error)

func GetRoleModel

func GetRoleModel(f string) (*rbacv1.Role, error)

func GetServiceAccountModel

func GetServiceAccountModel(f string) (*corev1.ServiceAccount, error)

func GetServiceModel

func GetServiceModel(f string) (*corev1.Service, error)

func GetStatefulSetModel

func GetStatefulSetModel(f string) (*appsv1.StatefulSet, error)

func GetSuffixedName

func GetSuffixedName(resourceName, suffix string) string

func GetTrenchBySelector

func GetTrenchBySelector(e *Executor, selector client.ObjectKey) (*meridiov1.Trench, error)

func IPAMServiceName

func IPAMServiceName(trench *meridiov1.Trench) string

func IPAMServiceWithPort

func IPAMServiceWithPort(cr *meridiov1.Trench) string

func IPAMStatefulSetName

func IPAMStatefulSetName(trench *meridiov1.Trench) string

func LbFeDeploymentName

func LbFeDeploymentName(attractor *meridiov1.Attractor) string

func LoadBalancerNsName

func LoadBalancerNsName(conduit, trench, namespace string) string

func MakeNetworkAttachmentSpecMap added in v1.0.0

func MakeNetworkAttachmentSpecMap(list []*NetworkAttachmentSelector) map[NetworkAttachmentSelector]*NetworkAttachmentSelector

MakeNetworkAttachmentSpecMap - Creates a map from list of NetworkAttachmentSelectors.

func NSEDeploymentName

func NSEDeploymentName(attractor *meridiov1.Attractor) string

func NSPServiceAccountName

func NSPServiceAccountName() string

func NSPServiceName

func NSPServiceName(trench *meridiov1.Trench) string

func NSPServiceWithPort

func NSPServiceWithPort(cr *meridiov1.Trench) string

func NSPStatefulSetName

func NSPStatefulSetName(trench *meridiov1.Trench) string

func NsName

func NsName(meta metav1.ObjectMeta) string

func PDBName

func PDBName(attractir *meridiov1.Attractor) string

func ProxyDeploymentName

func ProxyDeploymentName(conduit *meridiov1.Conduit) string

func ProxyNtwkSvcNsName

func ProxyNtwkSvcNsName(cr *meridiov1.Conduit) string

func SetContainerResourceRequirements

func SetContainerResourceRequirements(from *metav1.ObjectMeta, container *corev1.Container) error

SetContainerResourceRequirements - Finds and sets resource requirements for container.

func SetResourceRequirementAnnotation

func SetResourceRequirementAnnotation(from *metav1.ObjectMeta, into *metav1.ObjectMeta)

SetResourceRequirementAnnotation - Sets ResourceRequirementKey annotation based on param 'from'.

func VlanNtwkSvcName

func VlanNtwkSvcName(attractorCr *meridiov1.Attractor, trenchCr *meridiov1.Trench) string

Types

type Action

type Action interface {
	Run(e *Executor) (string, string, error)
}

func AppendActions

func AppendActions(actions ...Action) []Action

type Executions

type Executions interface {
	RunAll(actions []Action) error
	// contains filtered or unexported methods
}

type Executor

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

func NewExecutor

func NewExecutor(s *runtime.Scheme, c client.Client, ct context.Context, cr client.Object, l logr.Logger) *Executor

func (*Executor) AddCreateAction

func (e *Executor) AddCreateAction(obj client.Object)

func (*Executor) AddUpdateAction

func (e *Executor) AddUpdateAction(obj client.Object)

func (*Executor) AddUpdateStatusAction

func (e *Executor) AddUpdateStatusAction(obj client.Object)

func (*Executor) GetObject

func (e *Executor) GetObject(selector client.ObjectKey, obj client.Object) error

func (*Executor) GetOwner

func (e *Executor) GetOwner() client.Object

func (*Executor) ListObject

func (e *Executor) ListObject(obj client.ObjectList, opts ...client.ListOption) error

func (*Executor) LogError

func (e *Executor) LogError(err error, msg string)

func (*Executor) LogInfo

func (e *Executor) LogInfo(msg string)

func (*Executor) RunActions

func (e *Executor) RunActions() error

func (*Executor) SetControllerReference

func (e *Executor) SetControllerReference(obj client.Object) error

func (*Executor) SetOwner

func (e *Executor) SetOwner(cr client.Object)

Set the owner of created objects

func (*Executor) SetOwnerReference

func (e *Executor) SetOwnerReference(obj client.Object, owners ...client.Object) error

Append/update owner reference. Used when setting owner reference for custom resource

type NamedResourceRequirements

type NamedResourceRequirements struct {
	Name      string                      `json:"name" protobuf:"bytes,1,opt,name=name"`
	Resources corev1.ResourceRequirements `json:"resources,omitempty" protobuf:"bytes,2,opt,name=resources"`
}

type NetworkAttachmentSelector added in v1.0.0

type NetworkAttachmentSelector struct {
	Name             string `json:"name,omitempty"`
	Namespace        string `json:"namespace,omitempty"`
	InterfaceRequest string `json:"interface,omitempty"`
}

NetworkAttachmentSelector - Represents a selector for a json formattad Network Attachment Annotation. (Not using meridiov1alpha1 NetworkAttachmentSpec to keep compatibility even if the meridio API gets extended/changed in the future.)

If required, can be replaced with e.g. 3rd party NetworkSelectionElement: https://github.com/k8snetworkplumbingwg/network-attachment-definition-client/blob/master/pkg/apis/k8s.cni.cncf.io/v1/types.go#L135

func GetNetworkAnnotation added in v1.0.0

func GetNetworkAnnotation(networks, defaultNamespace string) ([]*NetworkAttachmentSelector, error)

GetNetworkAnnotation - Parses k8s.v1.cni.cncf.io/networks annotations, and fills in the namespace information if missing with defaultNamespace. Understands both json and <namespace>/<network name>@<ifname> format.

type ResourceRequirementTemplates

type ResourceRequirementTemplates struct {
	Templates []NamedResourceRequirements `json:"templates,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,1,rep,name=templates"`
}

ResourceRequirementTemplates - Describes the data layout of a resource requirement template file

Jump to

Keyboard shortcuts

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