controllers

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 35 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertificateRequestPatch added in v0.4.0

type CertificateRequestPatch interface {
	CertificateRequestPatch() *cmapi.CertificateRequestStatus
}

type CertificateRequestPredicate

type CertificateRequestPredicate struct {
	predicate.Funcs
}

This predicate is used to indicate when a CertificateRequest event should trigger a reconciliation of itself.

In these cases we want to trigger: - an annotation changed/ was added or removed - a status condition was added or removed - a status condition that does not have type == Ready was changed (aka. other Status value)

func (CertificateRequestPredicate) Update

type CertificateRequestReconciler

type CertificateRequestReconciler struct {
	RequestController

	// SetCAOnCertificateRequest is used to enable setting the CA status field on
	// the CertificateRequest resource. This is disabled by default.
	// Deprecated: this option is for backwards compatibility only. The use of
	// ca.crt is discouraged. Instead, the CA certificate should be provided
	// separately using a tool such as trust-manager.
	SetCAOnCertificateRequest bool
}

CertificateRequestReconciler reconciles a CertificateRequest object

func (*CertificateRequestReconciler) Init added in v0.4.0

func (*CertificateRequestReconciler) SetupWithManager

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

type CertificateSigningRequestPatch added in v0.4.0

type CertificateSigningRequestPatch interface {
	CertificateSigningRequestPatch() *certificatesv1.CertificateSigningRequestStatus
}

type CertificateSigningRequestPredicate

type CertificateSigningRequestPredicate struct {
	predicate.Funcs
}

This predicate is used to indicate when a CertificateSigningRequest event should trigger a reconciliation of itself.

In these cases we want to trigger: - an annotation changed/ was added or removed - a status condition was added or removed - a status condition was changed

func (CertificateSigningRequestPredicate) Update

type CertificateSigningRequestReconciler

type CertificateSigningRequestReconciler struct {
	RequestController
}

CertificateSigningRequestReconciler reconciles a CertificateSigningRequest object

func (*CertificateSigningRequestReconciler) Init added in v0.4.0

func (*CertificateSigningRequestReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type CombinedController

type CombinedController struct {
	IssuerTypes        []v1alpha1.Issuer
	ClusterIssuerTypes []v1alpha1.Issuer

	FieldOwner string

	MaxRetryDuration time.Duration

	// Check connects to a CA and checks if it is available
	signer.Check
	// Sign connects to a CA and returns a signed certificate for the supplied CertificateRequest.
	signer.Sign

	// IgnoreCertificateRequest is an optional function that can prevent the CertificateRequest
	// and Kubernetes CSR controllers from reconciling a CertificateRequest resource.
	signer.IgnoreCertificateRequest
	// IgnoreIssuer is an optional function that can prevent the issuer controllers from
	// reconciling an issuer resource.
	signer.IgnoreIssuer

	// EventRecorder is used for creating Kubernetes events on resources.
	EventRecorder record.EventRecorder

	// Clock is used to mock condition transition times in tests.
	Clock clock.PassiveClock

	// SetCAOnCertificateRequest is used to enable setting the CA status field on
	// the CertificateRequest resource. This is disabled by default.
	// Deprecated: this option is for backwards compatibility only. The use of
	// ca.crt is discouraged. Instead, the CA certificate should be provided
	// separately using a tool such as trust-manager.
	SetCAOnCertificateRequest bool

	// DisableCertificateRequestController is used to disable the CertificateRequest
	// controller. This controller is enabled by default.
	// You should only disable this controller if you eg. don't want to rely on the cert-manager
	// CRDs to be installed.
	// Note: in the future, we might remove this option and always enable the CertificateRequest
	// controller.
	DisableCertificateRequestController bool

	// DisableKubernetesCSRController is used to disable the Kubernetes CSR controller.
	// This controller is enabled by default.
	// You should only disable this controller if you really don't want to support signing
	// Kubernetes CSRs.
	// Note: in the future, we might remove this option and always enable the Kubernetes CSR
	// controller.
	DisableKubernetesCSRController bool

	// PreSetupWithManager is an optional function that can be used to perform
	// additional setup before the controller is built and registered with the
	// manager.
	PreSetupWithManager func(context.Context, schema.GroupVersionKind, ctrl.Manager, *builder.Builder) error

	// PostSetupWithManager is an optional function that can be used to perform
	// additional setup after the controller is built and registered with the
	// manager.
	PostSetupWithManager func(context.Context, schema.GroupVersionKind, ctrl.Manager, controller.Controller) error
}

func (*CombinedController) SetupWithManager

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

type IssuerPredicate

type IssuerPredicate struct {
	predicate.Funcs
}

Predicate for Issuer events that should trigger the Issuer reconciler

In these cases we want to trigger: - an annotation changed/ was added or removed - the generation changed - the Ready condition was added/ removed

func (IssuerPredicate) Update

Update implements default UpdateEvent filter for validating generation change.

type IssuerReconciler

type IssuerReconciler struct {
	ForObject v1alpha1.Issuer

	FieldOwner  string
	EventSource kubeutil.EventSource

	// Client is a controller-runtime client used to get and set K8S API resources
	client.Client
	// Check connects to a CA and checks if it is available
	signer.Check
	// IgnoreIssuer is an optional function that can prevent the issuer controllers from
	// reconciling an issuer resource.
	signer.IgnoreIssuer

	// EventRecorder is used for creating Kubernetes events on resources.
	EventRecorder record.EventRecorder

	// Clock is used to mock condition transition times in tests.
	Clock clock.PassiveClock

	// PreSetupWithManager is an optional function that can be used to perform
	// additional setup before the controller is built and registered with the
	// manager.
	PreSetupWithManager func(context.Context, schema.GroupVersionKind, ctrl.Manager, *builder.Builder) error

	// PostSetupWithManager is an optional function that can be used to perform
	// additional setup after the controller is built and registered with the
	// manager.
	PostSetupWithManager func(context.Context, schema.GroupVersionKind, ctrl.Manager, controller.Controller) error
}

IssuerReconciler reconciles a TestIssuer object

func (*IssuerReconciler) Reconcile

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

func (*IssuerReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type IssuerType added in v0.4.0

type IssuerType struct {
	Type         v1alpha1.Issuer
	IsNamespaced bool
}

type LinkedIssuerPredicate

type LinkedIssuerPredicate struct {
	predicate.Funcs
}

Predicate for Issuer events that should trigger the CertificateRequest reconciler

In these cases we want to trigger: - the Ready condition was added/ removed - the Ready condition's Status property changed - the Ready condition's observed generation changed

func (LinkedIssuerPredicate) Update

Update implements default UpdateEvent filter for validating resource version change.

type MatchIssuerType added in v0.4.0

type MatchIssuerType func(client.Object) (v1alpha1.Issuer, client.ObjectKey, error)

type RequestController added in v0.4.0

type RequestController struct {
	IssuerTypes        []v1alpha1.Issuer
	ClusterIssuerTypes []v1alpha1.Issuer

	FieldOwner       string
	MaxRetryDuration time.Duration
	EventSource      kubeutil.EventSource

	// Client is a controller-runtime client used to get and set K8S API resources
	client.Client
	// Sign connects to a CA and returns a signed certificate for the supplied Request.
	signer.Sign
	// IgnoreCertificateRequest is an optional function that can prevent the Request
	// and Kubernetes CSR controllers from reconciling a Request resource.
	signer.IgnoreCertificateRequest

	// EventRecorder is used for creating Kubernetes events on resources.
	EventRecorder record.EventRecorder

	// Clock is used to mock condition transition times in tests.
	Clock clock.PassiveClock

	// PreSetupWithManager is an optional function that can be used to perform
	// additional setup before the controller is built and registered with the
	// manager.
	PreSetupWithManager func(context.Context, schema.GroupVersionKind, ctrl.Manager, *builder.Builder) error

	// PostSetupWithManager is an optional function that can be used to perform
	// additional setup after the controller is built and registered with the
	// manager.
	PostSetupWithManager func(context.Context, schema.GroupVersionKind, ctrl.Manager, controller.Controller) error
	// contains filtered or unexported fields
}

RequestController reconciles a "request" object. A request object implementation can be provided using the requestObjectHelperCreator function. This function is responsible for creating a RequestObjectHelper that is used to interact with the request object. Currently, we support cert-manager CertificateRequests and Kubernetes CertificateSigningRequests.

func (*RequestController) AllIssuerTypes added in v0.4.0

func (r *RequestController) AllIssuerTypes() []IssuerType

func (*RequestController) Init added in v0.4.0

func (r *RequestController) Init(
	requestType client.Object,
	requestPredicate predicate.Predicate,
	matchIssuerType MatchIssuerType,
	requestObjectHelperCreator RequestObjectHelperCreator,
) *RequestController

func (*RequestController) Reconcile added in v0.4.0

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

func (*RequestController) SetupWithManager added in v0.4.0

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

SetupWithManager sets up the controller with the Manager.

type RequestObjectHelper added in v0.4.0

type RequestObjectHelper interface {
	IsApproved() bool
	IsDenied() bool
	IsReady() bool
	IsFailed() bool

	RequestObject() signer.CertificateRequestObject

	NewPatch(
		clock clock.PassiveClock,
		fieldOwner string,
		eventRecorder record.EventRecorder,
	) RequestPatchHelper
}

type RequestObjectHelperCreator added in v0.4.0

type RequestObjectHelperCreator func(client.Object) RequestObjectHelper

type RequestPatch added in v0.4.0

type RequestPatch interface {
	Patch() (client.Object, client.Patch, error)
}

type RequestPatchHelper added in v0.4.0

type RequestPatchHelper interface {
	RequestPatch

	SetInitializing() (didInitialise bool)
	SetWaitingForIssuerExist(error)
	SetWaitingForIssuerReadyNoCondition()
	SetWaitingForIssuerReadyOutdated()
	SetWaitingForIssuerReadyNotReady(*cmapi.IssuerCondition)
	SetCustomCondition(
		conditionType string,
		conditionStatus metav1.ConditionStatus,
		conditionReason string, conditionMessage string,
	) (didCustomConditionTransition bool)
	SetPending(reason string)
	SetRetryableError(error)
	SetPermanentError(error)
	SetUnexpectedError(error)
	SetIssued(signer.PEMBundle)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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