Documentation
¶
Index ¶
- Constants
- func AddTypeInformationToObject(obj runtime.Object) error
- func CreateOrUpdateConfigMap(ctx context.Context, cmClient typedcorev1.ConfigMapInterface, ...) error
- func CreateOrUpdateEndpointSlice(ctx context.Context, c clientdiscoveryv1.EndpointSliceInterface, ...) error
- func CreateOrUpdateEndpoints(ctx context.Context, eclient typedcorev1.EndpointsInterface, ...) error
- func CreateOrUpdateSecret(ctx context.Context, secretClient typedcorev1.SecretInterface, ...) error
- func CreateOrUpdateService(ctx context.Context, sclient typedcorev1.ServiceInterface, svc *corev1.Service) (*corev1.Service, error)
- func CreateStatefulSetOrPatchLabels(ctx context.Context, ssetClient clientappsv1.StatefulSetInterface, ...) (*appsv1.StatefulSet, error)
- func EnsureCustomGoverningService(ctx context.Context, namespace string, serviceName string, ...) error
- func FinalizerAddPatch(finalizers []string, finalizerName string) ([]byte, error)
- func FinalizerDeletePatch(finalizers []string, finalizerName string) ([]byte, error)
- func ForceUpdateStatefulSet(ctx context.Context, ssetClient clientappsv1.StatefulSetInterface, ...) error
- func HasStatusCleanupFinalizer(obj metav1.Object) bool
- func IsAPIGroupVersionResourceSupported(discoveryCli discovery.DiscoveryInterface, groupVersion schema.GroupVersion, ...) (bool, error)
- func IsAllowed(ctx context.Context, ssarClient typedauthv1.SelfSubjectAccessReviewInterface, ...) (bool, []error, error)
- func LabelSelectionHasChanged(old, current map[string]string, selector *metav1.LabelSelector) (bool, error)
- func LoadSecretRef(ctx context.Context, logger *slog.Logger, client typedcorev1.SecretInterface, ...) ([]byte, error)
- func MergePatchContainers(base, patches []corev1.Container) ([]corev1.Container, error)
- func MustRegisterClientGoMetrics(registerer prometheus.Registerer)
- func NewClusterConfig(config ClusterConfig) (*rest.Config, error)
- func PodRunningAndReady(pod corev1.Pod) (bool, error)
- func UpdateDNSConfig(podSpec *corev1.PodSpec, config *monitoringv1.PodDNSConfig)
- func UpdateDNSPolicy(podSpec *corev1.PodSpec, dnsPolicy *monitoringv1.DNSPolicy)
- func UpdateDaemonSet(ctx context.Context, dmsClient clientappsv1.DaemonSetInterface, ...) error
- type ClusterConfig
- type ResourceAttribute
- type ResourceNamer
Constants ¶
const ( // KubeConfigEnv (optionally) specify the location of kubeconfig file. KubeConfigEnv = "KUBECONFIG" // PrometheusOperatorFieldManager is the field manager name used by the // operator. PrometheusOperatorFieldManager = "PrometheusOperator" )
const StatusCleanupFinalizerName = "monitoring.coreos.com/status-cleanup"
StatusCleanupFinalizerName is the name of the finalizer used to garbage collect status bindings on configuration resources.
Variables ¶
This section is empty.
Functions ¶
func AddTypeInformationToObject ¶
AddTypeInformationToObject adds TypeMeta information to a runtime.Object based upon the loaded scheme.Scheme See https://github.com/kubernetes/client-go/issues/308#issuecomment-700099260
func CreateOrUpdateConfigMap ¶
func CreateOrUpdateConfigMap(ctx context.Context, cmClient typedcorev1.ConfigMapInterface, desired *corev1.ConfigMap) error
CreateOrUpdateConfigMap merges metadata of existing ConfigMap with new one and updates it.
func CreateOrUpdateEndpointSlice ¶
func CreateOrUpdateEndpointSlice(ctx context.Context, c clientdiscoveryv1.EndpointSliceInterface, eps *discoveryv1.EndpointSlice) error
CreateOrUpdateEndpointSlice creates or updates an EndpointSlice resource.
func CreateOrUpdateEndpoints ¶
func CreateOrUpdateEndpoints(ctx context.Context, eclient typedcorev1.EndpointsInterface, eps *corev1.Endpoints) error
CreateOrUpdateEndpoints creates or updates an Endpoints resource.
func CreateOrUpdateSecret ¶
func CreateOrUpdateSecret(ctx context.Context, secretClient typedcorev1.SecretInterface, desired *corev1.Secret) error
CreateOrUpdateSecret merges metadata of existing Secret with new one and updates it.
func CreateOrUpdateService ¶
func CreateOrUpdateService(ctx context.Context, sclient typedcorev1.ServiceInterface, svc *corev1.Service) (*corev1.Service, error)
CreateOrUpdateService creates or updates a Service resource.
func CreateStatefulSetOrPatchLabels ¶
func CreateStatefulSetOrPatchLabels(ctx context.Context, ssetClient clientappsv1.StatefulSetInterface, sset *appsv1.StatefulSet) (*appsv1.StatefulSet, error)
CreateStatefulSetOrPatchLabels creates a StatefulSet resource. If the StatefulSet already exists, it patches the labels from the input StatefulSet.
func EnsureCustomGoverningService ¶
func EnsureCustomGoverningService(ctx context.Context, namespace string, serviceName string, svcClient typedcorev1.ServiceInterface, selectorLabels map[string]string) error
EnsureCustomGoverningService is responsible for the following:
Verify that the service exists in the resource's namespace If it does not exist, fail the reconciliation.
If the ServiceName is specified and a service with the same name exists in the same namespace as the resource, ensure that the custom governing service's selector matches the labels. If it is not selected, fail the reconciliation Warning: the function will panic if the resource's ServiceName is nil..
func FinalizerAddPatch ¶
FinalizerAddPatch generates the JSON patch payload which adds the finalizer to the object's metadata. If the finalizer is already present, it returns an empty []byte slice.
func FinalizerDeletePatch ¶
FinalizerDeletePatch generates a JSON Patch payload to remove the specified finalizer from an object's metadata.
If the finalizer is not present, the function returns nil.
The patch includes a "test" operation before "remove" to ensure the value at the computed index matches the expected finalizer. This prevents race conditions when finalizers are modified concurrently.
func ForceUpdateStatefulSet ¶
func ForceUpdateStatefulSet(ctx context.Context, ssetClient clientappsv1.StatefulSetInterface, sset *appsv1.StatefulSet, onDeleteFunc func(string)) error
ForceUpdateStatefulSet updates a StatefulSet resource preserving custom labels and annotations. But when the update operation tries to update immutable fields for example, `.spec.selector`), the function will delete the statefulset (relying on the higher-level controller to re-create the resource during the next reconciliation).
It calls onDeleteFunc when the deletion of the resource is required. The function is given a string explaining the reason why the update was not possible.
func IsAPIGroupVersionResourceSupported ¶
func IsAPIGroupVersionResourceSupported(discoveryCli discovery.DiscoveryInterface, groupVersion schema.GroupVersion, resource string) (bool, error)
IsAPIGroupVersionResourceSupported checks if given groupVersion and resource is supported by the cluster.
func IsAllowed ¶
func IsAllowed( ctx context.Context, ssarClient typedauthv1.SelfSubjectAccessReviewInterface, namespaces []string, attributes ...ResourceAttribute, ) (bool, []error, error)
IsAllowed returns whether the user (e.g. the operator's service account) has been granted the required RBAC attributes. It returns true when the conditions are met for the namespaces (an empty namespace value means "all"). The second return value returns the list of permissions that are missing if the requirements aren't met.
func LabelSelectionHasChanged ¶
func LabelSelectionHasChanged(old, current map[string]string, selector *metav1.LabelSelector) (bool, error)
LabelSelectionHasChanged returns true if the selector doesn't yield the same results for the old and current labels.
func LoadSecretRef ¶
func LoadSecretRef(ctx context.Context, logger *slog.Logger, client typedcorev1.SecretInterface, sks *corev1.SecretKeySelector) ([]byte, error)
LoadSecretRef returns the data from a secret key reference. If the reference is set as optional and the secret or key isn't found, the function returns no error.
func MergePatchContainers ¶
MergePatchContainers adds patches to base using a strategic merge patch and iterating by container name, failing on the first error.
func MustRegisterClientGoMetrics ¶
func MustRegisterClientGoMetrics(registerer prometheus.Registerer)
MustRegisterClientGoMetrics registers the k8s.io/client-go metrics. It panics if it encounters an error (e.g. metrics already registered).
func NewClusterConfig ¶
func NewClusterConfig(config ClusterConfig) (*rest.Config, error)
func PodRunningAndReady ¶
PodRunningAndReady returns whether a pod is running and each container has passed it's ready state.
func UpdateDNSConfig ¶
func UpdateDNSConfig(podSpec *corev1.PodSpec, config *monitoringv1.PodDNSConfig)
UpdateDNSConfig updates the DNS configuration in a Pod spec.
func UpdateDNSPolicy ¶
func UpdateDNSPolicy(podSpec *corev1.PodSpec, dnsPolicy *monitoringv1.DNSPolicy)
UpdateDNSPolicy updates the DNS policy in a Pod spec.
func UpdateDaemonSet ¶
func UpdateDaemonSet(ctx context.Context, dmsClient clientappsv1.DaemonSetInterface, dset *appsv1.DaemonSet) error
UpdateDaemonSet merges metadata of existing DaemonSet with new one and updates it.
Types ¶
type ClusterConfig ¶
type ClusterConfig struct {
Host string
TLSConfig rest.TLSClientConfig
AsUser string
KubeconfigPath string
}
type ResourceAttribute ¶
type ResourceAttribute struct {
Resource string
Name string
Group string
Version string
Verbs []string
}
ResourceAttribute represents authorization attributes to check on a given resource.
type ResourceNamer ¶
type ResourceNamer struct {
// contains filtered or unexported fields
}
ResourceNamer knows how to generate valid names for various Kubernetes resources.
func NewResourceNamerWithPrefix ¶
func NewResourceNamerWithPrefix(p string) ResourceNamer
NewResourceNamerWithPrefix returns a ResourceNamer that adds a prefix followed by an hyphen character to all resource names.
func (ResourceNamer) DNS1123Label ¶
func (rn ResourceNamer) DNS1123Label(name string) (string, error)
DNS1123Label returns a name that is a valid DNS-1123 label. It will sanitize a name, removing invalid characters and if the name is bigger than 63 chars it will truncate it.
func (ResourceNamer) UniqueDNS1123Label ¶
func (rn ResourceNamer) UniqueDNS1123Label(name string) (string, error)
UniqueDNS1123Label returns a name that is a valid DNS-1123 label. The returned name has a hash-based suffix to ensure uniqueness in case the input name exceeds the 63-chars limit.