blob: 5e10df21510339a02417d129596b9fe1ae54c039 [file] [log] [blame]
Mohammed Naserb7b97d62022-03-12 16:30:00 -05001# Copyright (c) 2022 VEXXHOST, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
guilhermesteinmuller700eb2f2023-01-24 19:08:31 +000015- name: Uninstall the legacy HelmRelease
16 run_once: true
17 block:
18 - name: Suspend the existing HelmRelease
Mohammed Naserf0314a82023-04-11 18:53:30 +000019 failed_when: false
guilhermesteinmuller700eb2f2023-01-24 19:08:31 +000020 kubernetes.core.k8s:
21 state: patched
22 api_version: helm.toolkit.fluxcd.io/v2beta1
23 kind: HelmRelease
Mohammed Naser2145fc32023-01-29 23:23:03 +000024 name: "{{ nova_helm_release_name }}"
25 namespace: "{{ nova_helm_release_namespace }}"
guilhermesteinmuller700eb2f2023-01-24 19:08:31 +000026 definition:
27 spec:
28 suspend: true
29
30 - name: Remove the existing HelmRelease
Mohammed Naserf0314a82023-04-11 18:53:30 +000031 failed_when: false
guilhermesteinmuller700eb2f2023-01-24 19:08:31 +000032 kubernetes.core.k8s:
33 state: absent
34 api_version: helm.toolkit.fluxcd.io/v2beta1
35 kind: HelmRelease
Mohammed Naser2145fc32023-01-29 23:23:03 +000036 name: "{{ nova_helm_release_name }}"
37 namespace: "{{ nova_helm_release_namespace }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050038
Mohammed Naser01338322022-03-22 14:51:31 -040039- name: Generate public key for SSH private key
Mohammed Naser0a13cee2023-03-02 11:28:29 +010040 ansible.builtin.import_tasks:
41 file: generate_public_key.yml
Mohammed Naser01338322022-03-22 14:51:31 -040042
ricolind0f23d82023-08-03 15:32:32 +080043# NOTE(okozachenko1203): We cannot set helm hook for jobs.
44# As a workaround, remove them before upgrade nova helm release.
45- name: Remove nova-bootstrap and nova-cell-setup job
Oleksandr Kozachenkof5adeb52023-05-30 21:23:51 +020046 changed_when: false
47 failed_when: false
48 kubernetes.core.k8s:
49 state: absent
50 api_version: batch/v1
51 kind: Job
ricolind0f23d82023-08-03 15:32:32 +080052 name: "{{ item }}"
Oleksandr Kozachenkof5adeb52023-05-30 21:23:51 +020053 namespace: "{{ nova_helm_release_namespace }}"
ricolind0f23d82023-08-03 15:32:32 +080054 loop:
55 - nova-bootstrap
56 - nova-cell-setup
Oleksandr Kozachenkof5adeb52023-05-30 21:23:51 +020057
Mohammed Naserb7b97d62022-03-12 16:30:00 -050058- name: Deploy Helm chart
guilhermesteinmuller700eb2f2023-01-24 19:08:31 +000059 run_once: true
60 kubernetes.core.helm:
Mohammed Naser2145fc32023-01-29 23:23:03 +000061 name: "{{ nova_helm_release_name }}"
62 chart_ref: "{{ nova_helm_chart_ref }}"
63 release_namespace: "{{ nova_helm_release_namespace }}"
guilhermesteinmuller700eb2f2023-01-24 19:08:31 +000064 create_namespace: true
65 kubeconfig: /etc/kubernetes/admin.conf
Mohammed Naser2145fc32023-01-29 23:23:03 +000066 values: "{{ _nova_helm_values | combine(nova_helm_values, recursive=True) }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050067
68- name: Create Ingress
69 ansible.builtin.include_role:
70 name: openstack_helm_ingress
71 vars:
72 openstack_helm_ingress_endpoint: compute
73 openstack_helm_ingress_service_name: nova-api
74 openstack_helm_ingress_service_port: 8774
Oleksandr Kozachenkoaf9972f2023-10-17 19:25:12 +020075 openstack_helm_ingress_annotations: "{{ nova_api_ingress_annotations }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050076
77- name: Create Ingress
78 ansible.builtin.include_role:
79 name: openstack_helm_ingress
80 vars:
81 openstack_helm_ingress_endpoint: compute_novnc_proxy
82 openstack_helm_ingress_service_name: nova-novncproxy
83 openstack_helm_ingress_service_port: 6080
Oleksandr Kozachenkoaf9972f2023-10-17 19:25:12 +020084 openstack_helm_ingress_annotations: "{{ _nova_novnc_ingress_annotations | combine(nova_novnc_ingress_annotations) }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050085
Mohammed Naserb7b97d62022-03-12 16:30:00 -050086- name: Create flavors
Mohammed Naser2145fc32023-01-29 23:23:03 +000087 when: nova_flavors | length > 0
Mohammed Naserc8e1a452022-08-11 16:16:13 -040088 block:
89 - name: Wait until compute api service ready
90 kubernetes.core.k8s_info:
91 api_version: apps/v1
92 kind: Deployment
93 name: nova-api-osapi
94 namespace: openstack
95 wait_sleep: 10
96 wait_timeout: 600
97 wait: true
98 wait_condition:
99 type: Available
100 status: true
101
102 - name: Create flavors
103 openstack.cloud.compute_flavor:
104 cloud: atmosphere
105 # Flavor settings
106 flavorid: "{{ item.flavorid | default(omit) }}"
107 name: "{{ item.name }}"
108 vcpus: "{{ item.vcpus }}"
109 ram: "{{ item.ram }}"
110 disk: "{{ item.disk | default(omit) }}"
111 ephemeral: "{{ item.ephemeral | default(omit) }}"
112 swap: "{{ item.swap | default(omit) }}"
113 is_public: "{{ item.is_public | default(omit) }}"
114 rxtx_factor: "{{ item.rxtx_factor | default(omit) }}"
115 extra_specs: "{{ item.extra_specs | default(omit) }}"
Mohammed Naser2145fc32023-01-29 23:23:03 +0000116 loop: "{{ nova_flavors }}"
Mohammed Naser6f85b3a2022-09-21 14:57:56 -0400117 # NOTE(mnaser): This often fails with a 503 since we're sending a request
118 # way too fast after the service is ready, retry for now
119 # but the Helm chart should be fixed.
120 #
121 # See: https://github.com/vexxhost/atmosphere/issues/72
122 retries: 60
123 delay: 5
124 register: _result
125 until: _result is not failed