Skip to content

Commit 1aacff1

Browse files
committed
Logging POC initial commit
1 parent 977a7ff commit 1aacff1

File tree

4 files changed

+198
-0
lines changed

4 files changed

+198
-0
lines changed

logging/es-config.yaml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: elasticsearch
5+
labels:
6+
app: elasticsearch
7+
spec:
8+
selector:
9+
app: elasticsearch
10+
clusterIP: None
11+
ports:
12+
- port: 9200
13+
name: rest
14+
- port: 9300
15+
name: inter-node
16+
---
17+
apiVersion: apps/v1
18+
kind: StatefulSet
19+
metadata:
20+
name: es-cluster
21+
spec:
22+
serviceName: elasticsearch
23+
replicas: 3
24+
selector:
25+
matchLabels:
26+
app: elasticsearch
27+
template:
28+
metadata:
29+
labels:
30+
app: elasticsearch
31+
spec:
32+
containers:
33+
- name: elasticsearch
34+
image: docker.elastic.co/elasticsearch/elasticsearch:7.5.0
35+
resources:
36+
limits:
37+
cpu: 1000m
38+
requests:
39+
cpu: 100m
40+
ports:
41+
- containerPort: 9200
42+
name: rest
43+
protocol: TCP
44+
- containerPort: 9300
45+
name: inter-node
46+
protocol: TCP
47+
volumeMounts:
48+
- name: data
49+
mountPath: /usr/share/elasticsearch/data
50+
env:
51+
- name: cluster.name
52+
value: k8s-logs
53+
- name: node.name
54+
valueFrom:
55+
fieldRef:
56+
fieldPath: metadata.name
57+
- name: discovery.seed_hosts
58+
value: "es-cluster-0.elasticsearch,es-cluster-1.elasticsearch,es-cluster-2.elasticsearch"
59+
- name: cluster.initial_master_nodes
60+
value: "es-cluster-0,es-cluster-1,es-cluster-2"
61+
- name: ES_JAVA_OPTS
62+
value: "-Xms512m -Xmx512m"
63+
initContainers:
64+
- name: fix-permissions
65+
image: busybox
66+
command: ["sh", "-c", "chown -R 1000:1000 /usr/share/elasticsearch/data"]
67+
securityContext:
68+
privileged: true
69+
volumeMounts:
70+
- name: data
71+
mountPath: /usr/share/elasticsearch/data
72+
- name: increase-vm-max-map
73+
image: busybox
74+
command: ["sysctl", "-w", "vm.max_map_count=262144"]
75+
securityContext:
76+
privileged: true
77+
- name: increase-fd-ulimit
78+
image: busybox
79+
command: ["sh", "-c", "ulimit -n 65536"]
80+
securityContext:
81+
privileged: true
82+
volumeClaimTemplates:
83+
- metadata:
84+
name: data
85+
labels:
86+
app: elasticsearch
87+
spec:
88+
accessModes: [ "ReadWriteOnce" ]
89+
# storageClassName: ""
90+
resources:
91+
requests:
92+
storage: 3Gi

logging/fd-configmap.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: fluentd-config
5+
labels:
6+
kubernetes.io/cluster-service: "true"
7+
data:
8+
fluent.conf: |
9+
<match fluent.**>
10+
@type null
11+
</match>
12+
13+
<source>
14+
@type tail
15+
@id tail_marklogic_logs
16+
format none
17+
path /var/opt/MarkLogic/Logs/*
18+
pos_file /tmp/log/ml-logs.log.pos
19+
path_key log_file
20+
tag marklogic.logs
21+
read_from_head true
22+
<parse>
23+
@type none
24+
time_key @timestamp
25+
time_format %Y-%m-%dT%H:%M:%S.%N%z
26+
keep_time_key true
27+
</parse>
28+
</source>
29+
30+
<filter marklogic.logs>
31+
@type record_transformer
32+
enable_ruby true
33+
<record>
34+
# overwrite full path to file name
35+
log_file ${File.basename(record["log_file"])}
36+
</record>
37+
</filter>
38+
39+
<match marklogic.logs>
40+
@type elasticsearch
41+
host elasticsearch.default.svc.cluster.local
42+
port 9200
43+
user admin
44+
password admin
45+
index_name fluentd.${tag}
46+
include_timestamp true
47+
utc_index false
48+
time_key_format "%Y-%m-%dT%H:%M:%S.%N%z"
49+
time_key time
50+
logstash_format true
51+
logstash_prefix marklogic.logs
52+
path_key out/${log_file}
53+
flush_interval 1s
54+
</match>

logging/kibana-config.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: kibana
5+
labels:
6+
app: kibana
7+
spec:
8+
ports:
9+
- port: 5601
10+
selector:
11+
app: kibana
12+
---
13+
apiVersion: apps/v1
14+
kind: Deployment
15+
metadata:
16+
name: kibana
17+
labels:
18+
app: kibana
19+
spec:
20+
replicas: 1
21+
selector:
22+
matchLabels:
23+
app: kibana
24+
template:
25+
metadata:
26+
labels:
27+
app: kibana
28+
spec:
29+
containers:
30+
- name: kibana
31+
image: docker.elastic.co/kibana/kibana:7.5.0
32+
resources:
33+
limits:
34+
cpu: 1000m
35+
requests:
36+
cpu: 100m
37+
env:
38+
- name: ELASTICSEARCH_URL
39+
value: http://elasticsearch:9200
40+
ports:
41+
- containerPort: 5601

logging/reset.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
minikube delete
2+
minikube start --driver=docker -n=1
3+
4+
kubectl apply -f logging/es-config.yaml
5+
kubectl apply -f logging/kibana-config.yaml
6+
kubectl port-forward kibana-7f4cc47bkw4d-db7dn 5601:5601
7+
8+
echo "=====Loading marklogc images to minikube cluster"
9+
minikube image load marklogic-centos/marklogic-server-centos:10-internal
10+
11+
helm install ml ./charts/ -f values.yaml # Use local charts for helm install

0 commit comments

Comments
 (0)