From 4b1f5d840fb9f2158e7c7d8ebca6f1a86fb8569f Mon Sep 17 00:00:00 2001 From: Oleksandr K Date: Thu, 30 May 2024 15:45:30 +0200 Subject: [PATCH] feat: Update bind address for k8s components (#197) * feat: Update bind address for k8s components * Allow kube-proxy traffic --------- Co-authored-by: okozachenko1203 Co-authored-by: Mohammed Naser --- magnum_cluster_api/files/__init__.py | 0 magnum_cluster_api/files/run/__init__.py | 0 .../files/run/kubeadm/__init__.py | 0 .../files/run/kubeadm/configure-kube-proxy.sh | 18 +++++++++++++++ magnum_cluster_api/resources.py | 22 +++++++++++++++++++ 5 files changed, 40 insertions(+) create mode 100644 magnum_cluster_api/files/__init__.py create mode 100644 magnum_cluster_api/files/run/__init__.py create mode 100644 magnum_cluster_api/files/run/kubeadm/__init__.py create mode 100644 magnum_cluster_api/files/run/kubeadm/configure-kube-proxy.sh diff --git a/magnum_cluster_api/files/__init__.py b/magnum_cluster_api/files/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/magnum_cluster_api/files/run/__init__.py b/magnum_cluster_api/files/run/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/magnum_cluster_api/files/run/kubeadm/__init__.py b/magnum_cluster_api/files/run/kubeadm/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/magnum_cluster_api/files/run/kubeadm/configure-kube-proxy.sh b/magnum_cluster_api/files/run/kubeadm/configure-kube-proxy.sh new file mode 100644 index 00000000..ddc3e1d2 --- /dev/null +++ b/magnum_cluster_api/files/run/kubeadm/configure-kube-proxy.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# SPDX-License-Identifier: Apache-2.0 + +set -o pipefail +set -o errexit +set -o nounset + +if grep -q "KubeProxyConfiguration" /run/kubeadm/kubeadm.yaml; then + exit 0 +fi + +cat <> /run/kubeadm/kubeadm.yaml +--- +apiVersion: kubeproxy.config.k8s.io/v1alpha1 +kind: KubeProxyConfiguration +metricsBindAddress: "0.0.0.0:10249" +EOF diff --git a/magnum_cluster_api/resources.py b/magnum_cluster_api/resources.py index 7eac091a..27f46001 100644 --- a/magnum_cluster_api/resources.py +++ b/magnum_cluster_api/resources.py @@ -13,6 +13,7 @@ # under the License. import glob +import importlib.resources import json import os import textwrap @@ -603,14 +604,23 @@ def get_object(self) -> objects.KubeadmControlPlaneTemplate: } ], }, + "etcd": { + "local": { + "extraArgs": { + "listen-metrics-urls": "http://0.0.0.0:2381", + }, + }, + }, "controllerManager": { "extraArgs": { + "bind-address": "0.0.0.0", "cloud-provider": "external", "profiling": "false", }, }, "scheduler": { "extraArgs": { + "bind-address": "0.0.0.0", "profiling": "false", }, }, @@ -631,6 +641,18 @@ def get_object(self) -> objects.KubeadmControlPlaneTemplate: ), "encoding": "base64", }, + { + "path": "/run/kubeadm/configure-kube-proxy.sh", + "permissions": "0755", + "content": base64.encode_as_text( + importlib.resources.files( + "magnum_cluster_api.files.run.kubeadm" + ) + .joinpath("configure-kube-proxy.sh") + .read_text() + ), + "encoding": "base64", + }, ], "initConfiguration": { "nodeRegistration": {