Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick Magnum CAPI commits #537

Merged
merged 5 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions ansible/roles/magnum/tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,33 @@
when:
- magnum_policy.results

- name: Check if kubeconfig file is supplied
stat:
path: "{{ node_custom_config }}/magnum/kubeconfig"
delegate_to: localhost
run_once: True
register: magnum_kubeconfig_file

- name: Copying over kubeconfig file
template:
src: "{{ node_custom_config }}/magnum/kubeconfig"
dest: "{{ node_config_directory }}/{{ item.key }}/kubeconfig"
mode: "0660"
become: true
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
- magnum_kubeconfig_file.stat.exists
with_dict: "{{ magnum_services }}"
notify:
- Restart {{ item.key }} container

- name: Set magnum kubeconfig file's path
set_fact:
magnum_kubeconfig_file_path: "{{ magnum_kubeconfig_file.stat.path }}"
when:
- magnum_kubeconfig_file.stat.exists

- include_tasks: copy-certs.yml
when:
- kolla_copy_ca_into_containers | bool
Expand Down
9 changes: 8 additions & 1 deletion ansible/roles/magnum/templates/magnum-api.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
"dest": "/etc/magnum/magnum.conf",
"owner": "magnum",
"perm": "0600"
}{% if magnum_policy_file is defined %},
}{% if magnum_kubeconfig_file_path is defined %},
{
"source": "{{ container_config_directory }}/kubeconfig",
"dest": "/var/lib/magnum/.kube/config",
"owner": "magnum",
"perm": "0600"
}{% endif %}
{% if magnum_policy_file is defined %},
{
"source": "{{ container_config_directory }}/{{ magnum_policy_file }}",
"dest": "/etc/magnum/{{ magnum_policy_file }}",
Expand Down
7 changes: 4 additions & 3 deletions ansible/roles/magnum/templates/magnum-conductor.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
"dest": "/etc/magnum/magnum.conf",
"owner": "magnum",
"perm": "0600"
}{% if magnum_cluster_api_driver_enabled is defined %},
}{% if magnum_kubeconfig_file_path is defined %},
{
"source": "{{ container_config_directory }}/kubeconfig",
"dest": "/etc/magnum/kubeconfig",
"dest": "/var/lib/magnum/.kube/config",
"owner": "magnum",
"perm": "0600"
}{% endif %}{% if magnum_policy_file is defined %},
}{% endif %}
{% if magnum_policy_file is defined %},
{
"source": "{{ container_config_directory }}/{{ magnum_policy_file }}",
"dest": "/etc/magnum/{{ magnum_policy_file }}",
Expand Down
7 changes: 6 additions & 1 deletion ansible/roles/magnum/templates/magnum.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ hmac_keys = {{ osprofiler_secret }}
connection_string = {{ osprofiler_backend_connection_string }}
{% endif %}

{% if magnum_kubeconfig_file_path is not defined %}
[drivers]
disabled_drivers = k8s_cluster_api_flatcar,k8s_cluster_api_ubuntu,k8s_cluster_api_ubuntu_focal
{% endif %}

{% if magnum_cluster_api_driver_enabled is defined %}
[capi_driver]
kubeconfig_file = /etc/magnum/kubeconfig
{% endif %}
{% endif %}
5 changes: 5 additions & 0 deletions releasenotes/notes/magnum-kubeconfig-71934a2980c7e74f.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
features:
- |
Adds support for copying in ``{{ node_custom_config }}/magnum/kubeconfig``
to Magnum containers for ``magnum-cluster-api`` driver.