Skip to content
This repository was archived by the owner on May 16, 2023. It is now read-only.

Commit 2f4dd45

Browse files
framsouzajmlrt
andauthored
[filebeat] using https to connect to elasticsearch (#1627)
* Adding support to Ingress networking.k8s.io/v1 * Adjusting ES service name * Removing ingress typo & adjusting python test * Adjusting python tests to use the new ingress version * fixing conflict * Adding support to kubernetes ingress v1 & ClassName * Adding reformatted files * fixing conflict * Adding ClassName & Pathtype on ingress settings * Performing syntax adjustments and removing comments * adjusting settings to connect into elasticsearch using https * adjusting tests * adjusting tests * adjusting tests * adding body, username, password and increasing version upgraded * fix goss syntax Co-authored-by: jmlrt <8582351+jmlrt@users.noreply.github.com>
1 parent cea1149 commit 2f4dd45

File tree

8 files changed

+74
-28
lines changed

8 files changed

+74
-28
lines changed

filebeat/examples/default/test/goss.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ user:
2525
gid: 1000
2626

2727
http:
28-
http://elasticsearch-master:9200/_cat/indices:
28+
https://elasticsearch-master:9200/_cat/indices:
2929
status: 200
3030
timeout: 2000
31+
allow-insecure: true
3132
username: "{{ .Env.ELASTICSEARCH_USERNAME }}"
3233
password: "{{ .Env.ELASTICSEARCH_PASSWORD }}"
3334
body:
@@ -45,4 +46,4 @@ command:
4546
cd /usr/share/filebeat && filebeat test output:
4647
exit-status: 0
4748
stdout:
48-
- "elasticsearch: http://elasticsearch-master:9200"
49+
- "elasticsearch: https://elasticsearch-master:9200"

filebeat/examples/deployment/test/goss.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
http:
2-
http://elasticsearch-master:9200/_cat/indices:
2+
https://elasticsearch-master:9200/_cat/indices:
33
status: 200
4+
allow-insecure: true
45
timeout: 2000
56
username: "{{ .Env.ELASTICSEARCH_USERNAME }}"
67
password: "{{ .Env.ELASTICSEARCH_PASSWORD }}"

filebeat/examples/oss/test/goss.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ user:
1515
gid: 1000
1616

1717
http:
18-
http://elasticsearch-master:9200/_cat/indices:
18+
https://elasticsearch-master:9200/_cat/indices:
19+
allow-insecure: true
1920
status: 200
2021
timeout: 2000
2122
username: "{{ .Env.ELASTICSEARCH_USERNAME }}"

filebeat/examples/oss/values.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@ daemonset:
1515
logs_path: "/var/log/containers/"
1616
output.elasticsearch:
1717
host: '${NODE_NAME}'
18-
hosts: "elasticsearch-master:9200"
18+
hosts: ["https://elasticsearch-master:9200"]
1919
username: '${ELASTICSEARCH_USERNAME}'
2020
password: '${ELASTICSEARCH_PASSWORD}'
2121
index: "filebeat-oss-%{[agent.version]}-%{+yyyy.MM.dd}"
22+
ssl.certificate_authorities:
23+
- /usr/share/filebeat/certs/ca.crt
2224
setup.ilm.enabled: false
2325
setup.template.name: "filebeat"
2426
setup.template.pattern: "filebeat-oss-*"
27+
secretMounts:
28+
- name: elasticsearch-master-certs
29+
secretName: elasticsearch-master-certs
30+
path: /usr/share/filebeat/certs

filebeat/examples/upgrade/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ include ../../../helpers/examples.mk
44

55
CHART := filebeat
66
RELEASE := helm-filebeat-upgrade
7-
# K8S 1.22 doesn't support anymore rbac.authorization.k8s.io/v1beta1 used in 7.9.0
8-
FROM := 7.10.0
7+
# upgrade from versions before 7.17.1 isn't compatible with 8.x
8+
FROM := 7.17.1
99

1010
install:
1111
../../../helpers/upgrade.sh --chart $(CHART) --release $(RELEASE) --from $(FROM)

filebeat/examples/upgrade/test/goss.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ user:
2525
gid: 1000
2626

2727
http:
28-
http://upgrade-master:9200/_cat/indices:
28+
https://upgrade-master:9200/_cat/indices:
2929
status: 200
30+
allow-insecure: true
3031
timeout: 2000
3132
body:
3233
- "filebeat-8.1.0"
34+
username: "{{ .Env.ELASTICSEARCH_USERNAME }}"
35+
password: "{{ .Env.ELASTICSEARCH_PASSWORD }}"
3336

3437
file:
3538
/usr/share/filebeat/filebeat.yml:
@@ -42,4 +45,4 @@ command:
4245
cd /usr/share/filebeat && filebeat test output:
4346
exit-status: 0
4447
stdout:
45-
- "elasticsearch: http://upgrade-master:9200"
48+
- "elasticsearch: https://upgrade-master:9200"
Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,39 @@
1-
---
2-
daemonset:
3-
extraEnvs:
4-
- name: ELASTICSEARCH_HOSTS
5-
value: upgrade-master:9200
6-
- name: "ELASTICSEARCH_USERNAME"
7-
valueFrom:
8-
secretKeyRef:
9-
name: upgrade-master-credentials
10-
key: username
11-
- name: "ELASTICSEARCH_PASSWORD"
12-
valueFrom:
13-
secretKeyRef:
14-
name: upgrade-master-credentials
15-
key: password
1+
extraEnvs:
2+
- name: "ELASTICSEARCH_HOSTS"
3+
value: "https://upgrade-master:9200"
4+
- name: "ELASTICSEARCH_USERNAME"
5+
valueFrom:
6+
secretKeyRef:
7+
name: upgrade-master-credentials
8+
key: username
9+
- name: "ELASTICSEARCH_PASSWORD"
10+
valueFrom:
11+
secretKeyRef:
12+
name: upgrade-master-credentials
13+
key: password
14+
- name: ssl.certificate_authorities
15+
value: "/usr/share/filebeat/certs/ca.crt"
16+
filebeatConfig:
17+
filebeat.yml: |
18+
filebeat.inputs:
19+
- type: container
20+
paths:
21+
- /var/log/containers/*.log
22+
processors:
23+
- add_kubernetes_metadata:
24+
host: ${NODE_NAME}
25+
matchers:
26+
- logs_path:
27+
logs_path: "/var/log/containers/"
28+
output.elasticsearch:
29+
host: '${NODE_NAME}'
30+
hosts: '${ELASTICSEARCH_HOSTS:upgrade-master:9200}'
31+
username: '${ELASTICSEARCH_USERNAME}'
32+
password: '${ELASTICSEARCH_PASSWORD}'
33+
protocol: https
34+
ssl.certificate_authorities:
35+
- /usr/share/filebeat/certs/ca.crt
36+
secretMounts:
37+
- name: upgrade-master-certs
38+
secretName: upgrade-master-certs
39+
path: /usr/share/filebeat/certs

filebeat/values.yaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,20 @@ daemonset:
4848
4949
output.elasticsearch:
5050
host: '${NODE_NAME}'
51-
hosts: '${ELASTICSEARCH_HOSTS:elasticsearch-master:9200}'
51+
hosts: '["https://${ELASTICSEARCH_HOSTS:elasticsearch-master:9200}"]'
5252
username: '${ELASTICSEARCH_USERNAME}'
5353
password: '${ELASTICSEARCH_PASSWORD}'
54+
protocol: https
55+
ssl.certificate_authorities: ["/usr/share/filebeat/certs/ca.crt"]
5456
# Only used when updateStrategy is set to "RollingUpdate"
5557
maxUnavailable: 1
5658
nodeSelector: {}
5759
# A list of secrets and their paths to mount inside the pod
5860
# This is useful for mounting certificates for security other sensitive values
59-
secretMounts: []
61+
secretMounts:
62+
- name: elasticsearch-master-certs
63+
secretName: elasticsearch-master-certs
64+
path: /usr/share/filebeat/certs/
6065
# - name: filebeat-certificates
6166
# secretName: filebeat-certificates
6267
# path: /usr/share/filebeat/certs
@@ -117,13 +122,18 @@ deployment:
117122
118123
output.elasticsearch:
119124
host: "${NODE_NAME}"
120-
hosts: "${ELASTICSEARCH_HOSTS:elasticsearch-master:9200}"
125+
hosts: '["https://${ELASTICSEARCH_HOSTS:elasticsearch-master:9200}"]'
121126
username: "${ELASTICSEARCH_USERNAME}"
122127
password: "${ELASTICSEARCH_PASSWORD}"
128+
protocol: https
129+
ssl.certificate_authorities: ["/usr/share/filebeat/certs/ca.crt"]
123130
nodeSelector: {}
124131
# A list of secrets and their paths to mount inside the pod
125132
# This is useful for mounting certificates for security other sensitive values
126-
secretMounts: []
133+
secretMounts:
134+
- name: elasticsearch-master-certs
135+
secretName: elasticsearch-master-certs
136+
path: /usr/share/filebeat/certs/
127137
# - name: filebeat-certificates
128138
# secretName: filebeat-certificates
129139
# path: /usr/share/filebeat/certs

0 commit comments

Comments
 (0)