Skip to main content
Version: Preview

Environment variables and placeholders

Environment variables

Pod container environment variables

The following variables are injected by KubeBlocks into each pod.

NameDescription
KB_POD_NAMEK8s Pod Name
KB_NAMESPACEK8s Pod Namespace
KB_SA_NAMEKubeBlocks Service Account Name
KB_NODENAMEK8s Node Name
KB_HOSTIPK8s Host IP address
KB_PODIPK8s Pod IP address
KB_PODIPSK8s Pod IP addresses
KB_POD_UIDPOD UID (pod.metadata.uid)
KB_CLUSTER_NAMEKubeBlocks Cluster API object name
KB_COMP_NAMERunning pod's KubeBlocks Cluster API object's .spec.components.name
KB_CLUSTER_COMP_NAMERunning pod's KubeBlocks Cluster API object's <.metadata.name>-<.spec.components.name>
KB_REPLICA_COUNTRunning pod's component's replica
KB_CLUSTER_UIDRunning pods' KubeBlocks Cluster API object's metadata.uid
KB_CLUSTER_UID_POSTFIX_8Last eight digits of KB_CLUSTER_UID
KB_{ordinal}_HOSTNAMERunning pod's hostname, where {ordinal} is the ordinal of pod.
N/A if workloadType=Stateless.
KB_POD_FQDNRunning pod's fully qualified domain name (FQDN).
N/A if workloadType=Stateless.

Built-in Place-holders

ComponentValueFrom API

NameDescription
POD_ORDINALPod ordinal
POD_FQDNPod FQDN (fully qualified domain name)
POD_NAMEPod Name

ConnectionCredential API

NameDescription
UUIDGenerate a random UUID v4 string.
UUID_B64Generate a random UUID v4 BASE64 encoded string.
UUID_STR_B64Generate a random UUID v4 string then BASE64 encoded.
UUID_HEXGenerate a random UUID v4 HEX representation.
HEADLESS_SVC_FQDNHeadless service FQDN placeholder, value pattern - $(CLUSTER_NAME)-$(1ST_COMP_NAME)-headless.$(NAMESPACE).svc, where 1ST_COMP_NAME is the 1st component that provide ClusterDefinition.spec.componentDefs[].service attribute.
SVC_FQDNService FQDN placeholder, value pattern - $(CLUSTER_NAME)-$(1ST_COMP_NAME).$(NAMESPACE).svc, where 1ST_COMP_NAME is the 1st component that provide ClusterDefinition.spec.componentDefs[].service attribute.
SVCPORT{PORT_NAME}A ServicePort's port value with specified port name, i.e, a servicePort JSON struct:
{"name": "mysql", "targetPort": "mysqlContainerPort", "port": 3306}, and "$(SVC_PORT_mysql)" in the connection credential value is 3306.
RANDOM_PASSWDRandom 8 characters