Join us
@vvickky007 ăť Nov 11,2021 ăť 4 min read ăť 557 views ăť Originally posted on faun.pub
Quick Code to deploy ELK stack (Elasticsearch, Logstash, Kibana) and supporting services on Kubernetes Controlled Docker platform.
Click Here to access code.
Docker images hosted at official âdocker.elastic.coâ are valid and used for ELK deployments. Below are the docker repo:
Target Architecture Diagram
Installing via Ansible
Clone the âQuickELKâ project, ensure that all Prerequisite are in place. Select a kubernetes namespace where this stack is required to be created. Namespace will be automatically created if not exist. Select a helm deployment name for the stack. Run below command from inside the clone directory.
# ansible-playbook main.yaml -e namespace=<Namespace for Deployment> -e stackname=<Name of Stack> -e chartpath=elk-stack
Example:
# ansible-playbook main.yaml -e namespace=ezsinam1 -e stackname=mystack -e chartpath=elk-stack
Output:
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match âallâ
PLAY [localhost] *****************************************************************************************************************************************************
TASK [Check the Namespace Exist.] ************************************************************************************************************************************
fatal: [localhost]: FAILED! => {âchangedâ: true, âcmdâ: âkubectl get ns ezsinam1â, âdeltaâ: â0:00:00.136403â, âendâ: â2021â10â27 14:11:27.742760â, âmsgâ: ânon-zero return codeâ, ârcâ: 1, âstartâ: â2021â10â27 14:11:27.606357â, âstderrâ: âError from server (NotFound): namespaces \âezsinam1\â not foundâ, âstderr_linesâ: [âError from server (NotFound): namespaces \âezsinam1\â not foundâ], âstdoutâ: ââ, âstdout_linesâ: []}
TASK [Create Namespace if NOT exists.] *******************************************************************************************************************************
changed: [localhost]
TASK [debug] *********************************************************************************************************************************************************
ok: [localhost] => {
âns.stdout_linesâ: [
ânamespace/ezsinam1 createdâ
]
}
TASK [Deploy the ELK Stack.] *****************************************************************************************************************************************
changed: [localhost]
TASK [debug] *********************************************************************************************************************************************************
ok: [localhost] => {
âchart.stdout_linesâ: [
âNAME: mystackâ,
âLAST DEPLOYED: Wed Oct 27 14:11:28 2021â,
âNAMESPACE: ezsinam1â,
âSTATUS: deployedâ,
âREVISION: 1â,
âNOTES:â,
â1. Get the application URL by running these commands:â
]
}
PLAY RECAP ***********************************************************************************************************************************************************
localhost : ok=4 changed=2 unreachable=0 failed=1
0
Installing via Helm
Clone the âQuickELKâ project, ensure that all Prerequisites are in place. Select a kubernetes namespace where this stack is required to be created. Namespace will be automatically created if not exist. Select a helm deployment name for the stack. Run below command from inside the clone directory.
# helm install <Stack Name> elk-stack â namespace <Namespace for Deployment> â create-namespace
Installing Specific ELK stack Release via Helm/Ansible
Update file âELK/elk-stack/Chart.yamlâ, value of key âappVersionâ to the specific version of ELK stack. Presently we have configured entire stack installation from version â6.8.20â.
apiVersion: v2
appVersion: 6.8.20 # Update Specific version of ELK stack, Automatically all components will be installed with selected version.
âŚ
âŚ
Installation Validation via Kubectl
Run below command for deployment validation, provide the namespace provided in previous step
# kubectl get all -n <Namespace for Deployment>
Example:
# kubectl get all -n ezsinam1
Output:
NAME READY STATUS RESTARTS AGE
pod/elasticsearch-logging-0 1/1 Running 0 4m7s
pod/elasticsearch-logging-1 1/1 Running 0 4m7s
pod/elasticsearch-logging-2 1/1 Running 0 4m7s
pod/filebeat-4kc6r 1/1 Running 0 4m7s
pod/filebeat-5b9pz 1/1 Running 0 4m7s
pod/filebeat-cxwpj 1/1 Running 0 4m7s
pod/filebeat-fqth7 1/1 Running 0 4m7s
pod/filebeat-mgtts 1/1 Running 0 4m7s
pod/filebeat-rdgx8 1/1 Running 0 4m7s
pod/filebeat-rgxmc 1/1 Running 0 4m7s
pod/kibana-logging-58db4c758f-gbb6k 1/1 Running 2 4m7s
pod/logstash-deployment-5b4879b9f7â4zwnr 1/1 Running 0 4m7s
pod/metricbeat-6kp4k 1/1 Running 0 4m7s
pod/metricbeat-dqf7c 1/1 Running 0 4m7s
pod/metricbeat-gj78v 1/1 Running 0 4m7s
pod/metricbeat-kgbfg 1/1 Running 0 4m7s
pod/metricbeat-ngb9q 1/1 Running 0 4m7s
pod/metricbeat-tw7zb 1/1 Running 0 4m7s
pod/metricbeat-x4tv4 1/1 Running 0 4m7s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/elasticsearch-logging ClusterIP 10.108.33.4 <none> 9200/TCP 4m7s
service/kibana-logging LoadBalancer 10.108.8.123 10.64.109.113 5601:30316/TCP 4m7s
service/logstash-service ClusterIP 10.105.7.173 <none> 5044/TCP 4m7s
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
daemonset.apps/filebeat 7 7 7 7 7 <none> 4m7s
daemonset.apps/metricbeat 7 7 7 7 7 <none> 4m7s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/kibana-logging 1/1 1 1 4m7s
deployment.apps/logstash-deployment 1/1 1 1 4m7s
NAME DESIRED CURRENT READY AGE
replicaset.apps/kibana-logging-58db4c758f 1 1 1 4m7s
replicaset.apps/logstash-deployment-5b4879b9f7 1 1 1 4m7s
NAME READY AGE
statefulset.apps/elasticsearch-logging 3/3 4m7s
Integration Validation
To validate indeces for ElasticSearch to validate Integration with filebeat, logstash and metricbeat.
# curl <elasticsearch-logging clsuetrIP Service IP>:9200/_cat/indices
Example:
# curl 10.108.33.4:9200/_cat/indices
yellow open logstash-2021.07.08 sxXdBTWZSt6dIaDB4s_QLQ 5 1 218 0 388.2kb 388.2kb
yellow open logstash-2021.08.05 H37edbWUT4enUQfF â -t_A 5 1 6 0 62.7kb 62.7kb
yellow open logstash-2021.09.05 vuQnUkGMTLWy85c9LSr-SA 5 1 681 0 458.8kb 458.8kb
yellow open logstash-2021.07.05 Im1jancJQlWfwUiC8h0vKw 5 1 717 0 773.6kb 773.6kb
yellow open logstash-2021.07.02 b9AFqpcTTkW5nmqoqaCsig 5 1 27535 0 6.6mb 6.6mb
yellow open metricbeat-6.8.20â2021.10.27 iiVkm-lMQwKT6ElVwpukGw 5 1 17020 0 12.9mb 12.9mb
âŚ
âŚ
MetricBeat and LogStash indices should be visible. Also you can select any index and check data using below command.
Example:
# curl 10.108.33.4:9200/logstash-2021.07.08/_search
Installation Cleanup
To delete entire deployment provide kubernetes namespace where this stack is created. Namespace will be automatically deleted. Also provide helm deployment name of the created stack.
Run below command.
# ansible-playbook clean.yaml -e namespace=<Namespace of Deployment> -e stackname=<Name of Deployed Stack>
Example:
# ansible-playbook clean.yaml -e namespace=ezsinam1 -e stackname=mystack
Output:
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match âallâ
PLAY [localhost] *****************************************************************************************************************************************************
TASK [Remove the ELK Stack.] *****************************************************************************************************************************************
changed: [localhost]
TASK [debug] *********************************************************************************************************************************************************
ok: [localhost] => {
âchart.stdout_linesâ: [
ârelease \âmystack\â uninstalledâ
]
}
TASK [Delete the Namespace.] *****************************************************************************************************************************************
ansible-playbook clean.yaml -e namespace=ezsinam1 -e stackname=mystackchanged: [localhost]
TASK [debug] *********************************************************************************************************************************************************
ok: [localhost] => {
âns.stdout_linesâ: [
ânamespace \âezsinam1\â deletedâ
]
}
PLAY RECAP ***********************************************************************************************************************************************************
localhost : ok=4 changed=2 unreachable=0 failed=0
Join other developers and claim your FAUN account now!
Influence
Total Hits
Posts
Only registered users can post comments. Please, login or signup.