esutils

package
v1.45.0-0.dev Latest Latest
Warning

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

Go to latest
Published: Aug 17, 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"
)

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
	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 LinseedUser

func LinseedUser(clusterID, tenant string) *User

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