File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ func init() {
2323 allProviders [providers .K3s ] = providers .IsK3s
2424 allProviders [providers .Minikube ] = providers .IsMinikube
2525 allProviders [providers .RKE ] = providers .IsRKE
26+ allProviders [providers .RKE_WINDOWS ] = providers .IsRKEWindows
2627 allProviders [providers .RKE2 ] = providers .IsRKE2
2728}
2829
Original file line number Diff line number Diff line change 1+ package providers
2+
3+ import (
4+ "context"
5+
6+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
7+ "k8s.io/client-go/kubernetes"
8+ )
9+
10+ const RKE_WINDOWS = "rke.windows"
11+
12+ func IsRKEWindows (ctx context.Context , k8sClient kubernetes.Interface ) (bool , error ) {
13+ // if there are windows nodes
14+ windowsNodes , err := k8sClient .CoreV1 ().Nodes ().List (ctx , metav1.ListOptions {
15+ Limit : 1 ,
16+ LabelSelector : "kubernetes.io/os=windows" ,
17+ })
18+ if err != nil {
19+ return false , err
20+ }
21+ if len (windowsNodes .Items ) == 0 {
22+ return false , nil
23+ }
24+
25+ annos := windowsNodes .Items [0 ].Annotations
26+ if _ , ok := annos ["rke.cattle.io/external-ip" ]; ok {
27+ return true , nil
28+ }
29+ if _ , ok := annos ["rke.cattle.io/internal-ip:" ]; ok {
30+ return true , nil
31+ }
32+ return false , nil
33+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,18 @@ import (
1010const RKE = "rke"
1111
1212func IsRKE (ctx context.Context , k8sClient kubernetes.Interface ) (bool , error ) {
13+ // if there are windows nodes then this should not be counted as rke.linux
14+ windowsNodes , err := k8sClient .CoreV1 ().Nodes ().List (ctx , metav1.ListOptions {
15+ Limit : 1 ,
16+ LabelSelector : "kubernetes.io/os=windows" ,
17+ })
18+ if err != nil {
19+ return false , err
20+ }
21+ if len (windowsNodes .Items ) != 0 {
22+ return false , nil
23+ }
24+
1325 // Any node created by RKE should have the annotation, so just grab 1
1426 nodes , err := k8sClient .CoreV1 ().Nodes ().List (ctx , metav1.ListOptions {Limit : 1 })
1527 if err != nil {
You can’t perform that action at this time.
0 commit comments