github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/deploy/elasticsearch/templates/clusterdefinition.yaml (about) 1 apiVersion: apps.kubeblocks.io/v1alpha1 2 kind: ClusterDefinition 3 metadata: 4 name: elasticsearch 5 labels: 6 {{- include "elasticsearch.labels" . | nindent 4 }} 7 spec: 8 type: elasticsearch 9 connectionCredential: 10 username: root 11 password: "$(RANDOM_PASSWD)" 12 endpoint: "https://$(SVC_FQDN):$(SVC_PORT_rest-api)" 13 host: "$(SVC_FQDN)" 14 port: "$(SVC_PORT_rest-api)" 15 16 componentDefs: 17 18 - name: elasticsearch 19 characterType: elasticsearch 20 21 configSpecs: 22 - name: elasticsearch-config-template 23 templateRef: elasticsearch-config-template 24 volumeName: elasticsearch-config 25 namespace: {{.Release.Namespace}} 26 workloadType: Stateful 27 28 service: # Source: elasticsearch/templates/service.yaml -> coordinating-only 29 ports: 30 - name: rest-api # tcp 31 port: 9200 32 targetPort: rest-api 33 - name: transport # tcp 34 port: 9300 35 targetPort: transport 36 volumeTypes: 37 - name: data 38 type: data 39 40 podSpec: 41 initContainers: 42 - name: sysctl 43 imagePullPolicy: IfNotPresent 44 command: 45 - sh 46 - -c 47 - | 48 set -xe 49 DESIRED="262144" 50 CURRENT=$(sysctl -n vm.max_map_count) 51 if [ "$DESIRED" -gt "$CURRENT" ]; then 52 sysctl -w vm.max_map_count=$DESIRED 53 fi 54 securityContext: 55 runAsUser: 0 56 privileged: true 57 containers: 58 - name: elasticsearch 59 imagePullPolicy: IfNotPresent 60 61 securityContext: 62 runAsNonRoot: true 63 runAsUser: 1001 64 65 readinessProbe: 66 tcpSocket: 67 port: 9200 68 periodSeconds: 5 69 timeoutSeconds: 3 70 failureThreshold: 3 71 72 startupProbe: 73 tcpSocket: 74 port: 9200 75 initialDelaySeconds: 5 76 periodSeconds: 10 77 timeoutSeconds: 3 78 failureThreshold: 30 79 80 ports: 81 - name: rest-api 82 containerPort: 9200 83 - name: transport 84 containerPort: 9300 85 - name: metrics 86 containerPort: 9600 87 88 env: 89 - name: MY_POD_NAME 90 valueFrom: 91 fieldRef: 92 fieldPath: metadata.name 93 - name: BITNAMI_DEBUG 94 value: "true" 95 - name: ELASTICSEARCH_CLUSTER_NAME 96 value: "$(KB_CLUSTER_NAME)" 97 - name: ELASTICSEARCH_IS_DEDICATED_NODE # is dedicated node 98 value: "no" 99 - name: ELASTICSEARCH_NODE_ROLES # node type when behaving as a 'dedicated node' 100 value: "" 101 - name: ELASTICSEARCH_TRANSPORT_PORT_NUMBER 102 value: "9300" 103 - name: ELASTICSEARCH_HTTP_PORT_NUMBER 104 value: "9200" 105 - name: ELASTICSEARCH_CLUSTER_HOSTS 106 value: "" 107 - name: ELASTICSEARCH_TOTAL_NODES 108 value: "1" 109 - name: ELASTICSEARCH_CLUSTER_MASTER_HOSTS 110 value: "$(KB_CLUSTER_NAME)-$(KB_COMP_NAME)-0" 111 - name: ELASTICSEARCH_ENABLE_SECURITY 112 value: "false" 113 - name: ELASTICSEARCH_MINIMUM_MASTER_NODES 114 value: "1" 115 - name: ELASTICSEARCH_ADVERTISED_HOSTNAME 116 value: "$(KB_CLUSTER_NAME)-$(KB_COMP_NAME)" 117 - name: ELASTICSEARCH_HEAP_SIZE 118 value: "128m" 119 120 volumeMounts: 121 - mountPath: /usr/share/elasticsearch/data 122 name: data 123 - mountPath: /usr/share/elasticsearch/config/elasticsearch.yaml 124 subPath: elasticsearch.yaml 125 name: elasticsearch-config 126 127 # https://discuss.elastic.co/t/kibana-not-able-to-connect-to-elastic-master-in-kubernetes-from-elastic-helm/185759/5 128 - name: elasticsearch-master-graceful-termination-handler 129 imagePullPolicy: IfNotPresent 130 command: 131 - "sh" 132 - -c 133 - | 134 #!/usr/bin/env bash 135 set -e 136 137 http () { 138 local path="${1}" 139 if [ -n "${USERNAME}" ] && [ -n "${PASSWORD}" ]; then 140 BASIC_AUTH="-u ${USERNAME}:${PASSWORD}" 141 else 142 BASIC_AUTH='' 143 fi 144 curl -XGET -s -k --fail ${BASIC_AUTH} https://$(KB_CLUSTER_NAME)-$(KB_COMP_NAME)-headless:9200:${path} 145 } 146 147 cleanup () { 148 while true ; do 149 local master="$(http "/_cat/master?h=node" || echo "")" 150 if [[ $master == "$(KB_CLUSTER_NAME)-$(KB_COMP_NAME)"* && $master != "${NODE_NAME}" ]]; then 151 echo "This node is not master." 152 break 153 fi 154 echo "This node is still master, waiting gracefully for it to step down" 155 sleep 1 156 done 157 158 exit 0 159 } 160 161 trap cleanup TERM 162 163 sleep infinity & 164 wait $! 165 166 - name: metrics 167 monitor: 168 builtIn: false 169 exporterConfig: 170 scrapePath: /metrics 171 scrapePort: 9114 # Source: elasticsearch/templates/metrics/deployment.yaml 172 characterType: elasticsearch-metrics 173 workloadType: Stateless 174 service: 175 ports: 176 - name: metrics 177 port: 9114 178 targetPort: metrics 179 180 podSpec: 181 containers: 182 - name: metrics 183 184 imagePullPolicy: "{{ .Values.image.pullPolicy }}" 185 securityContext: 186 privileged: true 187 runAsUser: 1001 188 command: 189 [] 190 args: 191 - --es.uri=http://$(KB_CLUSTER_NAME)-elasticsearch:9200 192 - --es.all 193 - --es.ssl-skip-verify 194 - --es.indices 195 - --es.shards 196 env: 197 startupProbe: 198 tcpSocket: 199 port: 9114 200 periodSeconds: 10 201 timeoutSeconds: 5 202 failureThreshold: 20 203 successThreshold: 1 204 initialDelaySeconds: 10 205 livenessProbe: 206 initialDelaySeconds: 60 207 periodSeconds: 10 208 timeoutSeconds: 5 209 successThreshold: 1 210 failureThreshold: 5 211 httpGet: 212 path: /metrics 213 port: metrics 214 readinessProbe: 215 initialDelaySeconds: 5 216 periodSeconds: 10 217 timeoutSeconds: 1 218 successThreshold: 1 219 failureThreshold: 5 220 httpGet: 221 path: /metrics 222 port: metrics 223 ports: 224 - name: metrics 225 containerPort: 9114