configentries

package
v0.0.0-...-20fb198 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MPL-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FinalizerName                = "finalizers.consul.hashicorp.com"
	ConsulAgentError             = "ConsulAgentError"
	ConsulPatchError             = "ConsulPatchError"
	ExternallyManagedConfigError = "ExternallyManagedConfigError"
	MigrationFailedError         = "MigrationFailedError"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigEntryController

type ConfigEntryController struct {
	// ConsulClientConfig is the config for the Consul API client.
	ConsulClientConfig *consul.Config

	// ConsulServerConnMgr is the watcher for the Consul server addresses.
	ConsulServerConnMgr consul.ServerConnectionManager

	// DatacenterName indicates the Consul Datacenter name the controller is
	// operating in. Adds this value as metadata on managed resources.
	DatacenterName string

	// EnableConsulNamespaces indicates that a user is running Consul Enterprise
	// with version 1.7+ which supports namespaces.
	EnableConsulNamespaces bool

	// ConsulDestinationNamespace is the name of the Consul namespace to create
	// all config entries in. If EnableNSMirroring is true this is ignored.
	ConsulDestinationNamespace string

	// EnableNSMirroring causes Consul namespaces to be created to match the
	// k8s namespace of any config entry custom resource. Config entries will
	// be created in the matching Consul namespace.
	EnableNSMirroring bool

	// NSMirroringPrefix is an optional prefix that can be added to the Consul
	// namespaces created while mirroring. For example, if it is set to "k8s-",
	// then the k8s `default` namespace will be mirrored in Consul's
	// `k8s-default` namespace.
	NSMirroringPrefix string

	// CrossNSACLPolicy is the name of the ACL policy to attach to
	// any created Consul namespaces to allow cross namespace service discovery.
	// Only necessary if ACLs are enabled.
	CrossNSACLPolicy string
}

ConfigEntryController is a generic controller that is used to reconcile all config entry types, e.g. ServiceDefaults, ServiceResolver, etc, since they share the same reconcile behaviour.

func (*ConfigEntryController) ReconcileEntry

func (r *ConfigEntryController) ReconcileEntry(ctx context.Context, crdCtrl Controller, req ctrl.Request, configEntry common.ConfigEntryResource) (ctrl.Result, error)

ReconcileEntry reconciles an update to a resource. CRD-specific controller's call this function because it handles reconciliation of config entries generically. CRD-specific controller should pass themselves in as updater since we need to call back into their own update methods to ensure they update their internal state.

type ControlPlaneRequestLimitController

type ControlPlaneRequestLimitController struct {
	client.Client
	FinalizerPatcher
	Log                   logr.Logger
	Scheme                *runtime.Scheme
	ConfigEntryController *ConfigEntryController
}

ControlPlaneRequestLimitController reconciles a ControlPlaneRequestLimit object.

func (*ControlPlaneRequestLimitController) Logger

func (*ControlPlaneRequestLimitController) Reconcile

func (*ControlPlaneRequestLimitController) SetupWithManager

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

func (*ControlPlaneRequestLimitController) UpdateStatus

type Controller

type Controller interface {
	// AddFinalizersPatch creates a patch with the original finalizers with new ones appended to the end.
	AddFinalizersPatch(obj client.Object, finalizers ...string) *FinalizerPatch
	// RemoveFinalizersPatch creates a patch to remove a set of finalizers, while preserving the order.
	RemoveFinalizersPatch(obj client.Object, finalizers ...string) *FinalizerPatch
	// Patch patches the object. This should only ever be used for updating the metadata of an object, and not object
	// spec or status. Updating the spec could have unintended consequences such as defaulting zero values.
	Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error
	// UpdateStatus updates the state of just the object's status.
	UpdateStatus(context.Context, client.Object, ...client.SubResourceUpdateOption) error
	// Get retrieves an obj for the given object key from the Kubernetes Cluster.
	// obj must be a struct pointer so that obj can be updated with the response
	// returned by the Server.
	Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error
	// Logger returns a logger with values added for the specific controller
	// and request name.
	Logger(types.NamespacedName) logr.Logger
}

Controller is implemented by CRD-specific configentries. It is used by ConfigEntryController to abstract CRD-specific configentries.

type ExportedServicesController

type ExportedServicesController struct {
	client.Client
	FinalizerPatcher
	Log                   logr.Logger
	Scheme                *runtime.Scheme
	ConfigEntryController *ConfigEntryController
}

ExportedServicesController reconciles a ExportedServices object.

func (*ExportedServicesController) Logger

func (*ExportedServicesController) Reconcile

func (*ExportedServicesController) SetupWithManager

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

func (*ExportedServicesController) UpdateStatus

type FinalizerPatch

type FinalizerPatch struct {
	NewFinalizers []string
}

func (*FinalizerPatch) Data

func (fp *FinalizerPatch) Data(obj client.Object) ([]byte, error)

Data implements client.Patch.

func (*FinalizerPatch) Type

func (fp *FinalizerPatch) Type() types.PatchType

Type implements client.Patch. Since this patch is used for a custom CRD, Kubernetes does not allow the more advanced StrategicMergePatch. Therefore, this patcher will replace the entire list of finalizers with the new list, rather than adding/removing individual entries.

This can result in a small race condition where we could overwrite recently modified finalizers (either modified by a user or another controller process). Before the addition of this finalizer patcher implementation, this race condition still existed, but applied to the entirety of the CRD because we used to update the entire CRD rather than just the finalizer, so this reduces the surface area of the race condition. Generally we should not expect users or other configentries to be touching the finalizers of consul-k8s managed CRDs.

type FinalizerPatcher

type FinalizerPatcher struct{}

func (*FinalizerPatcher) AddFinalizersPatch

func (f *FinalizerPatcher) AddFinalizersPatch(oldObj client.Object, addFinalizers ...string) *FinalizerPatch

func (*FinalizerPatcher) RemoveFinalizersPatch

func (f *FinalizerPatcher) RemoveFinalizersPatch(oldObj client.Object, removeFinalizers ...string) *FinalizerPatch

type IngressGatewayController

type IngressGatewayController struct {
	FinalizerPatcher
	client.Client
	Log                   logr.Logger
	Scheme                *runtime.Scheme
	ConfigEntryController *ConfigEntryController
}

IngressGatewayController is the controller for IngressGateway resources.

func (*IngressGatewayController) Logger

func (*IngressGatewayController) Reconcile

func (*IngressGatewayController) SetupWithManager

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

func (*IngressGatewayController) UpdateStatus

type JWTProviderController

type JWTProviderController struct {
	client.Client
	FinalizerPatcher
	Log                   logr.Logger
	Scheme                *runtime.Scheme
	ConfigEntryController *ConfigEntryController
}

JWTProviderController reconciles a JWTProvider object.

func (*JWTProviderController) Logger

func (*JWTProviderController) Reconcile

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

func (*JWTProviderController) SetupWithManager

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

func (*JWTProviderController) UpdateStatus

type MeshController

type MeshController struct {
	client.Client
	FinalizerPatcher
	Log                   logr.Logger
	Scheme                *runtime.Scheme
	ConfigEntryController *ConfigEntryController
}

MeshController reconciles a Mesh object.

func (*MeshController) Logger

func (r *MeshController) Logger(name types.NamespacedName) logr.Logger

func (*MeshController) Reconcile

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

func (*MeshController) SetupWithManager

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

func (*MeshController) UpdateStatus

func (r *MeshController) UpdateStatus(ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption) error

type ProxyDefaultsController

type ProxyDefaultsController struct {
	client.Client
	FinalizerPatcher
	Log                   logr.Logger
	Scheme                *runtime.Scheme
	ConfigEntryController *ConfigEntryController
}

ProxyDefaultsController reconciles a ProxyDefaults object.

func (*ProxyDefaultsController) Logger

func (*ProxyDefaultsController) Reconcile

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

func (*ProxyDefaultsController) SetupWithManager

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

func (*ProxyDefaultsController) UpdateStatus

type SamenessGroupController

type SamenessGroupController struct {
	client.Client
	FinalizerPatcher
	Log                   logr.Logger
	Scheme                *runtime.Scheme
	ConfigEntryController *ConfigEntryController
}

SamenessGroupController reconciles a SamenessGroups object.

func (*SamenessGroupController) Logger

func (*SamenessGroupController) Reconcile

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

func (*SamenessGroupController) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

func (*SamenessGroupController) UpdateStatus

type ServiceDefaultsController

type ServiceDefaultsController struct {
	client.Client
	FinalizerPatcher
	Log                   logr.Logger
	Scheme                *runtime.Scheme
	ConfigEntryController *ConfigEntryController
}

ServiceDefaultsController is the controller for ServiceDefaults resources.

func (*ServiceDefaultsController) Logger

func (*ServiceDefaultsController) Reconcile

func (*ServiceDefaultsController) SetupWithManager

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

func (*ServiceDefaultsController) UpdateStatus

type ServiceIntentionsController

type ServiceIntentionsController struct {
	client.Client
	FinalizerPatcher
	Log                   logr.Logger
	Scheme                *runtime.Scheme
	ConfigEntryController *ConfigEntryController
}

ServiceIntentionsController reconciles a ServiceIntentions object.

func (*ServiceIntentionsController) Logger

func (*ServiceIntentionsController) Reconcile

func (*ServiceIntentionsController) SetupWithManager

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

func (*ServiceIntentionsController) UpdateStatus

type ServiceResolverController

type ServiceResolverController struct {
	client.Client
	FinalizerPatcher
	Log                   logr.Logger
	Scheme                *runtime.Scheme
	ConfigEntryController *ConfigEntryController
}

ServiceResolverController is the controller for ServiceResolver resources.

func (*ServiceResolverController) Logger

func (*ServiceResolverController) Reconcile

func (*ServiceResolverController) SetupWithManager

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

func (*ServiceResolverController) UpdateStatus

type ServiceRouterController

type ServiceRouterController struct {
	client.Client
	FinalizerPatcher
	Log                   logr.Logger
	Scheme                *runtime.Scheme
	ConfigEntryController *ConfigEntryController
}

ServiceRouterController is the controller for ServiceRouter resources.

func (*ServiceRouterController) Logger

func (*ServiceRouterController) Reconcile

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

func (*ServiceRouterController) SetupWithManager

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

func (*ServiceRouterController) UpdateStatus

type ServiceSplitterController

type ServiceSplitterController struct {
	client.Client
	FinalizerPatcher
	Log                   logr.Logger
	Scheme                *runtime.Scheme
	ConfigEntryController *ConfigEntryController
}

ServiceSplitterReconciler reconciles a ServiceSplitter object.

func (*ServiceSplitterController) Logger

func (*ServiceSplitterController) Reconcile

func (*ServiceSplitterController) SetupWithManager

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

func (*ServiceSplitterController) UpdateStatus

type TerminatingGatewayController

type TerminatingGatewayController struct {
	client.Client
	FinalizerPatcher

	NamespacesEnabled bool

	Log                   logr.Logger
	Scheme                *runtime.Scheme
	ConfigEntryController *ConfigEntryController
}

TerminatingGatewayController is the controller for TerminatingGateway resources.

func (*TerminatingGatewayController) Logger

func (*TerminatingGatewayController) Reconcile

func (*TerminatingGatewayController) SetupWithManager

func (r *TerminatingGatewayController) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error

func (*TerminatingGatewayController) UpdateStatus

func (*TerminatingGatewayController) UpdateStatusFailedToSetACLs

func (r *TerminatingGatewayController) UpdateStatusFailedToSetACLs(ctx context.Context, termGW *consulv1alpha1.TerminatingGateway, err error)

Jump to

Keyboard shortcuts

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