mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-10-29 22:03:22 -02:30
Fix custom_cni manifest apply failure for multi-namespace resources (#13091)
* fix(custom_cni): make namespace optional Keep kube-system as the default for existing manifests. An empty custom_cni_namespace omits kubectl's namespace flag so manifests spanning multiple namespaces can be applied without changing legacy behavior. Signed-off-by: Kay Yan <kay.yan@daocloud.io> * docs(custom_cni): document multi-namespace manifests Signed-off-by: Kay Yan <kay.yan@daocloud.io> --------- Signed-off-by: Kay Yan <kay.yan@daocloud.io>
This commit is contained in:
@@ -9,10 +9,16 @@
|
|||||||
## List of Kubernetes resource manifest files
|
## List of Kubernetes resource manifest files
|
||||||
## See tests/files/custom_cni/README.md for example
|
## See tests/files/custom_cni/README.md for example
|
||||||
# custom_cni_manifests: []
|
# custom_cni_manifests: []
|
||||||
|
#
|
||||||
|
## Namespace passed to kubectl when applying manifests.
|
||||||
|
## Set to an empty string for multi-namespace manifests where every namespaced
|
||||||
|
## resource declares metadata.namespace.
|
||||||
|
# custom_cni_namespace: "kube-system"
|
||||||
|
|
||||||
## OPTION 1 EXAMPLE - Cilium static manifests in Kubespray tree
|
## OPTION 1 EXAMPLE - Cilium static manifests in Kubespray tree
|
||||||
# custom_cni_manifests:
|
# custom_cni_manifests:
|
||||||
# - "{{ playbook_dir }}/../tests/files/custom_cni/cilium.yaml"
|
# - "{{ playbook_dir }}/../tests/files/custom_cni/cilium.yaml"
|
||||||
|
# custom_cni_namespace: ""
|
||||||
|
|
||||||
## OPTION 2 - Helm chart application
|
## OPTION 2 - Helm chart application
|
||||||
## This allows the CNI backend to be deployed to Kubespray cluster
|
## This allows the CNI backend to be deployed to Kubespray cluster
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
custom_cni_manifests: []
|
custom_cni_manifests: []
|
||||||
|
custom_cni_namespace: kube-system
|
||||||
|
|
||||||
custom_cni_chart_namespace: kube-system
|
custom_cni_chart_namespace: kube-system
|
||||||
custom_cni_chart_release_name: ""
|
custom_cni_chart_release_name: ""
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
- name: Custom CNI | Start Resources
|
- name: Custom CNI | Start Resources
|
||||||
kube:
|
kube:
|
||||||
namespace: "kube-system"
|
namespace: "{{ custom_cni_namespace | default(omit, true) }}"
|
||||||
kubectl: "{{ bin_dir }}/kubectl"
|
kubectl: "{{ bin_dir }}/kubectl"
|
||||||
filename: "{{ kube_config_dir }}/{{ item | basename | replace('.j2', '') }}"
|
filename: "{{ kube_config_dir }}/{{ item | basename | replace('.j2', '') }}"
|
||||||
state: "latest"
|
state: "latest"
|
||||||
|
|||||||
@@ -9,3 +9,17 @@ helm repo add cilium https://helm.cilium.io/
|
|||||||
helm repo update
|
helm repo update
|
||||||
helm template cilium/cilium -n kube-system -f values.yaml > cilium.yaml
|
helm template cilium/cilium -n kube-system -f values.yaml > cilium.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The generated Cilium manifest contains resources in both the `kube-system` and
|
||||||
|
`cilium-secrets` namespaces. Configure the static manifest example without a
|
||||||
|
kubectl namespace argument:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
custom_cni_manifests:
|
||||||
|
- "{{ playbook_dir }}/../tests/files/custom_cni/cilium.yaml"
|
||||||
|
custom_cni_namespace: ""
|
||||||
|
```
|
||||||
|
|
||||||
|
When `custom_cni_namespace` is empty, every namespaced resource in the
|
||||||
|
manifests should declare `metadata.namespace`. Otherwise, kubectl applies the
|
||||||
|
resource to the current context's default namespace.
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ kube_owner: root
|
|||||||
kube_network_plugin: custom_cni
|
kube_network_plugin: custom_cni
|
||||||
custom_cni_manifests:
|
custom_cni_manifests:
|
||||||
- "{{ playbook_dir }}/../tests/files/custom_cni/cilium.yaml"
|
- "{{ playbook_dir }}/../tests/files/custom_cni/cilium.yaml"
|
||||||
|
custom_cni_namespace: ""
|
||||||
|
|
||||||
# Use static containerd binary for older distributions like Debian 11.
|
# Use static containerd binary for older distributions like Debian 11.
|
||||||
containerd_static_binary: true
|
containerd_static_binary: true
|
||||||
|
|||||||
Reference in New Issue
Block a user