From 43ed0f422343e291b418f6de5b12319036847476 Mon Sep 17 00:00:00 2001 From: Thomas Ferrandiz Date: Mon, 2 Sep 2024 14:20:09 +0000 Subject: [PATCH 1/3] Add missing crds and options in the chart --- .../crds/whereabouts.cni.cncf.io_ippools.yaml | 36 +++++---- ...hereabouts.cni.cncf.io_nodeslicepools.yaml | 79 +++++++++++++++++++ ...ncf.io_overlappingrangeipreservations.yaml | 31 ++++---- .../templates/cluster_role.yaml | 7 ++ .../templates/node-slice-controller.yaml | 4 +- deployment/whereabouts-chart/values.yaml | 3 + 6 files changed, 127 insertions(+), 33 deletions(-) create mode 100644 deployment/whereabouts-chart/crds/whereabouts.cni.cncf.io_nodeslicepools.yaml diff --git a/deployment/whereabouts-chart/crds/whereabouts.cni.cncf.io_ippools.yaml b/deployment/whereabouts-chart/crds/whereabouts.cni.cncf.io_ippools.yaml index c912654e3..8e0ef3628 100644 --- a/deployment/whereabouts-chart/crds/whereabouts.cni.cncf.io_ippools.yaml +++ b/deployment/whereabouts-chart/crds/whereabouts.cni.cncf.io_ippools.yaml @@ -1,9 +1,9 @@ +--- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.4.1 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.14.0 name: ippools.whereabouts.cni.cncf.io spec: group: whereabouts.cni.cncf.io @@ -20,14 +20,19 @@ spec: description: IPPool is the Schema for the ippools API properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object @@ -41,14 +46,17 @@ spec: properties: id: type: string + ifname: + type: string podref: type: string required: - id + - podref type: object - description: Allocations is the set of allocated IPs for the given - range. Its` indices are a direct mapping to the IP with the same - index/offset for the pool's range. + description: |- + Allocations is the set of allocated IPs for the given range. Its` indices are a direct mapping to the + IP with the same index/offset for the pool's range. type: object range: description: Range is a RFC 4632/4291-style string that represents @@ -61,9 +69,3 @@ spec: type: object served: true storage: true -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/deployment/whereabouts-chart/crds/whereabouts.cni.cncf.io_nodeslicepools.yaml b/deployment/whereabouts-chart/crds/whereabouts.cni.cncf.io_nodeslicepools.yaml new file mode 100644 index 000000000..113d0837f --- /dev/null +++ b/deployment/whereabouts-chart/crds/whereabouts.cni.cncf.io_nodeslicepools.yaml @@ -0,0 +1,79 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: nodeslicepools.whereabouts.cni.cncf.io +spec: + group: whereabouts.cni.cncf.io + names: + kind: NodeSlicePool + listKind: NodeSlicePoolList + plural: nodeslicepools + singular: nodeslicepool + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: NodeSlicePool is the Schema for the nodesliceippools API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: NodeSlicePoolSpec defines the desired state of NodeSlicePool + properties: + range: + description: |- + Range is a RFC 4632/4291-style string that represents an IP address and prefix length in CIDR notation + this refers to the entire range where the node is allocated a subset + type: string + sliceSize: + description: SliceSize is the size of subnets or slices of the range + that each node will be assigned + type: string + required: + - range + - sliceSize + type: object + status: + description: NodeSlicePoolStatus defines the desired state of NodeSlicePool + properties: + allocations: + description: Allocations holds the allocations of nodes to slices + items: + properties: + nodeName: + description: NodeName is the name of the node assigned to this + slice, empty node name is an available slice for assignment + type: string + sliceRange: + description: SliceRange is the subnet of this slice + type: string + required: + - nodeName + - sliceRange + type: object + type: array + required: + - allocations + type: object + type: object + served: true + storage: true diff --git a/deployment/whereabouts-chart/crds/whereabouts.cni.cncf.io_overlappingrangeipreservations.yaml b/deployment/whereabouts-chart/crds/whereabouts.cni.cncf.io_overlappingrangeipreservations.yaml index 82d9547d4..f95cdfb8b 100644 --- a/deployment/whereabouts-chart/crds/whereabouts.cni.cncf.io_overlappingrangeipreservations.yaml +++ b/deployment/whereabouts-chart/crds/whereabouts.cni.cncf.io_overlappingrangeipreservations.yaml @@ -1,9 +1,9 @@ +--- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.4.1 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.14.0 name: overlappingrangeipreservations.whereabouts.cni.cncf.io spec: group: whereabouts.cni.cncf.io @@ -21,14 +21,19 @@ spec: API properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object @@ -38,19 +43,15 @@ spec: properties: containerid: type: string + ifname: + type: string podref: type: string required: - - containerid + - podref type: object required: - spec type: object served: true storage: true -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/deployment/whereabouts-chart/templates/cluster_role.yaml b/deployment/whereabouts-chart/templates/cluster_role.yaml index 61a732d22..cb97aa931 100644 --- a/deployment/whereabouts-chart/templates/cluster_role.yaml +++ b/deployment/whereabouts-chart/templates/cluster_role.yaml @@ -30,6 +30,13 @@ rules: - get - list - watch +- apiGroups: [""] + resources: + - nodes + verbs: + - get + - list + - watch - apiGroups: ["k8s.cni.cncf.io"] resources: - network-attachment-definitions diff --git a/deployment/whereabouts-chart/templates/node-slice-controller.yaml b/deployment/whereabouts-chart/templates/node-slice-controller.yaml index 889905a61..303b6cef7 100644 --- a/deployment/whereabouts-chart/templates/node-slice-controller.yaml +++ b/deployment/whereabouts-chart/templates/node-slice-controller.yaml @@ -1,3 +1,4 @@ +{{- if .Values.nodeSliceController.enabled }} apiVersion: apps/v1 kind: Deployment metadata: @@ -84,4 +85,5 @@ spec: - fieldRef: apiVersion: v1 fieldPath: metadata.namespace - path: namespace \ No newline at end of file + path: namespace +{{- end}} diff --git a/deployment/whereabouts-chart/values.yaml b/deployment/whereabouts-chart/values.yaml index f632a5568..d241e73f3 100644 --- a/deployment/whereabouts-chart/values.yaml +++ b/deployment/whereabouts-chart/values.yaml @@ -52,3 +52,6 @@ affinity: {} cniConf: confDir: /etc/cni/net.d binDir: /opt/cni/bin + +nodeSliceController: + enabled: true From ea3fc07f5bf655ff90a74417f5f47c6c93701be7 Mon Sep 17 00:00:00 2001 From: Thomas Ferrandiz Date: Tue, 3 Sep 2024 12:00:08 +0000 Subject: [PATCH 2/3] Update generate script to created crds for the chart --- hack/generate-code.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/generate-code.sh b/hack/generate-code.sh index 93eb2c563..c8b9ed355 100755 --- a/hack/generate-code.sh +++ b/hack/generate-code.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash BASEDIR=$(pwd) -${BASEDIR}/bin/controller-gen object crd:crdVersions=v1 paths="./..." output:crd:artifacts:config=doc/crds +${BASEDIR}/bin/controller-gen object crd:crdVersions=v1 paths="./..." output:crd:artifacts:config=doc/crds output:crd:artifacts:config=deployment/whereabouts-chart/crds From 5fbbf5e95851260fdf03338d8c3c0c020362cb45 Mon Sep 17 00:00:00 2001 From: Thomas Ferrandiz Date: Tue, 3 Sep 2024 15:54:22 +0000 Subject: [PATCH 3/3] remove outdated cronjob.yaml --- .../whereabouts-chart/templates/cronjob.yaml | 57 ------------------- 1 file changed, 57 deletions(-) delete mode 100644 deployment/whereabouts-chart/templates/cronjob.yaml diff --git a/deployment/whereabouts-chart/templates/cronjob.yaml b/deployment/whereabouts-chart/templates/cronjob.yaml deleted file mode 100644 index 9a3eb65cc..000000000 --- a/deployment/whereabouts-chart/templates/cronjob.yaml +++ /dev/null @@ -1,57 +0,0 @@ -apiVersion: batch/v1beta1 -kind: CronJob -metadata: - name: {{ include "whereabouts.fullname" . }} - {{- include "whereabouts.namespace" . | nindent 2 }} - labels: - {{- include "whereabouts.labels" . | nindent 4 }} -spec: - concurrencyPolicy: Forbid - successfulJobsHistoryLimit: {{ .Values.successfulJobsHistoryLimit | default "0" }} - schedule: "*/5 * * * *" - jobTemplate: - spec: - backoffLimit: 0 - template: - metadata: - labels: - name: whereabouts - {{- include "whereabouts.selectorLabels" . | nindent 12 }} - spec: - priorityClassName: "system-node-critical" - serviceAccountName: {{ include "whereabouts.serviceAccountName" . }} - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 12 }} - {{- end }} - containers: - - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 16 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - resources: - {{- toYaml .Values.resources | nindent 16 }} - command: - - /ip-reconciler - - -log-level=verbose - volumeMounts: - - name: cni-net-dir - mountPath: /host/etc/cni/net.d - volumes: - - name: cni-net-dir - hostPath: - path: /etc/cni/net.d - restartPolicy: OnFailure - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 12 }} - {{- end }}