kubernetes

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BootstrapTokenSecretNameSuffix            = "bootstrap-token"
	BootstrapTokenManagedClusterNameLabelName = "managed-cluster-name"
)
View Source
const (
	NodePoolLabelName        = "humio.com/node-pool"
	FeatureLabelName         = "humio.com/feature"
	PodMarkedForDataEviction = "humio.com/marked-for-data-eviction"
	LogScaleClusterVhost     = "humio.com/cluster-vhost"
)
View Source
const (
	ServiceTokenSecretNameSuffix = "admin-token"
	SecretNameLabelName          = "humio.com/secret-identifier" // #nosec G101
)

Variables

This section is empty.

Functions

func AnnotationsForHumio

func AnnotationsForHumio(podAnnotations map[string]string, productVersion string) map[string]string

AnnotationsForHumio returns the set of annotations for humio pods

func ConstructClusterRoleBinding

func ConstructClusterRoleBinding(clusterRoleBindingName, clusterRoleName, humioClusterNamespace, serviceAccountName string, labels map[string]string) *rbacv1.ClusterRoleBinding

ConstructClusterRoleBinding constructs a cluster role binding which binds the given serviceAccountName to the ClusterRole passed in as clusterRoleName

func ConstructExtraKafkaConfigsConfigMap

func ConstructExtraKafkaConfigsConfigMap(extraKafkaConfigsConfigMapName, extraKafkaPropertiesFilename, extraKafkaConfigsConfigMapData, humioClusterName, humioClusterNamespace string) corev1.ConfigMap

ConstructExtraKafkaConfigsConfigMap constructs the ConfigMap object used to store the file which is passed on to Humio using the configuration option EXTRA_KAFKA_CONFIGS_FILE

func ConstructHumioBootstrapToken

func ConstructHumioBootstrapToken(humioClusterName string, humioClusterNamespace string) *humiov1alpha1.HumioBootstrapToken

ConstructHumioBootstrapToken returns a HumioBootstrapToken

func ConstructInitClusterRole

func ConstructInitClusterRole(clusterRoleName string, labels map[string]string) *rbacv1.ClusterRole

ConstructInitClusterRole returns the cluster role used by the init container to obtain information about the Kubernetes worker node that the Humio cluster pod was scheduled on

func ConstructRolePermissionsConfigMap

func ConstructRolePermissionsConfigMap(rolePermissionsConfigMapName, rolePermissionsFilename, rolePermissionsConfigMapData, humioClusterName, humioClusterNamespace string) corev1.ConfigMap

ConstructRolePermissionsConfigMap constructs a ConfigMap object used to store the file which Humio uses when enabling READ_GROUP_PERMISSIONS_FROM_FILE to control RBAC using a file rather than the Humio UI

func ConstructSecret

func ConstructSecret(humioClusterName, humioClusterNamespace, secretName string, data map[string][]byte, additionalSecretLabels map[string]string) *corev1.Secret

ConstructSecret returns an opaque secret which holds the given data

func ConstructServiceAccount

func ConstructServiceAccount(serviceAccountName, humioClusterNamespace string, serviceAccountAnnotations map[string]string, labels map[string]string) *corev1.ServiceAccount

ConstructServiceAccount constructs and returns a service account which can be used for the given cluster and which will contain the specified annotations on the service account

func ConstructServiceAccountSecret

func ConstructServiceAccountSecret(humioClusterName, humioClusterNamespace, secretName string, serviceAccountName string) *corev1.Secret

ConstructServiceAccountSecret returns a secret which holds the service account token for the given service account name

func ConstructViewGroupPermissionsConfigMap

func ConstructViewGroupPermissionsConfigMap(viewGroupPermissionsConfigMapName, viewGroupPermissionsFilename, viewGroupPermissionsConfigMapData, humioClusterName, humioClusterNamespace string) corev1.ConfigMap

ConstructViewGroupPermissionsConfigMap constructs a ConfigMap object used to store the file which Humio uses when enabling READ_GROUP_PERMISSIONS_FROM_FILE to control RBAC using a file rather than the Humio UI

func GetClusterRole

func GetClusterRole(ctx context.Context, c client.Client, clusterRoleName string) (*rbacv1.ClusterRole, error)

GetClusterRole returns the given cluster role if it exists

func GetClusterRoleBinding

func GetClusterRoleBinding(ctx context.Context, c client.Client, clusterRoleBindingName string) (*rbacv1.ClusterRoleBinding, error)

GetClusterRoleBinding returns the given cluster role binding if it exists

func GetConfigMap

func GetConfigMap(ctx context.Context, c client.Client, configMapName, humioClusterNamespace string) (corev1.ConfigMap, error)

GetConfigMap returns the configmap for the given configmap name if it exists

func GetContainerIndexByName

func GetContainerIndexByName(pod corev1.Pod, name string) (int, error)

GetContainerIndexByName returns the index of the container in the list of containers of a pod. If no container is found with the given name in the pod, an error is returned.

func GetFullSetOfMergedWebhookheaders

func GetFullSetOfMergedWebhookheaders(hn *v1alpha1.HumioAction) (map[string]string, bool)

func GetIngress

func GetIngress(ctx context.Context, c client.Client, ingressName, humioClusterNamespace string) (*networkingv1.Ingress, error)

GetIngress returns the ingress for the given ingress name if it exists

func GetInitContainerIndexByName

func GetInitContainerIndexByName(pod corev1.Pod, name string) (int, error)

GetInitContainerIndexByName returns the index of the init container in the list of init containers of a pod. If no init container is found with the given name in the pod, an error is returned.

func GetNode

func GetNode(ctx context.Context, c client.Client, nodeName string) (*corev1.Node, error)

func GetSecret

func GetSecret(ctx context.Context, c client.Client, secretName, humioClusterNamespace string) (*corev1.Secret, error)

GetSecret returns the given service if it exists

func GetSecretForHa

func GetSecretForHa(hn *v1alpha1.HumioAction) (string, bool)

func GetService

func GetService(ctx context.Context, c client.Client, humioNodePoolName, humioClusterNamespace string) (*corev1.Service, error)

GetService returns the given service if it exists

func GetServiceAccount

func GetServiceAccount(ctx context.Context, c client.Client, serviceAccountName, humioClusterNamespace string) (*corev1.ServiceAccount, error)

GetServiceAccount returns the service account

func GetZoneForNodeName

func GetZoneForNodeName(ctx context.Context, c client.Client, nodeName string) (string, error)

func LabelsForHumio

func LabelsForHumio(clusterName string) map[string]string

LabelsForHumio returns the set of common labels for Humio resources. NB: There is a copy of this function in images/helper/main.go to work around helper depending on main project.

func LabelsForHumioBootstrapToken

func LabelsForHumioBootstrapToken(clusterName string) map[string]string

LabelsForHumioBootstrapToken returns a map of labels which contains a common set of labels and additional user-defined humio bootstrap token labels. In case of overlap between the common labels and user-defined labels, the user-defined label will be ignored.

func LabelsForSecret

func LabelsForSecret(clusterName string, secretName string, additionalSecretLabels map[string]string) map[string]string

LabelsForSecret returns a map of labels which contains a common set of labels and additional user-defined secret labels. In case of overlap between the common labels and user-defined labels, the user-defined label will be ignored.

func ListCertificates

func ListCertificates(ctx context.Context, c client.Client, humioClusterNamespace string, matchingLabels client.MatchingLabels) ([]cmapi.Certificate, error)

ListCertificates grabs the list of all certificates associated to a an instance of HumioCluster

func ListHumioBootstrapTokens

func ListHumioBootstrapTokens(ctx context.Context, c client.Client, humioClusterNamespace string, matchingLabels client.MatchingLabels) ([]humiov1alpha1.HumioBootstrapToken, error)

ListHumioBootstrapTokens returns all HumioBootstrapTokens in a given namespace which matches the label selector

func ListIngresses

func ListIngresses(ctx context.Context, c client.Client, humioClusterNamespace string, matchingLabels client.MatchingLabels) ([]networkingv1.Ingress, error)

ListIngresses grabs the list of all ingress objects associated to a an instance of HumioCluster

func ListPersistentVolumeClaims

func ListPersistentVolumeClaims(ctx context.Context, c client.Client, humioClusterNamespace string, matchingLabels client.MatchingLabels) ([]corev1.PersistentVolumeClaim, error)

ListPersistentVolumeClaims grabs the list of all persistent volume claims associated to a an instance of HumioCluster

func ListPods

func ListPods(ctx context.Context, c client.Client, humioClusterNamespace string, matchingLabels client.MatchingLabels) ([]corev1.Pod, error)

ListPods grabs the list of all pods associated to an instance of HumioCluster

func ListSecrets

func ListSecrets(ctx context.Context, c client.Client, humioClusterNamespace string, matchingLabels client.MatchingLabels) ([]corev1.Secret, error)

ListSecrets returns all secrets in a given namespace which matches the label selector

func MatchingLabelsForHumio

func MatchingLabelsForHumio(clusterName string) client.MatchingLabels

MatchingLabelsForHumio returns a MatchingLabels which can be passed on to the Kubernetes client to only return objects related to a specific HumioCluster instance

func MatchingLabelsForHumioNodePool

func MatchingLabelsForHumioNodePool(clusterName, nodePoolName string) map[string]string

MatchingLabelsForHumioNodePool returns labels for Humio pods for a given cluster and specific node pool.

func RandomString

func RandomString() string

RandomString returns a string of fixed length. The random strings are valid to use in Kubernetes object names.

func StoreFullSetOfMergedWebhookActionHeaders

func StoreFullSetOfMergedWebhookActionHeaders(hn *v1alpha1.HumioAction, resolvedSecretHeaders map[string]string)

func StoreSingleSecretForHa

func StoreSingleSecretForHa(hn *v1alpha1.HumioAction, token string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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