Skip to content

Instantly share code, notes, and snippets.

@drewr
Last active April 29, 2019 21:58
Show Gist options
  • Save drewr/4bdc3540ecb6c4ddf8058c59692ea7a8 to your computer and use it in GitHub Desktop.
Save drewr/4bdc3540ecb6c4ddf8058c59692ea7a8 to your computer and use it in GitHub Desktop.

After you've created a GKE cluster, run:

kubectl apply -f <(curl -s https://gist.githubusercontent.com/drewr/4bdc3540ecb6c4ddf8058c59692ea7a8/raw/es-k8s.yaml)`

That will give you a single-node instance accessible via elasticsearch:9200 around your cluster.

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: es-data-claim
annotations:
volume.alpha.kubernetes.io/storage-class: default
spec:
accessModes: [ReadWriteOnce]
resources:
requests:
storage: 2Gi
---
apiVersion: v1
kind: Service
metadata:
name: elasticsearch
labels:
name: elasticsearch
spec:
ports:
- port: 9200
selector:
app: elasticsearch
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: elasticsearch
spec:
replicas: 1
revisionHistoryLimit: 2
strategy:
type: Recreate
template:
metadata:
labels:
app: elasticsearch
spec:
containers:
- name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.1
imagePullPolicy: Always
ports:
- containerPort: 9200
env:
- name: ES_JAVA_OPTS
value: "-Xms128m -Xmx128m"
- name: discovery.type
value: single-node
readinessProbe:
httpGet:
path: /
port: 9200
initialDelaySeconds: 30
timeoutSeconds: 3
livenessProbe:
httpGet:
path: /
port: 9200
initialDelaySeconds: 30
timeoutSeconds: 3
resources:
requests:
memory: 20Mi
cpu: 200m
limits:
memory: 750Mi
cpu: 1000m
volumeMounts:
- mountPath: /usr/share/elasticsearch/data
name: es-data
securityContext:
runAsUser: 1000
fsGroup: 1000
volumes:
- name: es-data
persistentVolumeClaim:
claimName: es-data-claim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment