Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
556 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,258 @@ | ||
# Source: elasticsearch/templates/poddisruptionbudget.yaml | ||
apiVersion: policy/v1beta1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: "elasticsearch-master-pdb" | ||
namespace: m4oao | ||
spec: | ||
maxUnavailable: 1 | ||
selector: | ||
matchLabels: | ||
app: "elasticsearch-master" | ||
--- | ||
# Source: elasticsearch/templates/service.yaml | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: elasticsearch-master | ||
namespace: m4oao | ||
labels: | ||
heritage: "Helm" | ||
chart: "elasticsearch" | ||
app: "elasticsearch-master" | ||
annotations: | ||
{} | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
chart: "elasticsearch" | ||
app: "elasticsearch-master" | ||
ports: | ||
- name: http | ||
protocol: TCP | ||
port: 9200 | ||
- name: transport | ||
protocol: TCP | ||
port: 9300 | ||
--- | ||
# Source: elasticsearch/templates/service.yaml | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: elasticsearch-master-headless | ||
namespace: m4oao | ||
labels: | ||
heritage: "Helm" | ||
chart: "elasticsearch" | ||
app: "elasticsearch-master" | ||
annotations: | ||
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" | ||
spec: | ||
clusterIP: None # This is needed for statefulset hostnames like elasticsearch-0 to resolve | ||
# Create endpoints also if the related pod isn't ready | ||
publishNotReadyAddresses: true | ||
selector: | ||
app: "elasticsearch-master" | ||
ports: | ||
- name: http | ||
port: 9200 | ||
- name: transport | ||
port: 9300 | ||
--- | ||
# Source: elasticsearch/templates/statefulset.yaml | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: elasticsearch-master | ||
namespace: m4oao | ||
labels: | ||
heritage: "Helm" | ||
chart: "elasticsearch" | ||
app: "elasticsearch-master" | ||
annotations: | ||
esMajorVersion: "8" | ||
spec: | ||
serviceName: elasticsearch-master-headless | ||
selector: | ||
matchLabels: | ||
app: "elasticsearch-master" | ||
replicas: 1 | ||
podManagementPolicy: Parallel | ||
updateStrategy: | ||
type: RollingUpdate | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: elasticsearch-master | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 30Gi | ||
template: | ||
metadata: | ||
name: "elasticsearch-master" | ||
labels: | ||
heritage: "Helm" | ||
chart: "elasticsearch" | ||
app: "elasticsearch-master" | ||
annotations: | ||
|
||
spec: | ||
securityContext: | ||
fsGroup: 1000 | ||
runAsUser: 1000 | ||
affinity: | ||
podAntiAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
- labelSelector: | ||
matchExpressions: | ||
- key: app | ||
operator: In | ||
values: | ||
- "elasticsearch-master" | ||
topologyKey: kubernetes.io/hostname | ||
terminationGracePeriodSeconds: 120 | ||
volumes: | ||
enableServiceLinks: true | ||
initContainers: | ||
- name: configure-sysctl | ||
securityContext: | ||
runAsUser: 0 | ||
privileged: true | ||
image: "docker.elastic.co/elasticsearch/elasticsearch:8.0.0-SNAPSHOT" | ||
imagePullPolicy: "IfNotPresent" | ||
command: ["sysctl", "-w", "vm.max_map_count=262144"] | ||
resources: | ||
{} | ||
|
||
containers: | ||
- name: "elasticsearch" | ||
securityContext: | ||
capabilities: | ||
drop: | ||
- ALL | ||
runAsNonRoot: true | ||
runAsUser: 1000 | ||
image: "docker.elastic.co/elasticsearch/elasticsearch:8.0.0-SNAPSHOT" | ||
imagePullPolicy: "IfNotPresent" | ||
readinessProbe: | ||
exec: | ||
command: | ||
- sh | ||
- -c | ||
- | | ||
#!/usr/bin/env bash -e | ||
# If the node is starting up wait for the cluster to be ready (request params: "wait_for_status=green&timeout=1s" ) | ||
# Once it has started only check that the node itself is responding | ||
START_FILE=/tmp/.es_start_file | ||
http () { | ||
local path="${1}" | ||
local args="${2}" | ||
set -- -XGET -s | ||
if [ "$args" != "" ]; then | ||
set -- "$@" $args | ||
fi | ||
if [ -n "${ELASTIC_USERNAME}" ] && [ -n "${ELASTIC_PASSWORD}" ]; then | ||
set -- "$@" -u "${ELASTIC_USERNAME}:${ELASTIC_PASSWORD}" | ||
fi | ||
curl --output /dev/null -k "$@" "http://127.0.0.1:9200${path}" | ||
} | ||
if [ -f "${START_FILE}" ]; then | ||
echo 'Elasticsearch is already running, lets check the node is healthy' | ||
HTTP_CODE=$(http "/" "-w %{http_code}") | ||
RC=$? | ||
if [[ ${RC} -ne 0 ]]; then | ||
echo "curl --output /dev/null -k -XGET -s -w '%{http_code}' \${BASIC_AUTH} http://127.0.0.1:9200/ failed with RC ${RC}" | ||
exit ${RC} | ||
fi | ||
# ready if HTTP code 200, 503 is tolerable if ES version is 6.x | ||
if [[ ${HTTP_CODE} == "200" ]]; then | ||
exit 0 | ||
elif [[ ${HTTP_CODE} == "503" && "8" == "6" ]]; then | ||
exit 0 | ||
else | ||
echo "curl --output /dev/null -k -XGET -s -w '%{http_code}' \${BASIC_AUTH} http://127.0.0.1:9200/ failed with HTTP code ${HTTP_CODE}" | ||
exit 1 | ||
fi | ||
else | ||
echo 'Waiting for elasticsearch cluster to become ready (request params: "wait_for_status=green&timeout=1s" )' | ||
if http "/_cluster/health?wait_for_status=green&timeout=1s" "--fail" ; then | ||
touch ${START_FILE} | ||
exit 0 | ||
else | ||
echo 'Cluster is not yet ready (request params: "wait_for_status=green&timeout=1s" )' | ||
exit 1 | ||
fi | ||
fi | ||
failureThreshold: 3 | ||
initialDelaySeconds: 10 | ||
periodSeconds: 10 | ||
successThreshold: 3 | ||
timeoutSeconds: 5 | ||
ports: | ||
- name: http | ||
containerPort: 9200 | ||
- name: transport | ||
containerPort: 9300 | ||
resources: | ||
limits: | ||
cpu: 1000m | ||
memory: 2Gi | ||
requests: | ||
cpu: 1000m | ||
memory: 2Gi | ||
env: | ||
- name: node.name | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: cluster.initial_master_nodes | ||
value: "elasticsearch-master-0,elasticsearch-master-1,elasticsearch-master-2," | ||
- name: discovery.seed_hosts | ||
value: "elasticsearch-master-headless" | ||
- name: cluster.name | ||
value: "elasticsearch" | ||
- name: network.host | ||
value: "0.0.0.0" | ||
- name: ES_JAVA_OPTS | ||
value: "-Xmx1g -Xms1g" | ||
- name: node.data | ||
value: "true" | ||
- name: node.ingest | ||
value: "true" | ||
- name: node.master | ||
value: "true" | ||
volumeMounts: | ||
- name: "elasticsearch-master" | ||
mountPath: /usr/share/elasticsearch/data | ||
--- | ||
# Source: elasticsearch/templates/test/test-elasticsearch-health.yaml | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: "gjbkt-test" | ||
namespace: m4oao | ||
annotations: | ||
"helm.sh/hook": test-success | ||
spec: | ||
securityContext: | ||
fsGroup: 1000 | ||
runAsUser: 1000 | ||
containers: | ||
- name: "ivgtl-test" | ||
image: "docker.elastic.co/elasticsearch/elasticsearch:8.0.0-SNAPSHOT" | ||
imagePullPolicy: "IfNotPresent" | ||
command: | ||
- "sh" | ||
- "-c" | ||
- | | ||
#!/usr/bin/env bash -e | ||
curl -XGET --fail 'elasticsearch-master:9200/_cluster/health?wait_for_status=green&timeout=1s' | ||
restartPolicy: Never |
Oops, something went wrong.