Skip to content

Commit

Permalink
feat: installing windows cns if windows nodes present (#2246)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjohnst5 authored Sep 25, 2023
1 parent 4943198 commit beeb66a
Show file tree
Hide file tree
Showing 6 changed files with 449 additions and 104 deletions.
134 changes: 134 additions & 0 deletions test/integration/manifests/cns/daemonset-windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: azure-cns-win
namespace: kube-system
labels:
app: azure-cns-win
spec:
selector:
matchLabels:
k8s-app: azure-cns-win
template:
metadata:
labels:
k8s-app: azure-cns-win
kubernetes.azure.com/managedby: aks
annotations:
cluster-autoscaler.kubernetes.io/daemonset-pod: "true"
prometheus.io/port: "10092"
spec:
securityContext:
windowsOptions:
hostProcess: true
runAsUserName: "NT AUTHORITY\\SYSTEM"
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.azure.com/cluster
operator: Exists
- key: type
operator: NotIn
values:
- virtual-kubelet
- key: kubernetes.io/os
operator: In
values:
- windows
tolerations:
- operator: "Exists"
effect: NoExecute
- operator: "Exists"
effect: NoSchedule
containers:
- name: cns-container
image: acnpublic.azurecr.io/azure-cns:latest
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
command: ["powershell.exe"]
args:
[
'.\setkubeconfigpath.ps1',
";",
'.\azure-cns.exe',
"-c",
"tcp://$(CNSIpAddress):$(CNSPort)",
"-t",
"$(CNSLogTarget)",
"-o",
"$(CNSLogDir)",
"-storefilepath",
"$(CNSStoreFilePath)",
"-config-path",
"%CONTAINER_SANDBOX_MOUNT_POINT%\\$(CNS_CONFIGURATION_PATH)",
"--kubeconfig",
'.\kubeconfig',
]
volumeMounts:
- name: log
mountPath: /k/azurecns
- name: cns-config
mountPath: /etc/azure-cns
- name: cni-conflist
mountPath: /k/azurecni/netconf
ports:
- containerPort: 10090
hostPort: 10090
name: api
protocol: TCP
- containerPort: 10092
hostPort: 10092
name: metrics
protocol: TCP
env:
- name: PATH
value: '%CONTAINER_SANDBOX_MOUNT_POINT%\Windows\System32\WindowsPowershell\v1.0\'
- name: CNSIpAddress
value: "127.0.0.1"
- name: CNSPort
value: "10090"
- name: CNSLogTarget
value: "stdoutfile"
- name: CNSLogDir
value: /k/azurecns/
- name: CNSStoreFilePath
value: /k/azurecns/
- name: CNS_CONFIGURATION_PATH
value: /etc/azure-cns/cns_config.json
- name: NODENAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
initContainers:
- name: init-cni-dropgz
image: acnpublic.azurecr.io/cni-dropgz:CNI_DROPGZ_VERSION
imagePullPolicy: Always
command: ["%CONTAINER_SANDBOX_MOUNT_POINT%/dropgz.exe"]
args:
- deploy
- azure-vnet.exe
- -o
- /k/azurecni/bin/azure-vnet.exe # // TODO: add windows cni conflist when ready
volumeMounts:
- name: cni-bin
mountPath: /k/azurecni/bin/ # TODO: add cni conflist when ready
hostNetwork: true
volumes:
- name: log
hostPath:
path: /k/azurecns
type: DirectoryOrCreate
- name: cns-config
configMap:
name: cns-win-config
defaultMode: 420
- name: cni-bin
hostPath:
path: /k/azurecni/bin
type: Directory # // TODO: add windows cni conflist when ready
serviceAccount: azure-cns
serviceAccountName: azure-cns
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cns-win-config
namespace: kube-system
data:
cns_config.json: |
{
"TelemetrySettings": {
"TelemetryBatchSizeBytes": 16384,
"TelemetryBatchIntervalInSecs": 15,
"RefreshIntervalInSecs": 15,
"DisableAll": false,
"HeartBeatIntervalInMins": 30,
"DebugMode": false,
"SnapshotIntervalInMins": 60
},
"ManagedSettings": {
"PrivateEndpoint": "",
"InfrastructureNetworkID": "",
"NodeID": "",
"NodeSyncIntervalInSeconds": 30
},
"EnableSubnetScarcity": false,
"ChannelMode": "CRD",
"InitializeFromCNI": true,
"ManageEndpointState": false,
"ProgramSNATIPTables" : false,
"MetricsBindAddress": ":10092",
"EnableCNIConflistGeneration": false,
"CNIConflistFilepath": "C:\\k\\azurecni\\netconf\\10-azure.conflist",
"CNIConflistScenario": "v4overlay"
}
15 changes: 15 additions & 0 deletions test/internal/kubernetes/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,18 @@ func NamespaceExists(ctx context.Context, clientset *kubernetes.Clientset, names
func CreateLabelSelector(key string, selector *string) string {
return fmt.Sprintf("%s=%s", key, *selector)
}

func HasWindowsNodes(ctx context.Context, clientset *kubernetes.Clientset) (bool, error) {
nodes, err := GetNodeList(ctx, clientset)
if err != nil {
return false, errors.Wrapf(err, "failed to get node list")
}

for index := range nodes.Items {
node := nodes.Items[index]
if node.Status.NodeInfo.OperatingSystem == string(corev1.Windows) {
return true, nil
}
}
return false, nil
}
Loading

0 comments on commit beeb66a

Please sign in to comment.