Documentation ¶
Index ¶
- Constants
- Variables
- func CheckIfDeletionIsConfirmed(obj client.Object) error
- func ComputeGardenNamespace(seedName string) string
- func ComputeNginxIngressClassForSeed(seed *gardencorev1beta1.Seed, kubernetesVersion *string) (string, error)
- func ComputeSeedName(seedNamespaceName string) string
- func ComputeShootProjectSecretName(shootName, suffix string) string
- func ConfirmDeletion(ctx context.Context, w client.Writer, obj client.Object) error
- func EffectiveMaintenanceTimeWindow(timeWindow *timewindow.MaintenanceTimeWindow) *timewindow.MaintenanceTimeWindow
- func EffectiveShootMaintenanceTimeWindow(shoot *v1beta1.Shoot) *timewindow.MaintenanceTimeWindow
- func ExtractShootDetailsFromBackupEntryName(backupEntryName string) (shootTechnicalID string, shootUID types.UID)
- func GenerateBackupEntryName(shootTechnicalID string, shootUID types.UID) (string, error)
- func GenerateDNSProviderName(secretName, providerType string) string
- func GetAPIServerDomain(domain string) string
- func GetDomainInfoFromAnnotations(annotations map[string]string) (provider string, domain string, zone string, ...)
- func GetMandatoryExposureClassHandlerSNILabels(labels map[string]string, exposureClassName string) map[string]string
- func GetOwnerDomain(domain string) string
- func GetShootNameFromOwnerReferences(objectMeta metav1.Object) string
- func GetShootProjectSecretSuffixes() []string
- func GetWildcardCertificate(ctx context.Context, c client.Client) (*corev1.Secret, error)
- func InjectGenericKubeconfig(obj runtime.Object, genericKubeconfigName, accessSecretName string, ...) error
- func IsNowInEffectiveShootMaintenanceTimeWindow(shoot *v1beta1.Shoot) bool
- func IsObservedAtLatestGenerationAndSucceeded(shoot *v1beta1.Shoot) bool
- func IsSeedClientCert(x509cr *x509.CertificateRequest, usages []certificatesv1.KeyUsage) (bool, string)
- func IsShootFailed(shoot *v1beta1.Shoot) bool
- func IsShootProjectSecret(secretName string) (string, bool)
- func LastReconciliationDuringThisTimeWindow(shoot *v1beta1.Shoot) bool
- func NamespaceNameForControllerInstallation(controllerInstallation *gardencorev1beta1.ControllerInstallation) string
- func ProjectAndNamespaceFromReader(ctx context.Context, reader client.Reader, namespaceName string) (*gardencorev1beta1.Project, *corev1.Namespace, error)
- func ProjectForNamespaceFromReader(ctx context.Context, reader client.Reader, namespaceName string) (*gardencorev1beta1.Project, error)
- func RespectShootSyncPeriodOverwrite(respectSyncPeriodOverwrite bool, shoot *v1beta1.Shoot) bool
- func ShouldIgnoreShoot(respectSyncPeriodOverwrite bool, shoot *v1beta1.Shoot) bool
- func SyncPeriodOfShoot(respectSyncPeriodOverwrite bool, defaultMinSyncPeriod time.Duration, ...) time.Duration
- type ShootAccessSecret
- func (s *ShootAccessSecret) Reconcile(ctx context.Context, c client.Client) error
- func (s *ShootAccessSecret) WithKubeconfig(kubeconfigRaw *clientcmdv1.Config) *ShootAccessSecret
- func (s *ShootAccessSecret) WithNameOverride(name string) *ShootAccessSecret
- func (s *ShootAccessSecret) WithNamespaceOverride(namespace string) *ShootAccessSecret
- func (s *ShootAccessSecret) WithServiceAccountName(name string) *ShootAccessSecret
- func (s *ShootAccessSecret) WithTargetSecret(name, namespace string) *ShootAccessSecret
- func (s *ShootAccessSecret) WithTokenExpirationDuration(duration string) *ShootAccessSecret
Constants ¶
const ( // ConfirmationDeletion is an annotation on a Shoot and Project resources whose value must be set to "true" in order to // allow deleting the resource (if the annotation is not set any DELETE request will be denied). ConfirmationDeletion = "confirmation.gardener.cloud/deletion" // DeletionProtected is a label on CustomResourceDefinitions indicating that the deletion is protected, i.e. // it must be confirmed with the `confirmation.gardener.cloud/deletion=true` annotation before a `DELETE` call // is accepted. DeletionProtected = "gardener.cloud/deletion-protected" )
const ( // DNSProvider is the key for an annotation on a Kubernetes Secret object whose value must point to a valid // DNS provider. DNSProvider = "dns.gardener.cloud/provider" // DNSDomain is the key for an annotation on a Kubernetes Secret object whose value must point to a valid // domain name. DNSDomain = "dns.gardener.cloud/domain" // DNSDefaultDomainPriority is the priority of the default domain. In case of multiple default domains // the default domain with the highest priority is selected per default for new shoots. DNSDefaultDomainPriority = "dns.gardener.cloud/domain-default-priority" // DNSZone is the key for an annotation on a Kubernetes Secret object whose value must point to a valid // DNS hosted zone id. DNSZone = "dns.gardener.cloud/zone" // DNSIncludeZones is the key for an annotation on a Kubernetes Secret object whose value must point to a list // of zones that shall be included. DNSIncludeZones = "dns.gardener.cloud/include-zones" // DNSExcludeZones is the key for an annotation on a Kubernetes Secret object whose value must point to a list // of zones that shall be excluded. DNSExcludeZones = "dns.gardener.cloud/exclude-zones" // APIServerFQDNPrefix is the part of a FQDN which will be used to construct the domain name for the kube-apiserver of // a Shoot cluster. For example, when a Shoot specifies domain 'cluster.example.com', the apiserver domain would be // 'api.cluster.example.com'. APIServerFQDNPrefix = "api" // OwnerFQDNPrefix is the part of a FQDN which will be used to construct the domain name for the owner of // a Shoot cluster. For example, when a Shoot specifies domain 'cluster.example.com', the owner domain would be // 'owner.cluster.example.com'. OwnerFQDNPrefix = "owner" // IngressPrefix is the part of a FQDN which will be used to construct the domain name for an ingress controller of // a Shoot cluster. For example, when a Shoot specifies domain 'cluster.example.com', the ingress domain would be // '*.<IngressPrefix>.cluster.example.com'. IngressPrefix = "ingress" // InternalDomainKey is a key which must be present in an internal domain constructed for a Shoot cluster. If the // configured internal domain already contains it, it won't be added twice. If it does not contain it, it will be // appended. InternalDomainKey = "internal" )
const ( // ShootProjectSecretSuffixKubeconfig is a constant for a shoot project secret with suffix 'kubeconfig'. ShootProjectSecretSuffixKubeconfig = "kubeconfig" // ShootProjectSecretSuffixCACluster is a constant for a shoot project secret with suffix 'ca-cluster'. ShootProjectSecretSuffixCACluster = "ca-cluster" // ShootProjectSecretSuffixSSHKeypair is a constant for a shoot project secret with suffix 'ssh-keypair'. ShootProjectSecretSuffixSSHKeypair = v1beta1constants.SecretNameSSHKeyPair // ShootProjectSecretSuffixOldSSHKeypair is a constant for a shoot project secret with suffix 'ssh-keypair.old'. ShootProjectSecretSuffixOldSSHKeypair = v1beta1constants.SecretNameSSHKeyPair + ".old" // ShootProjectSecretSuffixMonitoring is a constant for a shoot project secret with suffix 'monitoring'. ShootProjectSecretSuffixMonitoring = "monitoring" )
const ( // SecretNamePrefixShootAccess is the prefix of all secrets containing credentials for accessing shoot clusters. SecretNamePrefixShootAccess = "shoot-access-" // VolumeMountPathGenericKubeconfig is a constant for the path to which the generic shoot kubeconfig will be mounted. VolumeMountPathGenericKubeconfig = "/var/run/secrets/gardener.cloud/shoot/generic-kubeconfig" // PathShootToken is a constant for the path at which the shoot token file is accessible. PathShootToken = VolumeMountPathGenericKubeconfig + "/" + resourcesv1alpha1.DataKeyToken // PathGenericKubeconfig is a constant for the path at which the kubeconfig file is accessible. PathGenericKubeconfig = VolumeMountPathGenericKubeconfig + "/" + secrets.DataKeyKubeconfig )
const ProjectNamespacePrefix = "garden-"
ProjectNamespacePrefix is the prefix of namespaces representing projects.
const (
// SeedNamespaceNamePrefix is the prefix used for seed namespaces.
SeedNamespaceNamePrefix = "seed-"
)
Variables ¶
var ( // NoControlPlaneSecretsReq is a label selector requirement to select non-control plane secrets. NoControlPlaneSecretsReq = utils.MustNewRequirement(constants.GardenRole, selection.NotIn, constants.ControlPlaneSecretRoles...) // UncontrolledSecretSelector is a selector for objects which are managed by operators/users and not created by // Gardener controllers. UncontrolledSecretSelector = client.MatchingLabelsSelector{Selector: labels.NewSelector().Add(NoControlPlaneSecretsReq)} )
var TimeNow = time.Now
TimeNow returns the current time. Exposed for testing.
Functions ¶
func CheckIfDeletionIsConfirmed ¶ added in v1.21.0
CheckIfDeletionIsConfirmed returns whether the deletion of an object is confirmed or not.
func ComputeGardenNamespace ¶
ComputeGardenNamespace returns the name of the namespace belonging to the given seed in the Garden cluster.
func ComputeNginxIngressClassForSeed ¶ added in v1.59.0
func ComputeNginxIngressClassForSeed(seed *gardencorev1beta1.Seed, kubernetesVersion *string) (string, error)
ComputeNginxIngressClassForSeed returns the IngressClass for the Nginx Ingress controller.
func ComputeSeedName ¶
ComputeSeedName computes the name of the seed out of the seed namespace in the Garden cluster.
func ComputeShootProjectSecretName ¶ added in v1.24.0
ComputeShootProjectSecretName computes the name of a shoot-related project secret.
func ConfirmDeletion ¶ added in v1.21.0
ConfirmDeletion adds Gardener's deletion confirmation and timestamp annotation to the given object and sends a PATCH request. It does not ignore `NotFound` errors while patching.
func EffectiveMaintenanceTimeWindow ¶ added in v1.21.0
func EffectiveMaintenanceTimeWindow(timeWindow *timewindow.MaintenanceTimeWindow) *timewindow.MaintenanceTimeWindow
EffectiveMaintenanceTimeWindow cuts a maintenance time window at the end with a guess of 15 minutes. It is subtracted from the end of a maintenance time window to use a best-effort kind of finishing the operation before the end. Generally, we can't make sure that the maintenance operation is done by the end of the time window anyway (considering large clusters with hundreds of nodes, a rolling update will take several hours).
func EffectiveShootMaintenanceTimeWindow ¶ added in v1.21.0
func EffectiveShootMaintenanceTimeWindow(shoot *v1beta1.Shoot) *timewindow.MaintenanceTimeWindow
EffectiveShootMaintenanceTimeWindow returns the effective MaintenanceTimeWindow of the given Shoot.
func ExtractShootDetailsFromBackupEntryName ¶ added in v1.24.0
func ExtractShootDetailsFromBackupEntryName(backupEntryName string) (shootTechnicalID string, shootUID types.UID)
ExtractShootDetailsFromBackupEntryName returns Shoot resource technicalID its UID from provided <backupEntryName>.
func GenerateBackupEntryName ¶ added in v1.24.0
GenerateBackupEntryName returns BackupEntry resource name created from provided <seedNamespace> and <shootUID>.
func GenerateDNSProviderName ¶ added in v1.21.0
GenerateDNSProviderName creates a name for the dns provider out of the passed `secretName` and `providerType`.
func GetAPIServerDomain ¶ added in v1.21.0
GetAPIServerDomain returns the fully qualified domain name for the api-server of the Shoot cluster. The end result is 'api.<domain>'.
func GetDomainInfoFromAnnotations ¶ added in v1.21.0
func GetDomainInfoFromAnnotations(annotations map[string]string) (provider string, domain string, zone string, includeZones, excludeZones []string, err error)
GetDomainInfoFromAnnotations returns the provider, domain, and zones that are specified in the given annotations.
func GetMandatoryExposureClassHandlerSNILabels ¶ added in v1.27.0
func GetMandatoryExposureClassHandlerSNILabels(labels map[string]string, exposureClassName string) map[string]string
GetMandatoryExposureClassHandlerSNILabels get the labels of an ExposureClass Handler plus its name and will add the mandatory SNI labels for ExposureClass handlers to it. Existing label keys will be overridden by the mandatory labels keys.
func GetOwnerDomain ¶ added in v1.32.0
GetOwnerDomain returns the fully qualified domain name for the owner of the Shoot cluster. The end result is 'owner.<domain>'.
func GetShootNameFromOwnerReferences ¶ added in v1.22.0
GetShootNameFromOwnerReferences attempts to get the name of the Shoot object which owns the passed in object. If it is not owned by a Shoot, an empty string is returned.
func GetShootProjectSecretSuffixes ¶ added in v1.24.0
func GetShootProjectSecretSuffixes() []string
GetShootProjectSecretSuffixes returns the list of shoot-related project secret suffixes.
func GetWildcardCertificate ¶ added in v1.59.0
GetWildcardCertificate gets the wildcard certificate for the seed's ingress domain. Nil is returned if no wildcard certificate is configured.
func InjectGenericKubeconfig ¶ added in v1.36.0
func InjectGenericKubeconfig(obj runtime.Object, genericKubeconfigName, accessSecretName string, containerNames ...string) error
InjectGenericKubeconfig injects the volumes and volume mounts for the generic shoot kubeconfig into the provided object. The access secret name must be the name of a secret containing a JWT token which should be used by the kubeconfig. If the object has multiple containers then the default is to inject it into all of them. If it should only be done for a selection of containers then their respective names must be provided.
func IsNowInEffectiveShootMaintenanceTimeWindow ¶ added in v1.21.0
IsNowInEffectiveShootMaintenanceTimeWindow checks if the current time is in the effective maintenance time window of the Shoot.
func IsObservedAtLatestGenerationAndSucceeded ¶ added in v1.21.0
IsObservedAtLatestGenerationAndSucceeded checks whether the Shoot's generation has changed or if the LastOperation status is Succeeded.
func IsSeedClientCert ¶ added in v1.23.0
func IsSeedClientCert(x509cr *x509.CertificateRequest, usages []certificatesv1.KeyUsage) (bool, string)
IsSeedClientCert returns true when the given CSR and usages match the requirements for a client certificate for a seed. If false is returned, a reason will be returned explaining which requirement was not met.
func IsShootFailed ¶ added in v1.21.0
IsShootFailed checks if a Shoot is failed.
func IsShootProjectSecret ¶ added in v1.24.0
IsShootProjectSecret checks if the given name matches the name of a shoot-related project secret. If no, it returns an empty string and <false>. Otherwise, it returns the shoot name and <true>.
func LastReconciliationDuringThisTimeWindow ¶ added in v1.21.0
LastReconciliationDuringThisTimeWindow returns true if <now> is contained in the given effective maintenance time window of the shoot and if the <lastReconciliation> did not happen longer than the longest possible duration of a maintenance time window.
func NamespaceNameForControllerInstallation ¶ added in v1.58.0
func NamespaceNameForControllerInstallation(controllerInstallation *gardencorev1beta1.ControllerInstallation) string
NamespaceNameForControllerInstallation returns the name of the namespace that will be used for the extension controller in the seed.
func ProjectAndNamespaceFromReader ¶ added in v1.21.0
func ProjectAndNamespaceFromReader(ctx context.Context, reader client.Reader, namespaceName string) (*gardencorev1beta1.Project, *corev1.Namespace, error)
ProjectAndNamespaceFromReader returns the Project responsible for a given <namespace>. It reads the namespace and fetches the project name label. Then it will read the project with the respective name.
func ProjectForNamespaceFromReader ¶ added in v1.21.0
func ProjectForNamespaceFromReader(ctx context.Context, reader client.Reader, namespaceName string) (*gardencorev1beta1.Project, error)
ProjectForNamespaceFromReader returns the Project responsible for a given <namespace>. It reads the namespace and fetches the project name label. Then it will read the project with the respective name.
func RespectShootSyncPeriodOverwrite ¶ added in v1.21.0
RespectShootSyncPeriodOverwrite checks whether to respect the sync period overwrite of a Shoot or not.
func ShouldIgnoreShoot ¶ added in v1.21.0
ShouldIgnoreShoot determines whether a Shoot should be ignored or not.
func SyncPeriodOfShoot ¶ added in v1.21.0
func SyncPeriodOfShoot(respectSyncPeriodOverwrite bool, defaultMinSyncPeriod time.Duration, shoot *v1beta1.Shoot) time.Duration
SyncPeriodOfShoot determines the sync period of the given shoot.
If no overwrite is allowed, the defaultMinSyncPeriod is returned. Otherwise, the overwrite is parsed. If an error occurs or it is smaller than the defaultMinSyncPeriod, the defaultMinSyncPeriod is returned. Otherwise, the overwrite is returned.
Types ¶
type ShootAccessSecret ¶ added in v1.36.0
type ShootAccessSecret struct { Secret *corev1.Secret ServiceAccountName string // contains filtered or unexported fields }
ShootAccessSecret contains settings for a shoot access secret consumed by a component communicating with a shoot API server.
func NewShootAccessSecret ¶ added in v1.36.0
func NewShootAccessSecret(name, namespace string) *ShootAccessSecret
NewShootAccessSecret returns a new ShootAccessSecret object and initializes it with an empty corev1.Secret object with for the given name and namespace. If not already done, the name will be prefixed with the SecretNamePrefixShootAccess. The ServiceAccountName field will be defaulted with the name.
func (*ShootAccessSecret) Reconcile ¶ added in v1.36.0
Reconcile creates or patches the given shoot access secret. Based on the struct configuration, it adds the required annotations for the token requestor controller of gardener-resource-manager.
func (*ShootAccessSecret) WithKubeconfig ¶ added in v1.36.0
func (s *ShootAccessSecret) WithKubeconfig(kubeconfigRaw *clientcmdv1.Config) *ShootAccessSecret
WithKubeconfig sets the kubeconfig field of the ShootAccessSecret.
func (*ShootAccessSecret) WithNameOverride ¶ added in v1.36.0
func (s *ShootAccessSecret) WithNameOverride(name string) *ShootAccessSecret
WithNameOverride sets the ObjectMeta.Name field of the *corev1.Secret inside the ShootAccessSecret.
func (*ShootAccessSecret) WithNamespaceOverride ¶ added in v1.36.0
func (s *ShootAccessSecret) WithNamespaceOverride(namespace string) *ShootAccessSecret
WithNamespaceOverride sets the ObjectMeta.Namespace field of the *corev1.Secret inside the ShootAccessSecret.
func (*ShootAccessSecret) WithServiceAccountName ¶ added in v1.36.0
func (s *ShootAccessSecret) WithServiceAccountName(name string) *ShootAccessSecret
WithServiceAccountName sets the ServiceAccountName field of the ShootAccessSecret.
func (*ShootAccessSecret) WithTargetSecret ¶ added in v1.38.0
func (s *ShootAccessSecret) WithTargetSecret(name, namespace string) *ShootAccessSecret
WithTargetSecret sets the kubeconfig field of the ShootAccessSecret.
func (*ShootAccessSecret) WithTokenExpirationDuration ¶ added in v1.36.0
func (s *ShootAccessSecret) WithTokenExpirationDuration(duration string) *ShootAccessSecret
WithTokenExpirationDuration sets the tokenExpirationDuration field of the ShootAccessSecret.