Skip to content
Snippets Groups Projects
Commit 0a69795b authored by Benguria Elguezabal, Gorka's avatar Benguria Elguezabal, Gorka
Browse files

updates README

parent b187d501
No related branches found
No related tags found
No related merge requests found
# Monitoring vagrant
This vagranfile was defined to support the local development of the monitoring components of the piacere project. During intensive debugging of the deployment this avoids lots of git command that: take time, imply many infrastructure requirements (vpn, server, gitlab, ...).
This vagranfile was defined to support the local development of kubernetes multinode with ansible.
It create a machine with docker compose that maps into the folder /monitoring-vagrant
It create a management machine and a four node cluster of kubernetes (k8s), with two masters and two workers.
## Prerequisites
In order to use this vagrantfile you need virtualbox and vagrant.
......@@ -10,52 +10,64 @@ In order to use this vagrantfile you need virtualbox and vagrant.
## Notes
Here we define some particularities of this vagrantifle
* This vagrant file is configured to save the image in a relative ../../vm folder to the location of this vagrantfile.
* This repo is heavily based in submodules, it may happen that you need to contact the repo owner for additional permissions on the included subfolders
* This vagrant file requires some environment variables to be defined in the host machine, they are listed in env.erb. The first two should be provided by someone, others can have any non-empty value.
* CA_API_KEY
* SMTP_API_KEY
* PORTAINER_PASSWORD
* INFLUXD_PASSWORD
* INFLUXD_TOKEN
* GRAFANA_ADMIN_PASSWORD
* The local environment is configured to user the following domains: monitoring.piacere.tri.dev, influxdb.monitoring.piacere.tri.dev, portainer.monitoring.piacere.tri.dev, agent.monitoring.piacere.tri.dev, portainer.monitoring.piacere.tri.dev. These domains should be added into the hosts file (in windows %WINDIR%\System32\drivers\etc\hosts elevated rights are required to edit it) of the host to support the resolution of addresses. The should point to the virtualbox ip i.e. 192.168.56.1 (usually in windows)
* the number of machiens
## How to create
To create the machine clone this repo, go into the folder and execute vagrant up.
```batch
git clone --recurse-submodules https://git.code.tecnalia.com/piacere/private/t61-runtime-monitoring-and-self-healing-preparation/monitoring/monitoring-vagrant/-/tree/master
cd monitoring-vagrant
git clone https://git.code.tecnalia.com/gorka.benguria/kubernetes-vagrant
cd kubernetes-vagrant
vagrant up
````
This will automatically install ansible and run a playbook that:
* process env.erb and stores under the ansible folder as .env
* install docker
* docker compose
* copy .env under git/monitoring-deploy/.local/.env
* will configure .profile to load git/monitoring-deploy/.local/.env as environment variables when login into the vm
## How to run an docker compose
To run a docker compose, you will need to login into the machine, cd to the docker compose, source environment variables, build and deploy
This will automatically start 5 virtual machines and install ansible in the management machine.
## How to setup kubernetes
This vagrant does not setup kubernetes automatically as it is a testing playground for the kubernetes deployment. It contains a sequence of steps to be performed in order to deploy and test the kubernetes deployment.
Therefore in order to setup kubernetes we have to login into management machine and invoke some scripts that simulate the steps that we will require to do in a on premise environment.
```batch
vagrant ssh
````
once inside, for example to run monitoring vagrant for development
once inside, we can start invoking the scripts.
```bash
cd /monitoring-vagrant/git/monitoring-deploy
echo force linux EOL in case of
sed -i 's/\r//g' .local/develop/.env
set -a; source .local/develop/.env; set +a
.local/develop/build.sh
.local/develop/deploy.sh
cd /kubernetes-vagrant/ansible/
export ANSIBLE_CONFIG=/kubernetes-vagrant/ansible/ansible.cfg
echo this is not required with ansible 2.12 ./01_add_required_ansible_modules.sh
./02_hosts_from_inventory.sh
./03_upgrade.sh
./04_epel.sh
./05_development.sh
./06_check_macs_vagrant_eth1.sh
./07_install_kubernetes_kubeadm_docker.sh
echo inside the following script we can adjust the cidrs
./08_bootstrap_kubernetes_kubeadm.sh
./09_enable_kubectl_at_management.sh
./10_calico_network_kubernetes.sh
echo we can check that nodes become ready
kubectl get nodes
./11_kubernetes_dashboard.sh
./12_enable_helm_at_management.sh
echo inside the following script we can adjust the lb ip range
./13_install_metallb.sh
echo we should wait until the metallb controller gets ready, this may take even 5 minutes
kubectl get pod -A
echo once the metallb is ready we can use it for loadbalancer based services
kubectl create deployment nginx --image=nginx --port=80
kubectl expose deployment nginx --type=LoadBalancer --name=nginx-service
kubectl describe service nginx-service
curl http://192.168.56.200
./14_install_nginx_ingress.sh
echo we check the ingress status
kubectl get services -A
echo we test ingress
kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0
kubectl expose deployment web --type=NodePort --port=8080
curl -L https://k8s.io/examples/service/networking/example-ingress.yaml
kubectl apply -f https://k8s.io/examples/service/networking/example-ingress.yaml
echo 192.168.56.201 hello-world.info | sudo tee -a /etc/hosts
curl http://hello-world.info
````
## How to access
Once we sucessfully deploy the docker-compose, we will be able to access the services at:
* https://monitoring.piacere.tri.dev:8443/grafana
* https://monitoring.piacere.tri.dev:8443/portainer
* https://portainer.monitoring.piacere.tri.dev:8443/
* https://monitoring.piacere.tri.dev:8443/dashboard
* https://influxdb.monitoring.piacere.tri.dev:8443/
This repository contains scripts related with ansible for ubuntu focal, and possibly other versions of ubuntu. Scripts such as install.sh
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment