Documentation
¶
Index ¶
- Constants
- Variables
- func HasApprovalDecision(csr *certificatesv1.CertificateSigningRequest) bool
- type CSRApprover
- type CSRApproverOptions
- type CSRApproverReconciler
- type CSRDecision
- type CSREvaluator
- type ControllerCertificateOptions
- type CredentialRequestAuthorizationFunc
- type KubeletClientCSRApprover
- type KubeletClientCSRApproverOptions
- type KubeletNodeAuthorizationFunc
- type RESTConfigProvider
- type RequestAuthorizationFunc
Constants ¶
const ( SystemNodesGroup = "system:nodes" SystemNodeUserPrefix = "system:node:" BootstrapUserPrefix = "system:bootstrap:" )
const ( // KubeletClientSignerName is the signer used for kubelet client certificates. KubeletClientSignerName = certificatesv1.KubeAPIServerClientKubeletSignerName // CredentialIDExtraKey is the user extra key the API server attaches to // requests authenticated with a bound ServiceAccount token (KEP-4193). For // ServiceAccount tokens its value is "JTI=<jti>". CredentialIDExtraKey = "authentication.kubernetes.io/credential-id" )
const (
DefaultControllerCertificateSignerName = "kubernetes.io/kube-apiserver-client"
)
Variables ¶
var ErrUnknownCredential = errors.New("unknown credential")
ErrUnknownCredential is returned, possibly wrapped, by a KubeletNodeAuthorizationFunc that has no record of the credential. The CSR is left undecided rather than denied, so an approver that does know the credential, or a later evaluation once the record is observed, decides it.
Functions ¶
func HasApprovalDecision ¶
func HasApprovalDecision(csr *certificatesv1.CertificateSigningRequest) bool
Types ¶
type CSRApprover ¶
type CSRApprover struct {
// contains filtered or unexported fields
}
CSRApprover validates daemon-controller CertificateSigningRequests and returns approval decisions. It enforces generic certificate shape and requester checks; callers provide resource-binding checks through callbacks.
func NewCSRApprover ¶
func NewCSRApprover(opts CSRApproverOptions) (*CSRApprover, error)
func (*CSRApprover) Evaluate ¶
func (a *CSRApprover) Evaluate(ctx context.Context, csr *certificatesv1.CertificateSigningRequest) (CSRDecision, error)
type CSRApproverOptions ¶
type CSRApproverOptions struct {
// SignerName is the certificates.k8s.io signerName this approver handles.
// Defaults to kubernetes.io/kube-apiserver-client when empty.
SignerName string
// DaemonGroup is the non-privileged group requested in the issued certificate
// alongside system:nodes. It is required and must not use reserved names.
DaemonGroup string
// BootstrapGroup is the bootstrap-token requester group allowed to request
// initial daemon-controller certificates. It is required and intentionally not
// derived from DaemonGroup so integrations can choose their own bootstrap group.
BootstrapGroup string
// MaxExpirationSeconds is the maximum allowed spec.expirationSeconds value.
// Defaults to 365 days when unset.
MaxExpirationSeconds int32
// AuthorizeBootstrap validates implementation-specific bootstrap-token to node
// binding after the generic CSR shape and requester group checks pass.
AuthorizeBootstrap RequestAuthorizationFunc
// CredentialBootstrapRequester is an optional exact requester identity allowed
// to bootstrap with a credential ID instead of a Kubernetes bootstrap token.
// AuthorizeCredentialBootstrap must also be set when this is set.
CredentialBootstrapRequester string
// AuthorizeCredentialBootstrap validates the credential ID to node binding
// after the exact requester identity and credential ID shape checks pass.
AuthorizeCredentialBootstrap CredentialRequestAuthorizationFunc
// AuthorizeRenewal validates implementation-specific existing-cert to node
// binding after the generic CSR shape and requester identity checks pass.
AuthorizeRenewal RequestAuthorizationFunc
}
CSRApproverOptions configures daemon-controller CSR validation.
type CSRApproverReconciler ¶
type CSRApproverReconciler struct {
// Client reads CertificateSigningRequest objects from the controller cache.
client.Client
// KubeClient updates the CSR approval subresource.
KubeClient kubernetes.Interface
// Approver evaluates CSR requests.
Approver CSREvaluator
// EventFilter optionally customizes which CSR events enqueue reconcile work.
// When nil, create, update, and generic events are processed and deletes are ignored.
EventFilter predicate.Predicate
}
CSRApproverReconciler watches CertificateSigningRequest objects and writes approval or denial conditions for requests evaluated by CSRApprover.
func NewCSRApproverReconciler ¶
func NewCSRApproverReconciler( c client.Client, kubeClient kubernetes.Interface, approver CSREvaluator, ) (*CSRApproverReconciler, error)
func (*CSRApproverReconciler) SetupWithManager ¶
func (r *CSRApproverReconciler) SetupWithManager(mgr ctrl.Manager) error
type CSRDecision ¶
type CSRDecision struct {
// Ignore is true when the CSR is for another signer and should not be touched.
Ignore bool
// AlreadyDecided is true when the CSR already has a terminal approval state or certificate.
AlreadyDecided bool
// Approve is true for approval decisions and false for denial decisions.
Approve bool
// Message is written to the CSR approval or denial condition.
Message string
}
CSRDecision describes the outcome of evaluating one CertificateSigningRequest.
func Approve ¶
func Approve(format string, args ...any) CSRDecision
func Deny ¶
func Deny(format string, args ...any) CSRDecision
type CSREvaluator ¶ added in v0.17.0
type CSREvaluator interface {
Evaluate(context.Context, *certificatesv1.CertificateSigningRequest) (CSRDecision, error)
}
CSREvaluator evaluates one CertificateSigningRequest and returns an approval decision. CSRApprover and KubeletClientCSRApprover implement it.
type ControllerCertificateOptions ¶
type ControllerCertificateOptions struct {
// Name identifies this certificate manager in logs.
Name string
// SignerName is the certificates.k8s.io signerName used for daemon-controller CSRs.
// Defaults to kubernetes.io/kube-apiserver-client when empty.
SignerName string
// DaemonGroup is the additional group requested alongside system:nodes.
// It is required and must not use reserved or privileged group names.
DaemonGroup string
// CredentialDir stores the daemon-controller certificate material.
// It is required.
CredentialDir string
// WaitTimeout is how long initial certificate issuance waits before failing.
// Defaults to 10 seconds when unset.
WaitTimeout time.Duration
// WaitPoll is the polling interval used while waiting for initial issuance.
// Defaults to 500 milliseconds when unset.
WaitPoll time.Duration
// ExpirationDuration is the requested lifetime for issued certificates.
// Defaults to 365 days when unset.
ExpirationDuration time.Duration
// ReloadPeriod is how often the REST config provider checks for rotation.
// Defaults to 10 seconds when unset.
ReloadPeriod time.Duration
}
ControllerCertificateOptions configures daemon-controller client certificate issuance, storage, and REST client rotation.
type CredentialRequestAuthorizationFunc ¶ added in v0.17.0
type CredentialRequestAuthorizationFunc func(context.Context, *certificatesv1.CertificateSigningRequest, string, string) (bool, error)
CredentialRequestAuthorizationFunc authorizes a parsed daemon-controller CSR request for the requested node name using an authenticated credential ID.
type KubeletClientCSRApprover ¶ added in v0.17.0
type KubeletClientCSRApprover struct {
// contains filtered or unexported fields
}
KubeletClientCSRApprover approves kubelet client CSRs submitted by a single requester identity, typically a ServiceAccount whose tokens are minted per Machine. Every handled CSR is either approved or denied, unless AuthorizeNode reports ErrUnknownCredential.
func NewKubeletClientCSRApprover ¶ added in v0.17.0
func NewKubeletClientCSRApprover(opts KubeletClientCSRApproverOptions) (*KubeletClientCSRApprover, error)
NewKubeletClientCSRApprover validates options and returns an approver.
func (*KubeletClientCSRApprover) Evaluate ¶ added in v0.17.0
func (a *KubeletClientCSRApprover) Evaluate(ctx context.Context, csr *certificatesv1.CertificateSigningRequest) (CSRDecision, error)
Evaluate returns the decision for csr.
type KubeletClientCSRApproverOptions ¶ added in v0.17.0
type KubeletClientCSRApproverOptions struct {
// Requester is the exact CSR spec.username this approver handles. CSRs
// from any other requester are ignored so other approvers keep working.
Requester string
// MaxExpirationSeconds is the maximum allowed spec.expirationSeconds value.
// Defaults to 365 days when unset.
MaxExpirationSeconds int32
// AuthorizeNode binds the requester credential to the requested node.
AuthorizeNode KubeletNodeAuthorizationFunc
}
KubeletClientCSRApproverOptions configures KubeletClientCSRApprover.
type KubeletNodeAuthorizationFunc ¶ added in v0.17.0
type KubeletNodeAuthorizationFunc func(ctx context.Context, csr *certificatesv1.CertificateSigningRequest, nodeName, credentialID string) (bool, string, error)
KubeletNodeAuthorizationFunc decides whether the credential identified by credentialID may obtain a kubelet client certificate for nodeName. A false result must carry a human-readable denial reason. An error wrapping ErrUnknownCredential leaves the CSR undecided.
type RESTConfigProvider ¶
type RESTConfigProvider struct {
// contains filtered or unexported fields
}
func NewRESTConfigProvider ¶
func NewRESTConfigProvider( ctx context.Context, base *rest.Config, nodeName string, opts ControllerCertificateOptions, ) (*RESTConfigProvider, error)
func (*RESTConfigProvider) RESTConfig ¶
func (p *RESTConfigProvider) RESTConfig() *rest.Config
func (*RESTConfigProvider) Run ¶
func (p *RESTConfigProvider) Run(ctx context.Context)
type RequestAuthorizationFunc ¶
type RequestAuthorizationFunc func(context.Context, *certificatesv1.CertificateSigningRequest, string) (bool, error)
RequestAuthorizationFunc authorizes a parsed daemon-controller CSR request for the requested node name. Callers provide implementation-specific binding checks, such as bootstrap token to Machine/Node validation.