Create the infrastructure to deploy a simple website (helloworld!) with monitoring using kubernetes + prometheus + grafana.
- How to use
- Requirements for run this project
- Cloning the project
- Creating docker image to app
- Creating infrastructure with terraform
- Configuring kubeconfig
- Installing prometheus helm chart
- Installing grafana helm chart
- Integration between grafana and prometheus
- Pipeline with github actions
- Contributing
$ git clone https://github.com/AryelDevops/IA_technical_test.git
$ cd IA_technical_test
$ code . (or other ide of your preference)
$ cd app
$ docker build -t aryeldevops/hello-world-ia-prom:v1 .
$ docker build -t aryeldevops/hello-world-ia-prom:latest .
$ docker scan aryeldevops/hello-world-ia-prom:v1
$ docker push aryeldevops/hello-world-ia-prom:v1
- Replace aryeldevops/hello-world-ia-prom:(tag) by the your docker repository name
$ cd k8s_terraform/k8s-do
$ docker run -it -v $PWD:/app -w /app --entrypoint "" hashicorp/terraform:light sh
$ export AWS_ACCESS_KEY_ID=(your_id)
$ export AWS_SECRET_ACCESS_KEY=(your_secret)
$ export DO_TOKEN=(your_digitalocean_token)
$ terraform init
$ terraform plan -var="DO_TOKEN=${DO_TOKEN}" -out plan
$ terraform apply plan
$ doctl auth init
$ doctl kubernetes cluster kubeconfig save hello-world
$ cd prometheus
$ helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
$ helm repo add kube-state-metrics https://kubernetes.github.io/kube-state-metrics
$ helm repo update
$ helm install prometheus prometheus-community/prometheus --values prometheus-values.yaml
$ cd grafana
$ helm repo add grafana https://grafana.github.io/helm-charts
$ helm repo update
$ helm install grafana grafana/grafana --values grafana-values.yaml
- Login in grafana
- configuration > datasources > add datasource > prometheus > url=http://prometheus-server > save and test
- import dashboard: + > import > Upload Json file > grafana/dashboard.json
- K8S_CONFIG: (kubeconfig cluster content)
- DOCKER_USERNAME: (your_dockerhub_username)
- DOCKER_PASSWD: (your_dockerhub_password)
- Edit file main.yaml replace docker repository name by the your
- Edit file deployment.yaml replace docker repository name by the your
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push -u origin my-new-feature
- Submit a pull request - cheers!