rancher / rke2

https://docs.rke2.io/
Apache License 2.0
1.57k stars 268 forks source link

[Backport release-1.26] Check calico or felix related env variables in windows #4655

Closed rancherbot closed 1 year ago

rancherbot commented 1 year ago

This is a backport issue for https://github.com/rancher/rke2/issues/4580, automatically created via rancherbot by @manuelbuil

Original issue description:

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

Currently, calico-node or felix do not check on OS level env variables when executing their processes, something that makes it hard to change the default config

Describe alternatives you've considered

Additional context

est-suse commented 1 year ago

Validated on 1.26 branch with commit 565745ab6e0613e4a56656794f99dab79979f411

Node(s) CPU architecture, OS, and Version:

Ubuntu 22.04 as Linux server and agent
Windows 2019 (1809) as Windows agent node

cluster configuration:

NAME                                          STATUS   ROLES                       AGE   VERSION
ip-172-31-10-137.us-east-2.compute.internal   Ready    control-plane,etcd,master   19h   v1.26.7+rke2r1
ip-172-31-13-107.us-east-2.compute.internal   Ready    <none>                      19h   v1.26.7+rke2r1
ip-172-31-6-51.us-east-2.compute.internal     Ready    control-plane,etcd,master   19h   v1.26.7+rke2r1
ip-172-31-8-41.us-east-2.compute.internal     Ready    control-plane,etcd,master   19h   v1.26.7+rke2r1
ip-ac1f0c89                                   Ready    <none>                      7m    v1.26.7

Config.yaml:

write-kubeconfig-mode: "0644"
cni: calico

Testing Steps

Copy config.yaml
$ sudo mkdir -p /etc/rancher/rke2 && sudo cp config.yaml /etc/rancher/rke2
Install RKE2 on server node
Join agent node and Windows agent node
Add the system variable: [System.Environment]::SetEnvironmentVariable('FELIX_DATASTORETYPE',

from var/logs/felix

2023-08-23 17:01:12.893 [INFO][5336] felix/config_params.go 612: Parsing value for DatastoreType: etcdv3 (from environment variable)
2023-08-23 17:01:12.893 [INFO][5336] felix/config_params.go 648: Parsed value for DatastoreType: etcdv3 (from environment variable)

Get-EventLog -LogName Application -Source 'rke2' -Newest 200 | select-object -Property TimeWritten,ReplacementStrings | Format-Table -Wrap

8/23/2023 5:01:12 PM {Felix Envs: [KUBE_NETWORK=Calico.* KUBECONFIG=c:\var\lib\rancher\rke2\agent\calico.kubeconfig
                     NODENAME=ip-ac1f0c89 CALICO_K8S_NODE_REF=ip-ac1f0c89 IP=172.31.12.137 USE_POD_CIDR=false
                     FELIX_FELIXHOSTNAME=ip-ac1f0c89 FELIX_VXLANVNI=4096 FELIX_DATASTORETYPE=kubernetes
                     FELIX_DATASTORETYPE=etcdv3]}
ActivityId             : 0EBC41D8-1001-4806-8530-3F4A074697E8
AdditionalParams       :
CurrentEndpointCount   : 0
DNSServerCompartment   : 4
DrMacAddress           : 00-15-5D-05-47-21
Extensions             : {@{Id=E7C3B2F0-F3C5-48DF-AF2B-10FED6D72E7A; IsEnabled=False; Name=Microsoft Windows Filtering Platform}, @{Id=E9B59CFA-2BE1-4B21-828F-B6FBDBDDC017; IsEnabled=True; Name=Microsoft Azure VFP Switch Extension},
                         @{Id=EA24CD6C-D17A-4348-9190-09F0D5BE83DD; IsEnabled=True; Name=Microsoft NDIS Capture}}
Flags                  : 0
Health                 : @{LastErrorCode=0; LastUpdateTime=133372836708921745}
ID                     : 192A3E17-5310-43DF-8942-F048C1C4CA21
IPv6                   : False
LayeredOn              : D585C7B1-3D95-45AF-A434-1C7ED3F6AF65
MacPools               : {@{EndMacAddress=00-15-5D-34-CF-FF; StartMacAddress=00-15-5D-34-C0-00}}
ManagementIP           : 172.31.12.137
MaxConcurrentEndpoints : 0
Name                   : Calico