deploy backend api

This commit is contained in:
Valentin CZERYBA 2022-12-10 23:05:52 +01:00
parent 3a16d3e723
commit 452a650b16
3 changed files with 70 additions and 4 deletions

View File

@ -41,8 +41,26 @@
src: "{{ project_backend }}/secret.yaml" src: "{{ project_backend }}/secret.yaml"
state: present state: present
- name: Pause for 2 minutes to build app cache
ansible.builtin.pause:
minutes: 2
- name: Fetch services
set_fact:
service: "{{ query('kubernetes.core.k8s', kind='Service', namespace='testing', label_selector='io.kompose.service=backend') }}"
register: result
tags: [ "services"]
- name: debug services
debug:
msg: "{{ result.ansible_facts.service[0].status.loadBalancer.ingress[0].ip }}"
tags: [ "services"]
- name: Test API Backend
ansible.builtin.uri:
url: "http://{{ result.ansible_facts.service[0].status.loadBalancer.ingress[0].ip }}:{{ port }}/api/hello"
status_code: 200
method: GET
tags: [ "services" ]

View File

@ -0,0 +1,42 @@
---
# tasks file for create cluster k8s via terraform
- name: Apply deployment
kubernetes.core.k8s:
src: "{{ project_backend }}/backend-deployment.yaml"
state: absent
- name: Apply services
kubernetes.core.k8s:
src: "{{ project_backend }}/backend-service.yaml"
state: absent
- name: Apply configmap
kubernetes.core.k8s:
src: "{{ project_backend }}/env-configmap.yaml"
state: absent
- name: Apply secret
kubernetes.core.k8s:
src: "{{ project_backend }}/secret.yaml"
state: absent
- name: Create a k8s namespace
kubernetes.core.k8s:
name: testing
api_version: v1
kind: Namespace
state: absent
- name: Create directory {{ project_terraform }}
file:
path: "{{ project_backend }}"
state: absent

View File

@ -14,6 +14,12 @@
import_tasks: deploy-backend.yml import_tasks: deploy-backend.yml
tags: ["deploy-api"] tags: ["deploy-api"]
- name: Deploy a API backend
import_tasks: destroy-backend.yml
tags: ["destroy-api"]
- name: Destroy cluster k8s scaleway via terraform - name: Destroy cluster k8s scaleway via terraform
import_tasks: destroy-cluster.yml import_tasks: destroy-cluster.yml
tags: ["destroy-cluster"] tags: ["destroy-cluster"]