-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iniciando integração do ansible com vagrant
- Loading branch information
Samuel Ferino
committed
Mar 29, 2024
1 parent
1afdee4
commit a3a36f6
Showing
5 changed files
with
147 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
all: run | ||
.PHONY: all build run clean | ||
|
||
requirements: | ||
if [ -x /usr/bin/apt-get ]; then xargs -a requirements.txt sudo apt-get install -y; fi | ||
|
||
build: clean | ||
@echo | ||
@echo "******************** BUILDING THE VIRTUAL MACHINE **********************************" | ||
vagrant provision | ||
@echo | ||
vagrant status | ||
@echo | ||
|
||
|
||
run: build | ||
@echo | ||
@echo "******************** RUNNING THE VIRTUAL MACHINE **********************************" | ||
vagrant up | ||
@echo | ||
vagrant status | ||
@echo | ||
vagrant ssh | ||
@echo | ||
|
||
|
||
clean: | ||
@echo | ||
@echo "******************** DESTROYING THE VIRTUAL MACHINE **********************************" | ||
vagrant destroy -f | ||
@echo | ||
vagrant status | ||
@echo | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
|
||
Vagrant.configure("2") do |config| | ||
config.vm.box = "ubuntu/focal64" | ||
|
||
config.vm.provision "file", source: "./k8s", destination: "/home/vagrant/k8s" | ||
config.vm.provision "file", source: "./kong", destination: "/home/vagrant/kong" | ||
config.vm.provision "file", source: "./ansible", destination: "/home/vagrant/ansible" | ||
|
||
# Create a forwarded port mapping which allows access to a specific port | ||
# within the machine from a port on the host machine. In the example below, | ||
# accessing "localhost:8080" will access port 80 on the guest machine. | ||
# NOTE: This will enable public access to the opened port | ||
# config.vm.network "forwarded_port", guest: 80, host: 8080 | ||
|
||
# Create a forwarded port mapping which allows access to a specific port | ||
# within the machine from a port on the host machine and only allow access | ||
# via 127.0.0.1 to disable public access | ||
config.vm.network "forwarded_port", guest: 8001, host: 8001, host_ip: "127.0.0.1" | ||
|
||
# Create a private network, which allows host-only access to the machine using a specific IP. | ||
config.vm.network "private_network", ip: "192.168.56.10" | ||
|
||
# Create a public network, which generally matched to bridged network. | ||
# Bridged networks make the machine appear as another physical device on | ||
# your network. | ||
# config.vm.network "public_network" | ||
|
||
config.vm.provider "virtualbox" do |vb| | ||
vb.gui = false | ||
vb.memory = "4096" | ||
vb.cpus = "2" | ||
end | ||
|
||
|
||
# Enable provisioning with a shell script. Additional provisioners such as | ||
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the | ||
# documentation for more information about their specific syntax and use. | ||
config.vm.provision "shell", inline: <<-SHELL | ||
echo "" | ||
echo "************** Updating Linux Packages" | ||
apt-get update | ||
apt-get upgrade -y | ||
echo "" | ||
echo "************** Installing MicroK8s (version 1.27)" | ||
snap install microk8s --classic --channel=1.27 | ||
microk8s status --wait-ready | ||
mkdir -p ~/.kube | ||
usermod -a -G microk8s vagrant | ||
chown -f -R vagrant ~/.kube | ||
alias kubectl='microk8s kubectl' | ||
alias helm='microk8s helm' | ||
echo "" | ||
echo "************** Deploying Flask App into the MicroK8s" | ||
kubectl create namespace app | ||
kubectl apply -f /home/vagrant/k8s/flask-app-k8s.yaml --namespace app | ||
kubectl wait --for=condition=available deployment/flask-app-deployment --namespace app --timeout=300s | ||
kubectl wait --for=condition=Ready pod -l app=flask-app -n app --timeout=300s | ||
kubectl get service --namespace app | ||
kubectl get deployment --namespace app | ||
echo "" | ||
echo "************** Installing MicroK8s addons/plugins" | ||
microk8s enable dns storage rbac | ||
# microk8s enable metallb | ||
microk8s enable metrics-server observability dashboard | ||
# echo "" | ||
# echo "************** Installing Kong Ingress Controller (KIC)" | ||
# kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml | ||
# kubectl apply -f /home/vagrant/kong/gateway-api-crd.yaml | ||
# helm repo add kong https://charts.konghq.com | ||
# helm repo update | ||
# helm install kong kong/ingress -n kong --create-namespace | ||
# helm dependency build /home/vagrant/kong/helm | ||
# helm install kong /home/vagrant/kong/helm --namespace kong --create-namespace | ||
export NODE_PORT="$(microk8s kubectl get services/flask-app-service --namespace app -o go-template='{{(index .spec.ports 0).nodePort}}')" | ||
echo "NODE_PORT=${NODE_PORT}" | ||
curl -sv localhost:${NODE_PORT}/api/comment/list/1 | ||
# microk8s kubectl --namespace kube-system patch svc kubernetes-dashboard -p '{"spec": {"type": "NodePort", "ports": [{"nodePort": 32000, "port": 443, "protocol": "TCP", "targetPort": 8443}]}}' | ||
# microk8s kubectl --namespace observability patch svc kube-prom-stack-kube-prome-prometheus -p '{"spec": {"type": "NodePort", "ports": [{"nodePort": 32001, "port": 9090, "protocol": "TCP", "targetPort": 9090}]}}' | ||
# microk8s kubectl --namespace observability patch svc kube-prom-stack-grafana -p '{"spec": {"type": "NodePort", "ports": [{"nodePort": 32002, "port": 80, "protocol": "TCP", "targetPort": 3000}]}}' | ||
SHELL | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
virtualbox | ||
vagrant | ||
ansible |