Skip to content

Commit beeb66a

Browse files
authored
feat: installing windows cns if windows nodes present (#2246)
1 parent 4943198 commit beeb66a

File tree

6 files changed

+449
-104
lines changed

6 files changed

+449
-104
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: azure-cns-win
5+
namespace: kube-system
6+
labels:
7+
app: azure-cns-win
8+
spec:
9+
selector:
10+
matchLabels:
11+
k8s-app: azure-cns-win
12+
template:
13+
metadata:
14+
labels:
15+
k8s-app: azure-cns-win
16+
kubernetes.azure.com/managedby: aks
17+
annotations:
18+
cluster-autoscaler.kubernetes.io/daemonset-pod: "true"
19+
prometheus.io/port: "10092"
20+
spec:
21+
securityContext:
22+
windowsOptions:
23+
hostProcess: true
24+
runAsUserName: "NT AUTHORITY\\SYSTEM"
25+
affinity:
26+
nodeAffinity:
27+
requiredDuringSchedulingIgnoredDuringExecution:
28+
nodeSelectorTerms:
29+
- matchExpressions:
30+
- key: kubernetes.azure.com/cluster
31+
operator: Exists
32+
- key: type
33+
operator: NotIn
34+
values:
35+
- virtual-kubelet
36+
- key: kubernetes.io/os
37+
operator: In
38+
values:
39+
- windows
40+
tolerations:
41+
- operator: "Exists"
42+
effect: NoExecute
43+
- operator: "Exists"
44+
effect: NoSchedule
45+
containers:
46+
- name: cns-container
47+
image: acnpublic.azurecr.io/azure-cns:latest
48+
imagePullPolicy: IfNotPresent
49+
securityContext:
50+
privileged: true
51+
command: ["powershell.exe"]
52+
args:
53+
[
54+
'.\setkubeconfigpath.ps1',
55+
";",
56+
'.\azure-cns.exe',
57+
"-c",
58+
"tcp://$(CNSIpAddress):$(CNSPort)",
59+
"-t",
60+
"$(CNSLogTarget)",
61+
"-o",
62+
"$(CNSLogDir)",
63+
"-storefilepath",
64+
"$(CNSStoreFilePath)",
65+
"-config-path",
66+
"%CONTAINER_SANDBOX_MOUNT_POINT%\\$(CNS_CONFIGURATION_PATH)",
67+
"--kubeconfig",
68+
'.\kubeconfig',
69+
]
70+
volumeMounts:
71+
- name: log
72+
mountPath: /k/azurecns
73+
- name: cns-config
74+
mountPath: /etc/azure-cns
75+
- name: cni-conflist
76+
mountPath: /k/azurecni/netconf
77+
ports:
78+
- containerPort: 10090
79+
hostPort: 10090
80+
name: api
81+
protocol: TCP
82+
- containerPort: 10092
83+
hostPort: 10092
84+
name: metrics
85+
protocol: TCP
86+
env:
87+
- name: PATH
88+
value: '%CONTAINER_SANDBOX_MOUNT_POINT%\Windows\System32\WindowsPowershell\v1.0\'
89+
- name: CNSIpAddress
90+
value: "127.0.0.1"
91+
- name: CNSPort
92+
value: "10090"
93+
- name: CNSLogTarget
94+
value: "stdoutfile"
95+
- name: CNSLogDir
96+
value: /k/azurecns/
97+
- name: CNSStoreFilePath
98+
value: /k/azurecns/
99+
- name: CNS_CONFIGURATION_PATH
100+
value: /etc/azure-cns/cns_config.json
101+
- name: NODENAME
102+
valueFrom:
103+
fieldRef:
104+
apiVersion: v1
105+
fieldPath: spec.nodeName
106+
initContainers:
107+
- name: init-cni-dropgz
108+
image: acnpublic.azurecr.io/cni-dropgz:CNI_DROPGZ_VERSION
109+
imagePullPolicy: Always
110+
command: ["%CONTAINER_SANDBOX_MOUNT_POINT%/dropgz.exe"]
111+
args:
112+
- deploy
113+
- azure-vnet.exe
114+
- -o
115+
- /k/azurecni/bin/azure-vnet.exe # // TODO: add windows cni conflist when ready
116+
volumeMounts:
117+
- name: cni-bin
118+
mountPath: /k/azurecni/bin/ # TODO: add cni conflist when ready
119+
hostNetwork: true
120+
volumes:
121+
- name: log
122+
hostPath:
123+
path: /k/azurecns
124+
type: DirectoryOrCreate
125+
- name: cns-config
126+
configMap:
127+
name: cns-win-config
128+
defaultMode: 420
129+
- name: cni-bin
130+
hostPath:
131+
path: /k/azurecni/bin
132+
type: Directory # // TODO: add windows cni conflist when ready
133+
serviceAccount: azure-cns
134+
serviceAccountName: azure-cns
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: cns-win-config
5+
namespace: kube-system
6+
data:
7+
cns_config.json: |
8+
{
9+
"TelemetrySettings": {
10+
"TelemetryBatchSizeBytes": 16384,
11+
"TelemetryBatchIntervalInSecs": 15,
12+
"RefreshIntervalInSecs": 15,
13+
"DisableAll": false,
14+
"HeartBeatIntervalInMins": 30,
15+
"DebugMode": false,
16+
"SnapshotIntervalInMins": 60
17+
},
18+
"ManagedSettings": {
19+
"PrivateEndpoint": "",
20+
"InfrastructureNetworkID": "",
21+
"NodeID": "",
22+
"NodeSyncIntervalInSeconds": 30
23+
},
24+
"EnableSubnetScarcity": false,
25+
"ChannelMode": "CRD",
26+
"InitializeFromCNI": true,
27+
"ManageEndpointState": false,
28+
"ProgramSNATIPTables" : false,
29+
"MetricsBindAddress": ":10092",
30+
"EnableCNIConflistGeneration": false,
31+
"CNIConflistFilepath": "C:\\k\\azurecni\\netconf\\10-azure.conflist",
32+
"CNIConflistScenario": "v4overlay"
33+
}

test/internal/kubernetes/utils.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,3 +416,18 @@ func NamespaceExists(ctx context.Context, clientset *kubernetes.Clientset, names
416416
func CreateLabelSelector(key string, selector *string) string {
417417
return fmt.Sprintf("%s=%s", key, *selector)
418418
}
419+
420+
func HasWindowsNodes(ctx context.Context, clientset *kubernetes.Clientset) (bool, error) {
421+
nodes, err := GetNodeList(ctx, clientset)
422+
if err != nil {
423+
return false, errors.Wrapf(err, "failed to get node list")
424+
}
425+
426+
for index := range nodes.Items {
427+
node := nodes.Items[index]
428+
if node.Status.NodeInfo.OperatingSystem == string(corev1.Windows) {
429+
return true, nil
430+
}
431+
}
432+
return false, nil
433+
}

0 commit comments

Comments
 (0)