Skip to content

Commit d16e96a

Browse files
Aleix Ramírez Baenask4zuzu
andauthored
F #205: [OneKE] Add cluster/service CIDRs (#206)
* F #205: [OneKE] Adds ONEAPP_K8S_SERVICE_CIDR configuration parameter * F #205: Add ONEAPPS_K8S_CLUSTER_CIDR + cleanups --------- Signed-off-by: Aleix Ramírez <aramirez@opennebula.io> Co-authored-by: Michal Opala <mopala@opennebula.io>
1 parent 525c327 commit d16e96a

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

appliances/OneKE/config.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
ONEAPP_K8S_CONTROL_PLANE_EP = env :ONEAPP_K8S_CONTROL_PLANE_EP, "#{ONEAPP_VROUTER_ETH0_VIP0}:#{ONEAPP_VNF_HAPROXY_LB1_PORT}"
6161
ONEAPP_K8S_EXTRA_SANS = env :ONEAPP_K8S_EXTRA_SANS, 'localhost,127.0.0.1'
6262

63+
# IPv4/IPv6 network CIDRs to use for cluster and service IPs: https://docs.rke2.io/reference/server_config#networking
64+
ONEAPP_K8S_CLUSTER_CIDR = env :ONEAPP_K8S_CLUSTER_CIDR, '10.42.0.0/16'
65+
ONEAPP_K8S_SERVICE_CIDR = env :ONEAPP_K8S_SERVICE_CIDR, '10.43.0.0/16'
66+
6367
# Proxy config for RKE2: https://docs.rke2.io/advanced#configuring-an-http-proxy
6468
ONEAPP_K8S_HTTP_PROXY = env :ONEAPP_K8S_HTTP_PROXY, nil
6569
ONEAPP_K8S_HTTPS_PROXY = env :ONEAPP_K8S_HTTPS_PROXY, nil

appliances/OneKE/kubernetes.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,11 @@
1313
def install_kubernetes(airgap_dir = ONE_AIRGAP_DIR)
1414
rke2_release_url = "https://github.com/rancher/rke2/releases/download/#{ONE_SERVICE_RKE2_VERSION}"
1515

16-
amap= {
17-
"x86_64" => "amd64",
18-
"aarch64" => "arm64"
19-
}
2016
begin
21-
arch = amap[`arch`.strip]
17+
arch = {'x86_64' => 'amd64', 'aarch64' => 'arm64'}[`arch`.strip]
2218
rescue KeyError
23-
msg :error, "Unknown architecture"
24-
exit 1
19+
msg :error, 'Unknown architecture'
20+
exit 1
2521
end
2622

2723
msg :info, "Install RKE2 runtime: #{ONE_SERVICE_RKE2_VERSION}"
@@ -203,6 +199,8 @@ def init_master
203199
'node-taint' => ['CriticalAddonsOnly=true:NoExecute'],
204200
'disable' => ['rke2-ingress-nginx'],
205201
'cni' => cni,
202+
'cluster-cidr' => ONEAPP_K8S_CLUSTER_CIDR,
203+
'service-cidr' => ONEAPP_K8S_SERVICE_CIDR,
206204
'disable-kube-proxy' => ONEAPP_K8S_CNI_PLUGIN == 'cilium',
207205
'disable-cloud-controller' => ONEAPP_RKE2_CLOUD_CONTROLLER_ENABLED == false
208206
}
@@ -260,6 +258,8 @@ def join_master(token, retries = RETRIES, seconds = SECONDS)
260258
'node-taint' => ['CriticalAddonsOnly=true:NoExecute'],
261259
'disable' => ['rke2-ingress-nginx'],
262260
'cni' => cni,
261+
'cluster-cidr' => ONEAPP_K8S_CLUSTER_CIDR,
262+
'service-cidr' => ONEAPP_K8S_SERVICE_CIDR,
263263
'disable-kube-proxy' => ONEAPP_K8S_CNI_PLUGIN == 'cilium',
264264
'disable-cloud-controller' => ONEAPP_RKE2_CLOUD_CONTROLLER_ENABLED == false
265265
}
@@ -392,10 +392,13 @@ def configure_rke2_proxy(current_role)
392392
proxy_config = []
393393
proxy_config << "HTTP_PROXY=#{ONEAPP_K8S_HTTP_PROXY}" unless ONEAPP_K8S_HTTP_PROXY.nil?
394394
proxy_config << "HTTPS_PROXY=#{ONEAPP_K8S_HTTPS_PROXY}" unless ONEAPP_K8S_HTTPS_PROXY.nil?
395+
395396
if ONEAPP_K8S_NO_PROXY.to_s.empty?
396-
no_proxy = ['127.0.0.1/32', 'localhost']
397+
no_proxy = ['127.0.0.0/8', 'localhost']
397398
no_proxy << retrieve_endpoint_host(ONEAPP_K8S_CONTROL_PLANE_EP) if ONEAPP_K8S_CONTROL_PLANE_EP
398399
no_proxy << retrieve_endpoint_host(ONEAPP_RKE2_SUPERVISOR_EP) if ONEAPP_RKE2_SUPERVISOR_EP
400+
no_proxy << ONEAPP_K8S_CLUSTER_CIDR
401+
no_proxy << ONEAPP_K8S_SERVICE_CIDR
399402
proxy_config << "NO_PROXY=#{no_proxy.uniq.join(',')}"
400403
else
401404
proxy_config << "NO_PROXY=#{ONEAPP_K8S_NO_PROXY}"

0 commit comments

Comments
 (0)