Mutating Web-hook Deployment for ElasticStack injection in k8s and helm
Architecture of Top Down ElasticStack Deployment
Prerequsites
-
Ensure that you are running a Kubernetes cluster with version greater than 1.9 by issuing the command
kubectl api-versions | grep admissionregistration.k8s.io/v1beta1
The result should be
admissionregistration.k8s.io/v1beta1
-
Kuberenetes client version (kubectl) version greater than 1.12
-
The project is written using Go. Install Go for you OS by reffering the following link https://golang.org/doc/install
-
The project uses dep as the dependency management tool for Go. Install dep by the following command
go get -u github.com/golang/dep/cmd/dep
-
Docker is used to create the container. It can be installed from https://docs.docker.com/install/linux/docker-ce/ubuntu/ ( Ubuntu users ) or https://docs.docker.com/docker-for-windows/install/ ( Windows Users )
-
A Dockerhub account is required to push the MutatingWebhook Image to a central repo
-
For the mutatingwebhook to work the namespace must be injected with the following labels by using the following commands
kubectl label namespace ${namespace} namespace=${namespace} kubectl label namespace ${namespace} sidecar-injector=enabled
Building the Docker Image
To build the Docker Image issue the following command
./build
Description of resource files
- filebeatyaml.yaml :- Contains the configmap of the filebeat.yml file
- injectionConfigmap :- Contains information of the details that would be injected into the containers
- logconf.yaml :- Contains the Logstash.conf file describing the pipeline of the Logstash container
- logpath-configmap.yaml :- Contains details of the log path locations of the contains which need sidecar injection. Additionally contains any environment variables that need be added
- logstash-collector.yaml :- Main deployment of the Logstash Collector
- Logstash-service.yaml :- Expose the Logstash container
- Logstash_s3_secrets.yaml :- Secrets for aws crednetials in Logstash s3 output plugin
- logstashyaml.yaml :- Configmap containing the logstash.yml file
- mutatingwebhookConfiguration.yaml :- Contains the mutatingwebhookConfiguration
- mutatingwebhookDeployment.yaml :- Contains the mutatingwebhook Deployment
- mutatingwebhookService.yaml :- Contains the service for exposing the mutating webhook
- create-cert.sh :- Create Generate certificate suitable for use with an sidecar-injector webhook service.
All resource files are generated under the assumption of helm is being used to create the deployment
Installation