forked from badtuxx/giropops-senhas
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.yml
93 lines (79 loc) · 3.42 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
- name: Configurar e Aplicar Manifestos Kubernetes
hosts: localhost
become: yes
tasks:
- name: Obter o KUBECONFIG do kind
ansible.builtin.command: kind get kubeconfig
register: kubeconfig_content
- name: Criar arquivo KUBECONFIG temporário
ansible.builtin.copy:
content: "{{ kubeconfig_content.stdout }}"
dest: /tmp/kind_kubeconfig
- name: Verificar a conexão com o servidor Kubernetes
ansible.builtin.command: kubectl cluster-info
environment:
KUBECONFIG: /tmp/kind_kubeconfig
register: cluster_info
failed_when: "'Kubernetes control plane' not in cluster_info.stdout"
- name: Instalar Nginx Ingress Controller
ansible.builtin.command: kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
environment:
KUBECONFIG: /tmp/kind_kubeconfig
- name: Instalar Cert-manager
ansible.builtin.command: kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.15.3/cert-manager.yaml
environment:
KUBECONFIG: /tmp/kind_kubeconfig
- name: Baixar e extrair Kube-prometheus
ansible.builtin.unarchive:
src: https://github.com/prometheus-operator/kube-prometheus/archive/main.zip
dest: /tmp/
remote_src: yes
- name: Verificar se os CRDs do Kube-prometheus já existem
ansible.builtin.command: kubectl get crd alertmanagerconfigs.monitoring.coreos.com
environment:
KUBECONFIG: /tmp/kind_kubeconfig
register: crd_check
ignore_errors: yes
- name: Criar namespace e CRDs do Kube-prometheus
ansible.builtin.command: kubectl create -f /tmp/kube-prometheus-main/manifests/setup
environment:
KUBECONFIG: /tmp/kind_kubeconfig
when: crd_check.rc != 0
- name: Aguardar criação do CRD "servicemonitors"
ansible.builtin.command: >
bash -c 'until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done'
environment:
KUBECONFIG: /tmp/kind_kubeconfig
- name: Verificar se os recursos do Kube-prometheus já existem
ansible.builtin.command: kubectl get all -n monitoring
environment:
KUBECONFIG: /tmp/kind_kubeconfig
register: resources_check
ignore_errors: yes
- name: Criar recursos restantes do Kube-prometheus
ansible.builtin.command: kubectl create -f /tmp/kube-prometheus-main/manifests/
environment:
KUBECONFIG: /tmp/kind_kubeconfig
when: resources_check.rc != 0
- name: Remover arquivos do Kube-prometheus
ansible.builtin.file:
path: /tmp/kube-prometheus-main
state: absent
- name: Verificar se o namespace giropops-senhas existe
ansible.builtin.command: kubectl get namespace giropops-senhas
register: namespace_check
ignore_errors: yes
environment:
KUBECONFIG: /tmp/kind_kubeconfig
- name: Criar namespace giropops-senhas se não existir
ansible.builtin.command: kubectl create namespace giropops-senhas
when: namespace_check.rc != 0
environment:
KUBECONFIG: /tmp/kind_kubeconfig
- name: Aplicar manifestos do diretório /kind/manifests
ansible.builtin.command: kubectl apply -f {{ item }}
with_fileglob:
- "/home/nataliagranato/Downloads/LINUXtips-PICK/kind/manifests/*.yaml"
environment:
KUBECONFIG: /tmp/kind_kubeconfig