diff --git a/scaleway-k8s/tasks/deploy-backend.yml b/scaleway-k8s/tasks/deploy-backend.yml index 034fe6d..18cee8f 100644 --- a/scaleway-k8s/tasks/deploy-backend.yml +++ b/scaleway-k8s/tasks/deploy-backend.yml @@ -41,8 +41,26 @@ src: "{{ project_backend }}/secret.yaml" 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" ] diff --git a/scaleway-k8s/tasks/destroy-backend.yml b/scaleway-k8s/tasks/destroy-backend.yml new file mode 100644 index 0000000..9cdd82d --- /dev/null +++ b/scaleway-k8s/tasks/destroy-backend.yml @@ -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 + + + + + diff --git a/scaleway-k8s/tasks/main.yml b/scaleway-k8s/tasks/main.yml index 22e162a..8065e9f 100644 --- a/scaleway-k8s/tasks/main.yml +++ b/scaleway-k8s/tasks/main.yml @@ -12,7 +12,13 @@ - name: Deploy a API backend 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 import_tasks: destroy-cluster.yml