blob: 73a8988c37385387852ae74753e1c9f7bd711927 [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
Oleksandr Kozachenkof5adeb52023-05-30 21:23:51 +020043# NOTE(okozachenko1203): We cannot set helm hook for this bootstrap job.
44# As a workaround, remove this job before upgrade nova helm release.
45- name: Remove nova-bootstrap job
46 changed_when: false
47 failed_when: false
48 kubernetes.core.k8s:
49 state: absent
50 api_version: batch/v1
51 kind: Job
52 name: nova-bootstrap
53 namespace: "{{ nova_helm_release_namespace }}"
54
Mohammed Naserb7b97d62022-03-12 16:30:00 -050055- name: Deploy Helm chart
guilhermesteinmuller700eb2f2023-01-24 19:08:31 +000056 run_once: true
57 kubernetes.core.helm:
Mohammed Naser2145fc32023-01-29 23:23:03 +000058 name: "{{ nova_helm_release_name }}"
59 chart_ref: "{{ nova_helm_chart_ref }}"
60 release_namespace: "{{ nova_helm_release_namespace }}"
guilhermesteinmuller700eb2f2023-01-24 19:08:31 +000061 create_namespace: true
62 kubeconfig: /etc/kubernetes/admin.conf
Mohammed Naser2145fc32023-01-29 23:23:03 +000063 values: "{{ _nova_helm_values | combine(nova_helm_values, recursive=True) }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050064
65- name: Create Ingress
66 ansible.builtin.include_role:
67 name: openstack_helm_ingress
68 vars:
69 openstack_helm_ingress_endpoint: compute
70 openstack_helm_ingress_service_name: nova-api
71 openstack_helm_ingress_service_port: 8774
Mohammed Naser2145fc32023-01-29 23:23:03 +000072 openstack_helm_ingress_annotations: "{{ nova_ingress_annotations }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050073
74- name: Create Ingress
75 ansible.builtin.include_role:
76 name: openstack_helm_ingress
77 vars:
78 openstack_helm_ingress_endpoint: compute_novnc_proxy
79 openstack_helm_ingress_service_name: nova-novncproxy
80 openstack_helm_ingress_service_port: 6080
Mohammed Naser2145fc32023-01-29 23:23:03 +000081 openstack_helm_ingress_annotations: "{{ nova_ingress_annotations }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050082
Mohammed Naserb7b97d62022-03-12 16:30:00 -050083- name: Create flavors
Mohammed Naser2145fc32023-01-29 23:23:03 +000084 when: nova_flavors | length > 0
Mohammed Naserc8e1a452022-08-11 16:16:13 -040085 block:
86 - name: Wait until compute api service ready
87 kubernetes.core.k8s_info:
88 api_version: apps/v1
89 kind: Deployment
90 name: nova-api-osapi
91 namespace: openstack
92 wait_sleep: 10
93 wait_timeout: 600
94 wait: true
95 wait_condition:
96 type: Available
97 status: true
98
99 - name: Create flavors
100 openstack.cloud.compute_flavor:
101 cloud: atmosphere
102 # Flavor settings
103 flavorid: "{{ item.flavorid | default(omit) }}"
104 name: "{{ item.name }}"
105 vcpus: "{{ item.vcpus }}"
106 ram: "{{ item.ram }}"
107 disk: "{{ item.disk | default(omit) }}"
108 ephemeral: "{{ item.ephemeral | default(omit) }}"
109 swap: "{{ item.swap | default(omit) }}"
110 is_public: "{{ item.is_public | default(omit) }}"
111 rxtx_factor: "{{ item.rxtx_factor | default(omit) }}"
112 extra_specs: "{{ item.extra_specs | default(omit) }}"
Mohammed Naser2145fc32023-01-29 23:23:03 +0000113 loop: "{{ nova_flavors }}"
Mohammed Naser6f85b3a2022-09-21 14:57:56 -0400114 # NOTE(mnaser): This often fails with a 503 since we're sending a request
115 # way too fast after the service is ready, retry for now
116 # but the Helm chart should be fixed.
117 #
118 # See: https://github.com/vexxhost/atmosphere/issues/72
119 retries: 60
120 delay: 5
121 register: _result
122 until: _result is not failed