Help us shape the future of Go! Take the 2026 Go Developer Survey

esutils

package
v1.44.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

This file contains functions common to the controllers to help them interact with elasticsearch.

Index

Constants

View Source
const (
	ElasticsearchRetentionFactor = 4
	DefaultMaxIndexSizeGi        = 30
	ElasticConnRetries           = 10
	ElasticConnRetryInterval     = "500ms"
)
View Source
const LegacySingleTenantUserSuffix = "secure"

LegacySingleTenantUserSuffix is the suffix es-kube-controllers appended to the single-tenant Elasticsearch users. Kept for backwards compatibility: the credentials and role mappings it already created only keep resolving if the operator provisions the same names.

View Source
const SystemUserFullName = "system:serviceaccount"

SystemUserFullName marks a user as one of ours rather than one backing a person. es-kube-controllers' authorization controller sweeps Elasticsearch on every resync and deletes any user that is neither marked with this full_name nor present in its OIDC user cache, so a user the operator provisions without it is deleted within one resync period and then recreated on the next reconcile. Must stay in sync with SystemUserFullName in kube-controllers/pkg/elasticsearch/users.

Variables

View Source
var (
	ElasticsearchUserNameLinseed            = "tigera-ee-linseed"
	ElasticsearchUserNameDashboardInstaller = "tigera-ee-dashboards-installer"
)

User's name in ES.

Functions

func ElasticsearchSecrets

func ElasticsearchSecrets(ctx context.Context, userSecretNames []string, cli client.Client) ([]*corev1.Secret, error)

ElasticsearchSecrets gets the secrets needed for a component to be able to access Elasticsearch.

func GetElasticLicenseType

func GetElasticLicenseType(ctx context.Context, cli client.Client, logger logr.Logger) (render.ElasticsearchLicenseType, error)

GetElasticLicenseType returns the license type from elastic-licensing ConfigMap that ECK operator keeps updated.

func GetElasticsearch

func GetElasticsearch(ctx context.Context, c client.Client) (*esv1.Elasticsearch, error)

func GetElasticsearchClusterConfig

func GetElasticsearchClusterConfig(ctx context.Context, cli client.Client) (*relasticsearch.ClusterConfig, error)

GetElasticsearchClusterConfig retrieves the config map containing the elasticsearch configuration values, such as the the cluster name and replica count.

func StrToElasticLicenseType

func StrToElasticLicenseType(license string, logger logr.Logger) render.ElasticsearchLicenseType

StrToElasticLicenseType maps Elasticsearch license to one of the known and expected value.

Types

type Application

type Application struct {
	Application string   `json:"application"`
	Privileges  []string `json:"privileges"`
	Resources   []string `json:"resources"`
}

type ElasticClient

type ElasticClient interface {
	SetILMPolicies(context.Context, *operatorv1.LogStorage, bool) error
	CreateUser(context.Context, *User) error
	DeleteUser(context.Context, *User) error
	GetUsers(ctx context.Context) ([]User, error)
}

func NewElasticClient

func NewElasticClient(client client.Client, ctx context.Context, elasticHTTPSEndpoint string, external bool) (ElasticClient, error)

type ElasticsearchClientCreator

type ElasticsearchClientCreator func(client client.Client, ctx context.Context, elasticHTTPSEndpoint string, external bool) (ElasticClient, error)

type Policy

type Policy struct {
	Phases struct {
		Hot struct {
			Actions struct {
				Rollover struct {
					MaxSize string `json:"max_size"`
					MaxAge  string `json:"max_age"`
				}
			}
		}
		Warm struct {
			Actions struct {
				Readonly *struct{} `json:"readonly,omitempty"`
			}
		}
		Delete struct {
			MinAge string `json:"min_age"`
		}
	}
}

type Role

type Role struct {
	Name       string `json:"-"`
	Definition *RoleDefinition
}

Role represents an Elasticsearch role that may be attached to a User

type RoleDefinition

type RoleDefinition struct {
	Cluster      []string      `json:"cluster"`
	Indices      []RoleIndex   `json:"indices"`
	Applications []Application `json:"applications,omitempty"`
}

type RoleIndex

type RoleIndex struct {
	Names      []string `json:"names"`
	Privileges []string `json:"privileges"`
}

type User

type User struct {
	Username string
	Password string
	// FullName is the user's full_name in Elasticsearch. Set it to SystemUserFullName on the users the
	// operator provisions - see that constant for why.
	FullName string
	Roles    []Role
}

User represents an Elasticsearch user, which may or may not have roles attached to it

func DashboardUser

func DashboardUser(clusterID, tenant string) *User

func DashboardUserSingleTenant

func DashboardUserSingleTenant(tenant string, externalElastic bool) *User

DashboardUserSingleTenant returns the Dashboards installer user for a single-tenant cluster, named the way es-kube-controllers named it. See LinseedUserSingleTenant.

func LinseedUser

func LinseedUser(clusterID string, tenant *operatorv1.Tenant) *User

LinseedUser returns the Linseed user for a multi-tenant cluster, which always stores its data in single-index format.

func LinseedUserSingleTenant

func LinseedUserSingleTenant(tenant *operatorv1.Tenant, externalElastic bool) *User

LinseedUserSingleTenant returns the Linseed user for a single-tenant cluster. A single-tenant cluster declares indices on its Tenant only once it has moved to single-index storage; until then its data lives in the per-cluster multi-index format.

func (User) RoleNames

func (u User) RoleNames() []string

RoleNames is a convenience function for getting the names of all the roles defined for this Elasticsearch user

Jump to

Keyboard shortcuts

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