From 10b48d400a16da5831111a107549f94ceb5f142b Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Mon, 1 Jul 2024 17:30:46 +0100 Subject: [PATCH] Add variables and hook for high-availability k8s control plane test Depends-On: https://review.opendev.org/c/openstack/openstack-ansible-plugins/+/924156 Change-Id: Ia9f3a424d9d9249eb5ff76ee2d9125769c3ca732 --- .../control_plane_conformance_test.yml | 63 +++++++++++++++++++ .../playbooks/files/k8s-ha/conf.d/k8s.yml | 5 ++ .../files/k8s-ha/user_variables_hooks.yml | 1 + 3 files changed, 69 insertions(+) create mode 100644 mcapi_vexxhost/playbooks/control_plane_conformance_test.yml create mode 100644 mcapi_vexxhost/playbooks/files/k8s-ha/conf.d/k8s.yml create mode 100644 mcapi_vexxhost/playbooks/files/k8s-ha/user_variables_hooks.yml diff --git a/mcapi_vexxhost/playbooks/control_plane_conformance_test.yml b/mcapi_vexxhost/playbooks/control_plane_conformance_test.yml new file mode 100644 index 00000000..848d279c --- /dev/null +++ b/mcapi_vexxhost/playbooks/control_plane_conformance_test.yml @@ -0,0 +1,63 @@ +# Copyright 2024, BBC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Import haproxy playbook + import_playbook: openstack.osa.haproxy + tags: + - haproxy + +- name: Import installation playbook + import_playbook: osa_ops.mcapi_vexxhost.mcapi_control_plane_k8s + tags: + - k8s + +- hosts: utility_all[0] + gather_facts: false + vars: + k8s_admin_conf_src: "/etc/kubernetes/admin.conf" + k8s_admin_conf_dest: "/root/.kube/config" + tasks: + - name: Collect admin config from k8s cluster + slurp: + src: "{{ k8s_admin_conf_src }}" + register: k8s_admin_conf_slurp + delegate_to: "{{ groups['k8s_all'][0] }}" + run_once: true + + - name: Ensure target directory exists + file: + state: directory + path: "{{ k8s_admin_conf_dest | dirname }}" + owner: root + group: root + + - name: Write k8s admin config to magnum home dir + copy: + content: "{{ k8s_admin_conf_slurp.content | b64decode }}" + dest: "{{ k8s_admin_conf_dest }}" + owner: root + group: root + mode: '0600' + tags: + - kubeconfig + +- hosts: utility_all[0] + gather_facts: false + tasks: + - include_role: + name: osa_ops.mcapi_vexxhost.sonobuoy + vars: + sonobuoy_kubeconfig_file: '/root/.kube/config' + tags: + - sonobuoy diff --git a/mcapi_vexxhost/playbooks/files/k8s-ha/conf.d/k8s.yml b/mcapi_vexxhost/playbooks/files/k8s-ha/conf.d/k8s.yml new file mode 100644 index 00000000..f2c8f8d9 --- /dev/null +++ b/mcapi_vexxhost/playbooks/files/k8s-ha/conf.d/k8s.yml @@ -0,0 +1,5 @@ +cluster-api_hosts: + aio1: + ip: 172.29.236.100 + affinity: + k8s_container: 3 diff --git a/mcapi_vexxhost/playbooks/files/k8s-ha/user_variables_hooks.yml b/mcapi_vexxhost/playbooks/files/k8s-ha/user_variables_hooks.yml new file mode 100644 index 00000000..3116f451 --- /dev/null +++ b/mcapi_vexxhost/playbooks/files/k8s-ha/user_variables_hooks.yml @@ -0,0 +1 @@ +post_setup_hosts_hook: osa_ops.mcapi_vexxhost.control_plane_conformance_test