Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Commit 32f08f9

Browse files
Jason Schmidtdekobon
authored andcommitted
feat: add filebeat support
Fixes #4.
1 parent a6999e6 commit 32f08f9

File tree

11 files changed

+122
-19
lines changed

11 files changed

+122
-19
lines changed

pulumi/aws/README.md

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ vpc - defines and installs the VPC and subnets to use with EKS
8484
└─kic-image-build - project that builds a new KIC image
8585
└─kic-image-push - pushes KIC image built in previous step to ECR
8686
└─kic-helm-chart - deploys NGINX Ingress Controller to the EKS cluster
87-
└─demo-app - deploys a sample application to the cluster
87+
└─logstore - deploys a logstore (elasticsearch) to the EKS cluster
88+
└─logagent - deploys a logging agent (filebeat) to the EKS cluster
89+
└─demo-app - deploys a sample application to the cluster
8890
```
8991

9092
### VPC
@@ -129,8 +131,65 @@ Ingress Controller on the previously deployed EKS cluster. You may want
129131
to customize this project to allow for deploying different versions of
130132
KIC.
131133

134+
A sample config-map is provided in the Pulumi deployment code; this
135+
code will adjust the logging format to approximate the upstream
136+
NGINX KIC project which will allow for easier injestion into log
137+
storage and processing systems.
138+
139+
### Log Store
140+
141+
In the [`logstore`](./logstore) directory, you will find the Pulumi
142+
project reponsible for installing your log store. The current
143+
solution deploys
144+
[Elasticsearch and Kibana](https://www.elastic.co/elastic-stack)
145+
using the
146+
[Bitnami Elasticsearch](https://bitnami.com/stack/elasticsearch/helm)
147+
chart. This solution can be swapped for other options as desired.
148+
This application is deployed to the `logstore` namespace.
149+
150+
#### Notes
151+
In order to access the Kibana dashboard via your web browser, you will
152+
need to setup port forwarding for the kibana pod. This can be accomplished
153+
using the `kubectl` command:
154+
155+
```
156+
$ # Find the Kibana pod name
157+
$ kubectl get pods -n logstore
158+
NAME READY STATUS RESTARTS AGE
159+
elastic-coordinating-only-b76674c4c-d58rh 1/1 Running 0 61m
160+
elastic-coordinating-only-b76674c4c-sb6v7 1/1 Running 0 61m
161+
elastic-elasticsearch-data-0 1/1 Running 0 61m
162+
elastic-elasticsearch-data-1 1/1 Running 0 61m
163+
elastic-elasticsearch-ingest-589d4ddf4b-6djjz 1/1 Running 0 61m
164+
elastic-elasticsearch-ingest-589d4ddf4b-6mzmb 1/1 Running 0 61m
165+
elastic-elasticsearch-master-0 1/1 Running 0 61m
166+
elastic-elasticsearch-master-1 1/1 Running 0 61m
167+
elastic-kibana-d45db8647-ghhx2 1/1 Running 0 61m
168+
$ # Setup the port forward
169+
$ kubectl port-forward elastic-kibana-d45db8647-ghhx2 5601:5601 -n logstore
170+
Forwarding from 127.0.0.1:5601 -> 5601
171+
Forwarding from [::1]:5601 -> 5601
172+
Handling connection for 5601
173+
````
174+
175+
Additionally, you will need to load the saved object data for Kibana from
176+
the provided [`kibana-data.ndjson`](./extras/kibana/kibana-data.ndjson)
177+
which can be found in the `./extras/kibana` directory in this project. To
178+
accomplish this, go to "Stack Management -> Saved Objects" in the Kibana
179+
interface.
180+
181+
### Log Agent
182+
183+
In the [`logagent`](./logagent) directory, you will find the Pulumi
184+
project reponsible for installing your log agent. The current solution
185+
deploys [`Filebeat`](https://www.elastic.co/beats/) which connects
186+
to the logstore deployed in the previous step. This solution can be
187+
swapped for other options as desired. This application is
188+
deployed to the `logagent` namespace.
189+
190+
132191
### Demo Application
133192
134193
A simple sample application is contained in the [`demo-app`](./demo-app)
135194
directory. This project shows off how one may deploy their application
136-
to a cluster that is using KIC.
195+
to a cluster that is using KIC.

pulumi/aws/destroy.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
99
cd "${script_dir}/demo-app"
1010
pulumi --emoji destroy --yes
1111

12+
cd "${script_dir}/logagent"
13+
pulumi --emoji destroy --yes
14+
15+
cd "${script_dir}/logstore"
16+
pulumi --emoji destroy --yes
17+
1218
cd "${script_dir}/kic-helm-chart"
1319
pulumi --emoji destroy --yes
1420

@@ -25,4 +31,4 @@ cd "${script_dir}/eks"
2531
pulumi --emoji destroy --yes
2632

2733
cd "${script_dir}/vpc"
28-
pulumi --emoji destroy --yes
34+
pulumi --emoji destroy --yes

pulumi/aws/extras/kibana/kibana-data.ndjson

Lines changed: 5 additions & 0 deletions
Large diffs are not rendered by default.

pulumi/aws/kic-helm-chart/__main__.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,32 @@ def project_name_from_project_dir(dirname: str):
2727

2828
def build_chart_values(repository: dict) -> helm.ChartOpts:
2929
values: Dict[str, Dict[str, typing.Any]] = {
30-
'controller': {
31-
'healthStatus': True
32-
}
30+
'controller': {
31+
'healthStatus': True,
32+
'appprotect': {
33+
'enable': False
34+
},
35+
'config': {
36+
'name': 'nginx-config',
37+
'entries': {
38+
'log-format': '$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" $upstream_response_time $upstream_status \"$uri\" $request_length $request_time [$proxy_host] [] $upstream_addr $upstream_bytes_sent $upstream_response_time $upstream_status $request_id'
39+
}
40+
},
41+
'service': {
42+
'annotations': {
43+
'co.elastic.logs/module': 'nginx'
44+
}
45+
},
46+
'pod': {
47+
'annotations': {
48+
'co.elastic.logs/module': 'nginx'
49+
}
50+
}
51+
},
52+
'prometheus': {
53+
'create': True,
54+
'port': 9113
55+
}
3356
}
3457

3558
if 'repository_url' in repository and 'image_tag_alias' in repository:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
name: filebeat
1+
name: logagent
22
runtime:
33
name: python
44
options:
55
virtualenv: ../venv
66
config: config
7-
description: Deploys filebeat daemonset
7+
description: Deploys a log agent

pulumi/aws/filebeat/__main__.py renamed to pulumi/aws/logagent/__main__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,22 @@ def project_name_from_project_dir(dirname: str):
3838
k8s_provider = k8s.Provider(resource_name=f'ingress-setup-sample',
3939
kubeconfig=kubeconfig)
4040

41-
#ns = k8s.core.v1.Namespace(resource_name='elastic',
42-
# metadata={'name': 'elastic'},
43-
# opts=pulumi.ResourceOptions(provider=k8s_provider))
41+
ns = k8s.core.v1.Namespace(resource_name='logagent',
42+
metadata={'name': 'logagent'},
43+
opts=pulumi.ResourceOptions(provider=k8s_provider))
4444

4545
chart_values = {
4646
"daemonset": {
4747
"enabled": True,
4848
"filebeatConfig": {
49-
"filebeat.yml": "filebeat.autodiscover:\n providers:\n - type: kubernetes\n hints.enabled: true\n hints.default_config:\n type: container\n paths:\n - /var/lib/docker/containers/${data.kubernetes.container.id}/*.log\noutput.elasticsearch:\n host: '${NODE_NAME}'\n hosts: 'elasticsearch-coordinating-only.elastic.svc.cluster.local:9200'\n"
49+
"filebeat.yml": "filebeat.autodiscover:\n providers:\n - type: kubernetes\n hints.enabled: true\n hints.default_config:\n type: container\n paths:\n - /var/lib/docker/containers/${data.kubernetes.container.id}/*.log\noutput.elasticsearch:\n host: '${NODE_NAME}'\n hosts: 'elastic-coordinating-only.logstore.svc.cluster.local:9200'\n"
5050
}
5151
}
5252
}
5353

5454
chart_ops = helm.ChartOpts(
5555
chart='filebeat',
56-
# namespace=ns.metadata.name,
57-
namespace='elastic',
56+
namespace=ns.metadata.name,
5857
repo=FILEBEAT_HELM_REPO_NAME,
5958
fetch_opts=FetchOpts(repo=FILEBEAT_HELM_REPO_URL),
6059
version='7.13.2',
File renamed without changes.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
name: elastic
1+
name: logstore
22
runtime:
33
name: python
44
options:
55
virtualenv: ../venv
66
config: config
7-
description: Sets up an Elasticsearch Cluster
7+
description: Deploys a logging store

pulumi/aws/elastic/__main__.py renamed to pulumi/aws/logstore/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def project_name_from_project_dir(dirname: str):
3838
k8s_provider = k8s.Provider(resource_name=f'ingress-setup-sample',
3939
kubeconfig=kubeconfig)
4040

41-
ns = k8s.core.v1.Namespace(resource_name='elastic',
42-
metadata={'name': 'elastic'},
41+
ns = k8s.core.v1.Namespace(resource_name='logstore',
42+
metadata={'name': 'logstore'},
4343
opts=pulumi.ResourceOptions(provider=k8s_provider))
4444

4545
chart_values = {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
config:
2+
aws:profile: f5
3+
aws:region: us-west-2

0 commit comments

Comments
 (0)