controllers

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DerivedServiceAnnotation annotates a ServiceImport with derived Service name
	DerivedServiceAnnotation = "multicluster.k8s.aws/derived-service"

	// ServiceExportFinalizer finalizer to perform cloudmap resource cleanup on delete
	ServiceExportFinalizer = "multicluster.k8s.aws/service-export-finalizer"

	// LabelServiceImportName indicates the name of the multi-cluster service that an EndpointSlice belongs to.
	LabelServiceImportName = "multicluster.kubernetes.io/service-name"

	// LabelDerivedServiceOriginatingName indicates the name of the multi-cluster service that the derived service originated from.
	LabelDerivedServiceOriginatingName = "multicluster.kubernetes.io/service-name"

	// LabelEndpointSliceManagedBy indicates the name of the entity that manages the EndpointSlice.
	LabelEndpointSliceManagedBy = "endpointslice.kubernetes.io/managed-by"

	// LabelSourceCluster indicates the id of the cluster the object was created for
	LabelSourceCluster = "multicluster.kubernetes.io/source-cluster"

	// ValueEndpointSliceManagedBy indicates the name of the entity that manages the EndpointSlice.
	ValueEndpointSliceManagedBy = "aws-cloud-map-mcs-controller-for-k8s"
)

Variables

This section is empty.

Functions

func CreateDerivedServiceAnnotation

func CreateDerivedServiceAnnotation(namespace string, name string, clusterIds []string) string

CreateDerivedServiceAnnotation creates a JSON object containing a slice of maps of clusterIds and derived service names

func CreateDerivedServiceStruct

func CreateDerivedServiceStruct(svcImport *multiclusterv1alpha1.ServiceImport, importedSvcPorts []*model.Port, clusterId string) *v1.Service

CreateDerivedServiceStruct creates struct representation of a derived service

func CreateEndpointForSlice

func CreateEndpointForSlice(svc *v1.Service, endpoint *model.Endpoint) discovery.Endpoint

func CreateEndpointSliceStruct

func CreateEndpointSliceStruct(svc *v1.Service, svcImportName string, clusterId string) *discovery.EndpointSlice

func CreateServiceImportStruct

func CreateServiceImportStruct(svc *model.Service, clusterIds []string, servicePorts []*model.Port) *multiclusterv1alpha1.ServiceImport

CreateServiceImportStruct creates struct representation of a ServiceImport

func DerivedName

func DerivedName(namespace string, name string, clusterId string) string

DerivedName computes the "placeholder" name for an imported service

func EndpointPortToPort

func EndpointPortToPort(port discovery.EndpointPort) model.Port

EndpointPortToPort converts a k8s endpoint port to an internal model port

func ExtractEndpointPorts

func ExtractEndpointPorts(endpoints []*model.Endpoint) (endpointPorts []*model.Port)

ExtractEndpointPorts extracts all unique endpoint ports from a slice of endpoints

func ExtractServicePorts

func ExtractServicePorts(endpoints []*model.Endpoint) (servicePorts []*model.Port)

ExtractServicePorts extracts all unique service ports from a slice of endpoints

func ExtractServiceType

func ExtractServiceType(svc *v1.Service) model.ServiceType

ExtractServiceType finds the ServiceType of a given service as Headless/ClusterSetIP

func GetClusterIpsFromServices

func GetClusterIpsFromServices(services []*v1.Service) []string

GetClusterIpsFromServices returns list of ClusterIPs from services

func IPsEqualIgnoreOrder

func IPsEqualIgnoreOrder(a, b []string) (equal bool)

func PortToEndpointPort

func PortToEndpointPort(port model.Port) discovery.EndpointPort

PortToEndpointPort converts an internal model port to a k8s endpoint port

func PortToServiceImportPort

func PortToServiceImportPort(port model.Port) multiclusterv1alpha1.ServicePort

PortToServiceImportPort converts an internal model port to a service import port

func PortToServicePort

func PortToServicePort(port model.Port) v1.ServicePort

PortToServicePort converts an internal model port to a k8s service port

func PortsEqualIgnoreOrder

func PortsEqualIgnoreOrder(a, b []*model.Port) (equal bool)

func ServiceImportPortToPort

func ServiceImportPortToPort(svcPort multiclusterv1alpha1.ServicePort) model.Port

ServiceImportPortToPort converts a service import port to an internal model port

func ServicePortToPort

func ServicePortToPort(svcPort v1.ServicePort) model.Port

ServicePortToPort converts a k8s service port to internal model port

func ServiceTypetoServiceImportType

func ServiceTypetoServiceImportType(serviceType model.ServiceType) multiclusterv1alpha1.ServiceImportType

ServiceTypetoServiceImportType converts model service type to multicluster ServiceImport type

Types

type CloudMapReconciler

type CloudMapReconciler struct {
	Client       client.Client
	Cloudmap     cloudmap.ServiceDiscoveryClient
	Log          common.Logger
	ClusterUtils model.ClusterUtils
}

CloudMapReconciler reconciles state of Cloud Map services with local ServiceImport objects

func (*CloudMapReconciler) DeleteDerivedServiceAndEndpointSlices

func (r *CloudMapReconciler) DeleteDerivedServiceAndEndpointSlices(ctx context.Context, derivedService *v1.Service) error

func (*CloudMapReconciler) Reconcile

func (r *CloudMapReconciler) Reconcile(ctx context.Context) (err error)

Reconcile triggers a single reconciliation round

func (*CloudMapReconciler) Start

func (r *CloudMapReconciler) Start(ctx context.Context) error

Start implements manager.Runnable

type EndpointSliceChanges

type EndpointSliceChanges struct {
	// Create: List of EndpointSlices that need to be created
	Create []*discovery.EndpointSlice
	// Update: List of EndpointSlices that need to be updated
	Update []*discovery.EndpointSlice
	// Delete: List of EndpointSlices that need to be deleted
	Delete []*discovery.EndpointSlice
	// Unmodified: List of EndpointSlices that do not need to be changed
	Unmodified []*discovery.EndpointSlice
}

type EndpointSlicePlan

type EndpointSlicePlan struct {

	// Service to reconcile endpoints in
	Service *v1.Service

	// ServiceImportName name used to create new EndpointSlices
	ServiceImportName string

	// Current EndpontSlices
	Current []*discovery.EndpointSlice

	// Desired Endpoints
	Desired []*model.Endpoint

	// Cluster the EndpointSlice belongs to
	ClusterId string
	// contains filtered or unexported fields
}

func (*EndpointSlicePlan) CalculateChanges

func (p *EndpointSlicePlan) CalculateChanges() EndpointSliceChanges

CalculateChanges returns list of EndpointSlice Changes that need to applied

type ServiceExportReconciler

type ServiceExportReconciler struct {
	Client       client.Client
	Log          common.Logger
	Scheme       *runtime.Scheme
	CloudMap     cloudmap.ServiceDiscoveryClient
	ClusterUtils model.ClusterUtils
}

ServiceExportReconciler reconciles a ServiceExport object

func (*ServiceExportReconciler) Reconcile

func (r *ServiceExportReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*ServiceExportReconciler) SetupWithManager

func (r *ServiceExportReconciler) SetupWithManager(mgr ctrl.Manager) error

Jump to

Keyboard shortcuts

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