Skip to content

Commit

Permalink
[deployment] add Digitalocean k8s Deploy Config
Browse files Browse the repository at this point in the history
  • Loading branch information
welbon committed Jul 5, 2024
1 parent ba505fe commit a96df94
Show file tree
Hide file tree
Showing 2 changed files with 185 additions and 0 deletions.
111 changes: 111 additions & 0 deletions kube/elasticsearch/elasticsearch-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# elasticsearch-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: elasticsearch
spec:
replicas: 1
selector:
matchLabels:
app: elasticsearch
template:
metadata:
labels:
app: elasticsearch
spec:
initContainers:
- name: init-permissions
image: busybox
command: [ "sh", "-c", "chown -R 1000:1000 /usr/share/elasticsearch/data" ]
volumeMounts:
- name: es-data
mountPath: /usr/share/elasticsearch/data
containers:
- name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0
resources:
requests:
cpu: "1"
memory: "4Gi"
limits:
cpu: "2"
memory: "6Gi"
ports:
- containerPort: 9200
name: http
- containerPort: 9300
name: transport
volumeMounts:
- name: es-data
mountPath: /usr/share/elasticsearch/data
- name: elasticsearch-config
mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
subPath: elasticsearch.yml
env:
- name: discovery.type
value: single-node
- name: ELASTIC_USERNAME
valueFrom:
secretKeyRef:
name: elasticsearch
key: username
- name: ELASTIC_PASSWORD
valueFrom:
secretKeyRef:
name: elasticsearch
key: password
volumes:
- name: es-data
persistentVolumeClaim:
claimName: es-pvc
- name: elasticsearch-config
configMap:
name: elasticsearch-config
---
# Elasticsearch Configuration
apiVersion: v1
kind: ConfigMap
metadata:
name: elasticsearch-config
data:
elasticsearch.yml: |
xpack.security.enabled: true
xpack.license.self_generated.type: basic
network.host: 0.0.0.0
---
# Elasticsearch Persistent Volume
apiVersion: v1
kind: PersistentVolume
metadata:
name: es-pv
spec:
capacity:
storage: 80Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /mnt/data/es
---
# Elasticsearch Persistent Volume Claim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: es-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 80Gi

---
# Elasticsearch Service
apiVersion: v1
kind: Service
metadata:
name: elasticsearch
spec:
ports:
- port: 9200
selector:
app: elasticsearch
74 changes: 74 additions & 0 deletions kube/elasticsearch/kibana-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# kibana-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: kibana
spec:
replicas: 1
selector:
matchLabels:
app: kibana
template:
metadata:
labels:
app: kibana
spec:
containers:
- name: kibana
image: docker.elastic.co/kibana/kibana:7.17.0
resources:
requests:
cpu: "0.5"
memory: "2Gi"
limits:
cpu: "1"
memory: "2Gi"
ports:
- containerPort: 5601
volumeMounts:
- name: kibana-config
mountPath: /usr/share/kibana/config/kibana.yml
subPath: kibana.yml
env:
- name: ELASTICSEARCH_HOSTS
value: "http://elasticsearch:9200"
- name: ES_USERNAME
valueFrom:
secretKeyRef:
name: elasticsearch
key: username
- name: ES_PASSWORD
valueFrom:
secretKeyRef:
name: elasticsearch
key: password
volumes:
- name: kibana-config
configMap:
name: kibana-config
---
apiVersion: v1
kind: ConfigMap
metadata:
name: kibana-config
data:
kibana.yml: |
server.name: kibana
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://elasticsearch:9200"]
elasticsearch.username: "${ES_USERNAME}"
elasticsearch.password: "${ES_PASSWORD}"
---
apiVersion: v1
kind: Service
metadata:
name: kibana
spec:
type: NodePort
selector:
app: kibana
ports:
- protocol: TCP
port: 5601
targetPort: 5601
nodePort: 31000

0 comments on commit a96df94

Please sign in to comment.