chi

package
v0.0.0-...-bbbf66a Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DirPathCommonConfig specifies full path to folder, where generated common XML files for ClickHouse would be placed
	// for the following sections:
	// 1. remote servers
	// 2. operator-provided additional config files
	DirPathCommonConfig = "/etc/clickhouse-server/" + api.CommonConfigDir + "/"

	// DirPathUsersConfig specifies full path to folder, where generated users XML files for ClickHouse would be placed
	// for the following sections:
	// 1. users
	// 2. quotas
	// 3. profiles
	// 4. operator-provided additional config files
	DirPathUsersConfig = "/etc/clickhouse-server/" + api.UsersConfigDir + "/"

	// DirPathHostConfig specifies full path to folder, where generated host XML files for ClickHouse would be placed
	// for the following sections:
	// 1. macros
	// 2. zookeeper
	// 3. settings
	// 4. files
	// 5. operator-provided additional config files
	DirPathHostConfig = "/etc/clickhouse-server/" + api.HostConfigDir + "/"

	// DirPathSecretFilesConfig specifies full path to folder, where secrets are mounted
	DirPathSecretFilesConfig = "/etc/clickhouse-server/secrets.d/"

	// DirPathClickHouseData specifies full path of data folder where ClickHouse would place its data storage
	DirPathClickHouseData = "/var/lib/clickhouse"

	// DirPathClickHouseLog  specifies full path of data folder where ClickHouse would place its log files
	DirPathClickHouseLog = "/var/log/clickhouse-server"

	// DirPathDockerEntrypointInit specified full path of docker-entrypoint-initdb.d
	// For more details please check: https://github.com/ClickHouse/ClickHouse/issues/3319
	DirPathDockerEntrypointInit = "/docker-entrypoint-initdb.d"
)
View Source
const (
	// DefaultClickHouseDockerImage specifies default ClickHouse docker image to be used
	DefaultClickHouseDockerImage = "clickhouse/clickhouse-server:latest"

	// DefaultBusyBoxDockerImage specifies default BusyBox docker image to be used
	DefaultBusyBoxDockerImage = "busybox"

	// DefaultUbiDockerImage specifies default ubi docker image to be used
	DefaultUbiDockerImage = "registry.access.redhat.com/ubi8/ubi-minimal:latest"

	// ClickHouseContainerName specifies name of the clickhouse container in the pod
	ClickHouseContainerName = "clickhouse"
	// ClickHouseLogContainerName specifies name of the logger container in the pod
	ClickHouseLogContainerName = "clickhouse-log"
)
View Source
const (
	// ClickHouse open ports names and values
	ChDefaultTCPPortName               = "tcp"
	ChDefaultTCPPortNumber             = int32(9000)
	ChDefaultTLSPortName               = "secureclient"
	ChDefaultTLSPortNumber             = int32(9440)
	ChDefaultHTTPPortName              = "http"
	ChDefaultHTTPPortNumber            = int32(8123)
	ChDefaultHTTPSPortName             = "https"
	ChDefaultHTTPSPortNumber           = int32(8443)
	ChDefaultInterserverHTTPPortName   = "interserver"
	ChDefaultInterserverHTTPPortNumber = int32(9009)
)
View Source
const (
	// ZkDefaultPort specifies Zookeeper default port
	ZkDefaultPort = 2181
	// ZkDefaultRootTemplate specifies default ZK root - /clickhouse/{namespace}/{chi name}
	ZkDefaultRootTemplate = "/clickhouse/%s/%s"
)
View Source
const (
	// Pattern for string path used in <distributed_ddl><path>XXX</path></distributed_ddl>
	DistributedDDLPathPattern = "/clickhouse/%s/task_queue/ddl"

	// Special auto-generated clusters. Each of these clusters lay over all replicas in CHI
	// 1. Cluster with one shard and all replicas. Used to duplicate data over all replicas.
	// 2. Cluster with all shards (1 replica). Used to gather/scatter data over all replicas.
	OneShardAllReplicasClusterName = "all-replicated"
	AllShardsOneReplicaClusterName = "all-sharded"
)
View Source
const (
	SchemaPolicyReplicaNone                = "None"
	SchemaPolicyReplicaAll                 = "All"
	SchemaPolicyShardNone                  = "None"
	SchemaPolicyShardAll                   = "All"
	SchemaPolicyShardDistributedTablesOnly = "DistributedTablesOnly"
)

Values for Schema Policy

View Source
const (
	LabelReadyName          = clickhouse_altinity_com.APIGroupName + "/" + "ready"
	LabelReadyValueReady    = "yes"
	LabelReadyValueNotReady = "no"
	LabelAppName            = clickhouse_altinity_com.APIGroupName + "/" + "app"
	LabelAppValue           = "chop"
	LabelCHOP               = clickhouse_altinity_com.APIGroupName + "/" + "chop"
	LabelCHOPCommit         = clickhouse_altinity_com.APIGroupName + "/" + "chop-commit"
	LabelCHOPDate           = clickhouse_altinity_com.APIGroupName + "/" + "chop-date"
	LabelNamespace          = clickhouse_altinity_com.APIGroupName + "/" + "namespace"
	LabelCHIName            = clickhouse_altinity_com.APIGroupName + "/" + "chi"
	LabelClusterName        = clickhouse_altinity_com.APIGroupName + "/" + "cluster"
	LabelShardName          = clickhouse_altinity_com.APIGroupName + "/" + "shard"
	LabelReplicaName        = clickhouse_altinity_com.APIGroupName + "/" + "replica"
	LabelConfigMap          = clickhouse_altinity_com.APIGroupName + "/" + "ConfigMap"

	LabelService = clickhouse_altinity_com.APIGroupName + "/" + "Service"

	LabelPVCReclaimPolicyName = clickhouse_altinity_com.APIGroupName + "/" + "reclaimPolicy"

	LabelZookeeperConfigVersion = clickhouse_altinity_com.APIGroupName + "/" + "zookeeper-version"
	LabelSettingsConfigVersion  = clickhouse_altinity_com.APIGroupName + "/" + "settings-version"
	LabelObjectVersion          = clickhouse_altinity_com.APIGroupName + "/" + "object-version"

	LabelShardScopeIndex         = clickhouse_altinity_com.APIGroupName + "/" + "shardScopeIndex"
	LabelReplicaScopeIndex       = clickhouse_altinity_com.APIGroupName + "/" + "replicaScopeIndex"
	LabelCHIScopeIndex           = clickhouse_altinity_com.APIGroupName + "/" + "chiScopeIndex"
	LabelCHIScopeCycleSize       = clickhouse_altinity_com.APIGroupName + "/" + "chiScopeCycleSize"
	LabelCHIScopeCycleIndex      = clickhouse_altinity_com.APIGroupName + "/" + "chiScopeCycleIndex"
	LabelCHIScopeCycleOffset     = clickhouse_altinity_com.APIGroupName + "/" + "chiScopeCycleOffset"
	LabelClusterScopeIndex       = clickhouse_altinity_com.APIGroupName + "/" + "clusterScopeIndex"
	LabelClusterScopeCycleSize   = clickhouse_altinity_com.APIGroupName + "/" + "clusterScopeCycleSize"
	LabelClusterScopeCycleIndex  = clickhouse_altinity_com.APIGroupName + "/" + "clusterScopeCycleIndex"
	LabelClusterScopeCycleOffset = clickhouse_altinity_com.APIGroupName + "/" + "clusterScopeCycleOffset"
)

Set of kubernetes labels used by the operator

View Source
const (
	InternodeClusterSecretEnvName = "CLICKHOUSE_INTERNODE_CLUSTER_SECRET"
)
View Source
const (
	// Default value for ClusterIP service
	TemplateDefaultsServiceClusterIP = "None"
)

Variables

This section is empty.

Functions

func AppendAnnotationReady

func AppendAnnotationReady(meta *meta.ObjectMeta) bool

AppendAnnotationReady appends "Ready" annotation to ObjectMeta.Annotations Returns true in case annotation was not in place and was added.

func AppendLabelReady

func AppendLabelReady(meta *meta.ObjectMeta) bool

AppendLabelReady appends "Ready" label to ObjectMeta.Labels. Returns true in case label was not in place and was added.

func CreateCHIServiceFQDN

func CreateCHIServiceFQDN(chi *api.ClickHouseInstallation) string

CreateCHIServiceFQDN creates a FQD name of a root ClickHouseInstallation Service resource

func CreateCHIServiceName

func CreateCHIServiceName(chi *api.ClickHouseInstallation) string

CreateCHIServiceName creates a name of a root ClickHouseInstallation Service resource

func CreateClusterAutoSecretName

func CreateClusterAutoSecretName(cluster *api.Cluster) string

CreateClusterAutoSecretName creates Secret name where auto-generated secret is kept

func CreateClusterServiceName

func CreateClusterServiceName(cluster *api.Cluster) string

CreateClusterServiceName returns a name of a cluster's Service

func CreateConfigMapCommonName

func CreateConfigMapCommonName(chi *api.ClickHouseInstallation) string

CreateConfigMapCommonName returns a name for a ConfigMap for replica's common config

func CreateConfigMapCommonUsersName

func CreateConfigMapCommonUsersName(chi *api.ClickHouseInstallation) string

CreateConfigMapCommonUsersName returns a name for a ConfigMap for replica's common users config

func CreateConfigMapHostName

func CreateConfigMapHostName(host *api.ChiHost) string

CreateConfigMapHostName returns a name for a ConfigMap for replica's personal config

func CreateFQDN

func CreateFQDN(host *api.ChiHost) string

CreateFQDN is a wrapper over pod FQDN function

func CreateFQDNs

func CreateFQDNs(obj interface{}, scope interface{}, excludeSelf bool) []string

CreateFQDNs is a wrapper over set of create FQDN functions obj specifies source object to create FQDNs from scope specifies target scope - what entity to create FQDNs for - be it CHI, cluster, shard or a host excludeSelf specifies whether to exclude the host itself from the result. Applicable only in case obj is a host

func CreateHostName

func CreateHostName(host *api.ChiHost, shard *api.ChiShard, shardIndex int, replica *api.ChiReplica, replicaIndex int) string

CreateHostName returns a name of a host

func CreateHostTemplateName

func CreateHostTemplateName(host *api.ChiHost) string

CreateHostTemplateName returns a name of a HostTemplate

func CreateInstanceHostname

func CreateInstanceHostname(host *api.ChiHost) string

CreateInstanceHostname returns hostname (pod-hostname + service or FQDN) which can be used as a replica name in all places where ClickHouse requires replica name. These are such places as: 1. "remote_servers.xml" config file 2. statements like SYSTEM DROP REPLICA <replica_name> any other places Function operations are based on .Spec.Defaults.ReplicasUseFQDN

func CreatePVCNameByVolumeClaimTemplate

func CreatePVCNameByVolumeClaimTemplate(host *api.ChiHost, volumeClaimTemplate *api.VolumeClaimTemplate) string

CreatePVCNameByVolumeClaimTemplate creates PVC name

func CreatePVCNameByVolumeMount

func CreatePVCNameByVolumeMount(host *api.ChiHost, volumeMount *core.VolumeMount) (string, bool)

CreatePVCNameByVolumeMount creates PVC name

func CreatePodHostname

func CreatePodHostname(host *api.ChiHost) string

CreatePodHostname returns a hostname of a Pod of a ClickHouse instance. Is supposed to be used where network connection to a Pod is required. NB: right now Pod's hostname points to a Service, through which Pod can be accessed.

func CreatePodHostnameRegexp

func CreatePodHostnameRegexp(chi *api.ClickHouseInstallation, template string) string

CreatePodHostnameRegexp creates pod hostname regexp. For example, `template` can be defined in operator config: HostRegexpTemplate: chi-{chi}-[^.]+\\d+-\\d+\\.{namespace}.svc.cluster.local$"

func CreatePodName

func CreatePodName(obj interface{}) string

CreatePodName creates Pod name based on specified StatefulSet or Host

func CreatePodNames

func CreatePodNames(obj interface{}) []string

CreatePodNames is a wrapper over set of create pod names functions obj specifies source object to create names from

func CreateReplicaName

func CreateReplicaName(replica *api.ChiReplica, index int) string

CreateReplicaName returns a name of a replica. Here replica is a CHOp-internal replica - i.e. a vertical slice of hosts field. In case you are looking for replica name in terms of a hostname to address particular host as in remote_servers.xml you need to take a look on CreateInstanceHostname function

func CreateShardName

func CreateShardName(shard *api.ChiShard, index int) string

CreateShardName returns a name of a shard

func CreateShardServiceName

func CreateShardServiceName(shard *api.ChiShard) string

CreateShardServiceName returns a name of a shard's Service

func CreateStatefulSetName

func CreateStatefulSetName(host *api.ChiHost) string

CreateStatefulSetName creates a name of a StatefulSet for ClickHouse instance

func CreateStatefulSetServiceName

func CreateStatefulSetServiceName(host *api.ChiHost) string

CreateStatefulSetServiceName returns a name of a StatefulSet-related Service for ClickHouse instance

func DeleteAnnotationReady

func DeleteAnnotationReady(meta *meta.ObjectMeta) bool

DeleteAnnotationReady deletes "Ready" annotation from ObjectMeta.Annotations Returns true in case annotation was in place and was deleted.

func DeleteLabelReady

func DeleteLabelReady(meta *meta.ObjectMeta) bool

DeleteLabelReady deletes "Ready" label from ObjectMeta.Labels Returns true in case label was in place and was deleted.

func GetCHINameFromObjectMeta

func GetCHINameFromObjectMeta(meta *meta.ObjectMeta) (string, error)

GetCHINameFromObjectMeta extracts CHI name from ObjectMeta. Based on labels.

func GetClusterNameFromObjectMeta

func GetClusterNameFromObjectMeta(meta *meta.ObjectMeta) (string, error)

GetClusterNameFromObjectMeta extracts cluster name from ObjectMeta. Based on labels.

func GetObjectVersion

func GetObjectVersion(meta meta.ObjectMeta) (string, bool)

GetObjectVersion gets version of the object

func GetPVCProvisioner

func GetPVCProvisioner(host *api.ChiHost, template *api.VolumeClaimTemplate) api.PVCProvisioner

func GetReclaimPolicy

func GetReclaimPolicy(meta meta.ObjectMeta) api.PVCReclaimPolicy

GetReclaimPolicy gets reclaim policy from meta

func GetSelectorClusterScope

func GetSelectorClusterScope(cluster *api.Cluster) map[string]string

GetSelectorClusterScope gets labels to select a Cluster-scoped object

func GetSelectorClusterScopeReady

func GetSelectorClusterScopeReady(cluster *api.Cluster) map[string]string

GetSelectorClusterScope gets labels to select a ready-labelled Cluster-scoped object

func GetSelectorHostScope

func GetSelectorHostScope(host *api.ChiHost) map[string]string

GetSelectorHostScope gets labels to select a Host-scoped object

func GetSelectorShardScopeReady

func GetSelectorShardScopeReady(shard *api.ChiShard) map[string]string

GetSelectorShardScopeReady gets labels to select a ready-labelled Shard-scoped object

func GetVolumeClaimTemplate

func GetVolumeClaimTemplate(host *api.ChiHost, volumeMount *core.VolumeMount) (*api.VolumeClaimTemplate, bool)

func HostCanDeleteAllPVCs

func HostCanDeleteAllPVCs(host *api.ChiHost) bool

HostCanDeleteAllPVCs checks whether all PVCs can be deleted

func HostCanDeletePVC

func HostCanDeletePVC(host *api.ChiHost, pvcName string) bool

HostCanDeletePVC checks whether PVC on a host can be deleted

func HostHasTablesCreated

func HostHasTablesCreated(host *api.ChiHost) bool

HostHasTablesCreated checks whether host has tables listed as already created

func HostIsNewOne

func HostIsNewOne(host *api.ChiHost) bool

HostIsNewOne checks whether host is a newly created TODO there should be better way to detect newly created CHI TODO unify with api host.IsNew

func HostWalkAssignedPorts

func HostWalkAssignedPorts(host *api.ChiHost, f func(name string, port *int32, protocol core.Protocol) bool)

func HostWalkInvalidPorts

func HostWalkInvalidPorts(host *api.ChiHost, f func(name string, port *int32, protocol core.Protocol) bool)

func HostWalkPorts

func HostWalkPorts(host *api.ChiHost, f func(name string, port *int32, protocol core.Protocol) bool)

func IsAutoGeneratedHostName

func IsAutoGeneratedHostName(
	name string,
	host *api.ChiHost,
	shard *api.ChiShard,
	shardIndex int,
	replica *api.ChiReplica,
	replicaIndex int,
) bool

IsAutoGeneratedHostName checks whether name is auto-generated

func IsAutoGeneratedReplicaName

func IsAutoGeneratedReplicaName(name string, replica *api.ChiReplica, index int) bool

IsAutoGeneratedReplicaName checks whether provided name is auto-generated

func IsAutoGeneratedShardName

func IsAutoGeneratedShardName(name string, shard *api.ChiShard, index int) bool

IsAutoGeneratedShardName checks whether provided name is auto-generated

func IsCHOPGeneratedObject

func IsCHOPGeneratedObject(meta *meta.ObjectMeta) bool

IsCHOPGeneratedObject check whether object is generated by an operator. Check is label-based

func IsConfigurationChangeRequiresReboot

func IsConfigurationChangeRequiresReboot(host *api.ChiHost) bool

IsConfigurationChangeRequiresReboot checks whether configuration changes requires a reboot

func IsObjectTheSame

func IsObjectTheSame(meta1, meta2 *meta.ObjectMeta) bool

IsObjectTheSame checks whether objects are the same

func MakeObjectVersion

func MakeObjectVersion(meta *meta.ObjectMeta, obj interface{})

MakeObjectVersion makes object version label

func MakeSelectorFromObjectMeta

func MakeSelectorFromObjectMeta(objMeta *meta.ObjectMeta) (k8sLabels.Selector, error)

MakeSelectorFromObjectMeta makes selector from meta TODO review usage

func MergeAffinity

func MergeAffinity(dst *core.Affinity, src *core.Affinity) *core.Affinity

MergeAffinity merges from src into dst and returns dst

func NewAffinity

func NewAffinity(template *api.PodTemplate) *core.Affinity

NewAffinity creates new Affinity struct

func PrepareAffinity

func PrepareAffinity(podTemplate *api.PodTemplate, host *api.ChiHost)

PrepareAffinity

Types

type ActionPlan

type ActionPlan struct {
	// contains filtered or unexported fields
}

ActionPlan is an action plan with list of differences between two CHIs

func NewActionPlan

func NewActionPlan(old, new *api.ClickHouseInstallation) *ActionPlan

NewActionPlan makes new ActionPlan out of two CHIs

func (*ActionPlan) GetNewHostsNum

func (ap *ActionPlan) GetNewHostsNum() int

GetNewHostsNum - total number of hosts to be achieved

func (*ActionPlan) GetRemovedHostsNum

func (ap *ActionPlan) GetRemovedHostsNum() int

GetRemovedHostsNum - how many hosts would be removed

func (*ActionPlan) HasActionsToDo

func (ap *ActionPlan) HasActionsToDo() bool

HasActionsToDo checks whether there are any actions to do - meaning changes between states to reconcile

func (*ActionPlan) String

func (ap *ActionPlan) String() string

String stringifies ActionPlan

func (*ActionPlan) WalkAdded

func (ap *ActionPlan) WalkAdded(
	clusterFunc func(cluster *api.Cluster),
	shardFunc func(shard *api.ChiShard),
	hostFunc func(host *api.ChiHost),
)

WalkAdded walk added cluster items

func (*ActionPlan) WalkModified

func (ap *ActionPlan) WalkModified(
	clusterFunc func(cluster *api.Cluster),
	shardFunc func(shard *api.ChiShard),
	hostFunc func(host *api.ChiHost),
)

WalkModified walk modified cluster items

func (*ActionPlan) WalkRemoved

func (ap *ActionPlan) WalkRemoved(
	clusterFunc func(cluster *api.Cluster),
	shardFunc func(shard *api.ChiShard),
	hostFunc func(host *api.ChiHost),
)

WalkRemoved walk removed cluster items

type Annotator

type Annotator struct {
	// contains filtered or unexported fields
}

Annotator is an entity which can annotate CHI artifacts

func NewAnnotator

func NewAnnotator(chi *api.ClickHouseInstallation) *Annotator

NewAnnotator creates new annotator with context

func (*Annotator) GetClusterScope

func (a *Annotator) GetClusterScope(cluster *api.Cluster) map[string]string

GetClusterScope gets annotations for Cluster-scoped object

func (*Annotator) GetConfigMapCHICommon

func (a *Annotator) GetConfigMapCHICommon() map[string]string

GetConfigMapCHICommon

func (*Annotator) GetConfigMapCHICommonUsers

func (a *Annotator) GetConfigMapCHICommonUsers() map[string]string

GetConfigMapCHICommonUsers

func (*Annotator) GetConfigMapHost

func (a *Annotator) GetConfigMapHost(host *api.ChiHost) map[string]string

GetConfigMapHost

func (*Annotator) GetHostScope

func (a *Annotator) GetHostScope(host *api.ChiHost) map[string]string

GetHostScope gets annotations for Host-scoped object

func (*Annotator) GetPV

func (a *Annotator) GetPV(pv *core.PersistentVolume, host *api.ChiHost) map[string]string

GetPV

func (*Annotator) GetPVC

func (a *Annotator) GetPVC(
	pvc *core.PersistentVolumeClaim,
	host *api.ChiHost,
	template *api.VolumeClaimTemplate,
) map[string]string

GetPVC

func (*Annotator) GetServiceCHI

func (a *Annotator) GetServiceCHI(chi *api.ClickHouseInstallation) map[string]string

GetServiceCHI

func (*Annotator) GetServiceCluster

func (a *Annotator) GetServiceCluster(cluster *api.Cluster) map[string]string

GetServiceCluster

func (*Annotator) GetServiceHost

func (a *Annotator) GetServiceHost(host *api.ChiHost) map[string]string

GetServiceHost

func (*Annotator) GetServiceShard

func (a *Annotator) GetServiceShard(shard *api.ChiShard) map[string]string

GetServiceShard

type ClickHouseConfigFilesGenerator

type ClickHouseConfigFilesGenerator struct {
	// contains filtered or unexported fields
}

ClickHouseConfigFilesGenerator specifies clickhouse configuration generator object

func NewClickHouseConfigFilesGenerator

func NewClickHouseConfigFilesGenerator(
	chConfigGenerator *ClickHouseConfigGenerator,
	chopConfig *api.OperatorConfig,
) *ClickHouseConfigFilesGenerator

NewClickHouseConfigFilesGenerator creates new clickhouse configuration generator object

func (*ClickHouseConfigFilesGenerator) CreateConfigFilesGroupCommon

func (c *ClickHouseConfigFilesGenerator) CreateConfigFilesGroupCommon(options *ClickHouseConfigFilesGeneratorOptions) map[string]string

CreateConfigFilesGroupCommon creates common config files

func (*ClickHouseConfigFilesGenerator) CreateConfigFilesGroupHost

func (c *ClickHouseConfigFilesGenerator) CreateConfigFilesGroupHost(host *api.ChiHost) map[string]string

CreateConfigFilesGroupHost creates host config files

func (*ClickHouseConfigFilesGenerator) CreateConfigFilesGroupUsers

func (c *ClickHouseConfigFilesGenerator) CreateConfigFilesGroupUsers() map[string]string

CreateConfigFilesGroupUsers creates users config files

type ClickHouseConfigFilesGeneratorOptions

type ClickHouseConfigFilesGeneratorOptions struct {
	RemoteServersGeneratorOptions *RemoteServersGeneratorOptions
}

ClickHouseConfigFilesGeneratorOptions specifies options for clickhouse configuration generator

func NewClickHouseConfigFilesGeneratorOptions

func NewClickHouseConfigFilesGeneratorOptions() *ClickHouseConfigFilesGeneratorOptions

NewClickHouseConfigFilesGeneratorOptions creates new options for clickhouse configuration generator

func (*ClickHouseConfigFilesGeneratorOptions) GetRemoteServersGeneratorOptions

func (o *ClickHouseConfigFilesGeneratorOptions) GetRemoteServersGeneratorOptions() *RemoteServersGeneratorOptions

GetRemoteServersGeneratorOptions gets remote-servers generator options

func (*ClickHouseConfigFilesGeneratorOptions) SetRemoteServersGeneratorOptions

SetRemoteServersGeneratorOptions sets remote-servers generator options

type ClickHouseConfigGenerator

type ClickHouseConfigGenerator struct {
	// contains filtered or unexported fields
}

ClickHouseConfigGenerator generates ClickHouse configuration files content for specified CHI ClickHouse configuration files content is an XML ATM, so config generator provides set of Get*() functions which produces XML which are parts of ClickHouse configuration and can/should be used as ClickHouse config files.

func NewClickHouseConfigGenerator

func NewClickHouseConfigGenerator(chi *api.ClickHouseInstallation) *ClickHouseConfigGenerator

NewClickHouseConfigGenerator returns new ClickHouseConfigGenerator struct

func (*ClickHouseConfigGenerator) CHIHostsNum

CHIHostsNum count hosts according to the options

func (*ClickHouseConfigGenerator) ClusterHostsNum

func (c *ClickHouseConfigGenerator) ClusterHostsNum(cluster *api.Cluster, options *RemoteServersGeneratorOptions) int

ClusterHostsNum count hosts according to the options

func (*ClickHouseConfigGenerator) GetHostHostnameAndPorts

func (c *ClickHouseConfigGenerator) GetHostHostnameAndPorts(host *api.ChiHost) string

GetHostHostnameAndPorts creates "ports.xml" content

func (*ClickHouseConfigGenerator) GetHostMacros

func (c *ClickHouseConfigGenerator) GetHostMacros(host *api.ChiHost) string

GetHostMacros creates "macros.xml" content

func (*ClickHouseConfigGenerator) GetHostZookeeper

func (c *ClickHouseConfigGenerator) GetHostZookeeper(host *api.ChiHost) string

GetHostZookeeper creates data for "zookeeper.xml"

func (*ClickHouseConfigGenerator) GetProfiles

func (c *ClickHouseConfigGenerator) GetProfiles() string

GetProfiles creates data for profiles section. Used as "profiles.xml"

func (*ClickHouseConfigGenerator) GetQuotas

func (c *ClickHouseConfigGenerator) GetQuotas() string

GetQuotas creates data for "quotas.xml"

func (*ClickHouseConfigGenerator) GetRemoteServers

func (c *ClickHouseConfigGenerator) GetRemoteServers(options *RemoteServersGeneratorOptions) string

GetRemoteServers creates "remote_servers.xml" content and calculates data generation parameters for other sections

func (*ClickHouseConfigGenerator) GetSectionFromFiles

func (c *ClickHouseConfigGenerator) GetSectionFromFiles(section api.SettingsSection, includeUnspecified bool, host *api.ChiHost) map[string]string

GetSectionFromFiles creates data for custom common config files

func (*ClickHouseConfigGenerator) GetSettings

func (c *ClickHouseConfigGenerator) GetSettings(host *api.ChiHost) string

GetSettings creates data for "settings.xml"

func (*ClickHouseConfigGenerator) GetSettingsGlobal

func (c *ClickHouseConfigGenerator) GetSettingsGlobal() string

GetSettingsGlobal creates data for "settings.xml"

func (*ClickHouseConfigGenerator) GetUsers

func (c *ClickHouseConfigGenerator) GetUsers() string

GetUsers creates data for users section. Used as "users.xml"

func (*ClickHouseConfigGenerator) ShardHostsNum

func (c *ClickHouseConfigGenerator) ShardHostsNum(shard *api.ChiShard, options *RemoteServersGeneratorOptions) int

ShardHostsNum count hosts according to the options

type EntityType

type EntityType string

EntityType specifies registry entity type

const (
	// StatefulSet describes StatefulSet entity type
	StatefulSet EntityType = "StatefulSet"
	// ConfigMap describes ConfigMap entity type
	ConfigMap EntityType = "ConfigMap"
	// Service describes Service entity type
	Service EntityType = "Service"
	// Secret describes Secret entity type
	Secret EntityType = "Secret"
	// PVC describes PersistentVolumeClaim entity type
	PVC EntityType = "PVC"
	// Comment out PV
	// PV describes PersistentVolume entity type
	//PV EntityType = "PV"
	// PDB describes PodDisruptionBudget entity type
	PDB EntityType = "PDB"
)

Possible entity types

type Labeler

type Labeler struct {
	// contains filtered or unexported fields
}

Labeler is an entity which can label CHI artifacts

func NewLabeler

func NewLabeler(chi *api.ClickHouseInstallation) *Labeler

NewLabeler creates new labeler with context

func (*Labeler) GetClusterScope

func (l *Labeler) GetClusterScope(cluster *api.Cluster) map[string]string

GetClusterScope gets labels for Cluster-scoped object

func (*Labeler) GetConfigMapCHICommon

func (l *Labeler) GetConfigMapCHICommon() map[string]string

GetConfigMapCHICommon

func (*Labeler) GetConfigMapCHICommonUsers

func (l *Labeler) GetConfigMapCHICommonUsers() map[string]string

GetConfigMapCHICommonUsers

func (*Labeler) GetConfigMapHost

func (l *Labeler) GetConfigMapHost(host *api.ChiHost) map[string]string

GetConfigMapHost

func (*Labeler) GetHostScope

func (l *Labeler) GetHostScope(host *api.ChiHost, applySupplementaryServiceLabels bool) map[string]string

GetHostScope gets labels for Host-scoped object

func (*Labeler) GetHostScopeReady

func (l *Labeler) GetHostScopeReady(host *api.ChiHost, applySupplementaryServiceLabels bool) map[string]string

GetHostScopeReady gets labels for Host-scoped object including Ready label

func (*Labeler) GetPV

func (l *Labeler) GetPV(pv *core.PersistentVolume, host *api.ChiHost) map[string]string

GetPV

func (*Labeler) GetPVC

func (l *Labeler) GetPVC(
	pvc *core.PersistentVolumeClaim,
	host *api.ChiHost,
	template *api.VolumeClaimTemplate,
) map[string]string

GetPVC

func (*Labeler) GetSelectorCHIScope

func (l *Labeler) GetSelectorCHIScope() map[string]string

GetSelectorCHIScope gets labels to select a CHI-scoped object

func (*Labeler) GetSelectorCHIScopeReady

func (l *Labeler) GetSelectorCHIScopeReady() map[string]string

GetSelectorCHIScopeReady gets labels to select a ready-labelled CHI-scoped object

func (*Labeler) GetServiceCHI

func (l *Labeler) GetServiceCHI(chi *api.ClickHouseInstallation) map[string]string

GetServiceCHI

func (*Labeler) GetServiceCluster

func (l *Labeler) GetServiceCluster(cluster *api.Cluster) map[string]string

GetServiceCluster

func (*Labeler) GetServiceHost

func (l *Labeler) GetServiceHost(host *api.ChiHost) map[string]string

GetServiceHost

func (*Labeler) GetServiceShard

func (l *Labeler) GetServiceShard(shard *api.ChiShard) map[string]string

GetServiceShard

type MacrosEngine

type MacrosEngine struct {
	// contains filtered or unexported fields
}

MacrosEngine

func Macro

func Macro(scope interface{}) *MacrosEngine

Macro

func (*MacrosEngine) Line

func (m *MacrosEngine) Line(line string) string

Line expands line with macros(es)

func (*MacrosEngine) Map

func (m *MacrosEngine) Map(_map map[string]string) map[string]string

Map expands map with macros(es)

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry specifies registry struct

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates new registry

func (*Registry) HasConfigMap

func (r *Registry) HasConfigMap(meta meta.ObjectMeta) bool

HasConfigMap checks whether registry has specified ConfigMap

func (*Registry) HasPDB

func (r *Registry) HasPDB(meta meta.ObjectMeta) bool

HasPDB checks whether registry has specified PDB

func (*Registry) HasPVC

func (r *Registry) HasPVC(meta meta.ObjectMeta) bool

HasPVC checks whether registry has specified PVC

func (*Registry) HasSecret

func (r *Registry) HasSecret(meta meta.ObjectMeta) bool

HasSecret checks whether registry has specified Secret

func (*Registry) HasService

func (r *Registry) HasService(meta meta.ObjectMeta) bool

HasService checks whether registry has specified Service

func (*Registry) HasStatefulSet

func (r *Registry) HasStatefulSet(meta meta.ObjectMeta) bool

HasStatefulSet checks whether registry has specified StatefulSet

func (*Registry) Len

func (r *Registry) Len(what ...EntityType) int

Len return len of the whole registry or specified entity types Note that this is unsafe to call recursively, including in calls to other synchronized Registry functions like Walk (and therefore in the "work" function passed into iterators like Walk and walkEntityType).

func (*Registry) NumConfigMap

func (r *Registry) NumConfigMap() int

NumConfigMap gets number of ConfigMap

func (*Registry) NumPDB

func (r *Registry) NumPDB() int

NumPDB gets number of PDB

func (*Registry) NumPVC

func (r *Registry) NumPVC() int

NumPVC gets number of PVC

func (*Registry) NumSecret

func (r *Registry) NumSecret() int

NumSecret gets number of Secret

func (*Registry) NumService

func (r *Registry) NumService() int

NumService gets number of Service

func (*Registry) NumStatefulSet

func (r *Registry) NumStatefulSet() int

NumStatefulSet gets number of StatefulSet

func (*Registry) RegisterConfigMap

func (r *Registry) RegisterConfigMap(meta meta.ObjectMeta)

RegisterConfigMap register ConfigMap

func (*Registry) RegisterPDB

func (r *Registry) RegisterPDB(meta meta.ObjectMeta)

RegisterPDB register PDB

func (*Registry) RegisterPVC

func (r *Registry) RegisterPVC(meta meta.ObjectMeta)

RegisterPVC register PVC

func (*Registry) RegisterSecret

func (r *Registry) RegisterSecret(meta meta.ObjectMeta)

RegisterSecret register Secret

func (*Registry) RegisterService

func (r *Registry) RegisterService(meta meta.ObjectMeta)

RegisterService register Service

func (*Registry) RegisterStatefulSet

func (r *Registry) RegisterStatefulSet(meta meta.ObjectMeta)

RegisterStatefulSet registers StatefulSet

func (*Registry) String

func (r *Registry) String() string

String makes string representation of the registry

func (*Registry) Subtract

func (r *Registry) Subtract(sub *Registry) *Registry

Subtract subtracts specified registry from main

func (*Registry) Walk

func (r *Registry) Walk(f func(entityType EntityType, meta meta.ObjectMeta))

Walk walks over registry. Note: this is fairly expensive in the sense that it locks the entire registry from being written for the full duration of whatever workload is applied throughout iteration. Avoid calling when you know the entity type you want.

func (*Registry) WalkConfigMap

func (r *Registry) WalkConfigMap(f func(meta meta.ObjectMeta))

WalkConfigMap walk over specified entity types

func (*Registry) WalkPDB

func (r *Registry) WalkPDB(f func(meta meta.ObjectMeta))

WalkPDB walk over specified entity types

func (*Registry) WalkPVC

func (r *Registry) WalkPVC(f func(meta meta.ObjectMeta))

WalkPVC walk over specified entity types

func (*Registry) WalkSecret

func (r *Registry) WalkSecret(f func(meta meta.ObjectMeta))

WalkSecret walk over specified entity types

func (*Registry) WalkService

func (r *Registry) WalkService(f func(meta meta.ObjectMeta))

WalkService walk over specified entity types

func (*Registry) WalkStatefulSet

func (r *Registry) WalkStatefulSet(f func(meta meta.ObjectMeta))

WalkStatefulSet walk over specified entity types

type RemoteServersGeneratorOptions

type RemoteServersGeneratorOptions struct {
	// contains filtered or unexported fields
}

RemoteServersGeneratorOptions specifies options for remote-servers generator

func NewRemoteServersGeneratorOptions

func NewRemoteServersGeneratorOptions() *RemoteServersGeneratorOptions

NewRemoteServersGeneratorOptions creates new remote-servers generator options

func (*RemoteServersGeneratorOptions) Exclude

func (o *RemoteServersGeneratorOptions) Exclude(host *api.ChiHost) bool

Exclude tells whether to exclude the host

func (*RemoteServersGeneratorOptions) ExcludeHost

ExcludeHost specifies to exclude a host

func (*RemoteServersGeneratorOptions) ExcludeHosts

ExcludeHosts specifies to exclude list of hosts

func (*RemoteServersGeneratorOptions) ExcludeReconcileAttributes

ExcludeReconcileAttributes specifies to exclude reconcile attributes

func (*RemoteServersGeneratorOptions) Include

func (o *RemoteServersGeneratorOptions) Include(host *api.ChiHost) bool

Include tells whether to include the host

func (*RemoteServersGeneratorOptions) String

String returns string representation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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