Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPoIB Network support #350

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions api/v1alpha1/ipoibnetwork_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
2022 NVIDIA CORPORATION & AFFILIATES

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
IPoIBNetworkCRDName = "IPoIBNetwork"
)

// IPoIBNetworkSpec defines the desired state of IPoIBNetwork
type IPoIBNetworkSpec struct {
// Namespace of the NetworkAttachmentDefinition custom resource
NetworkNamespace string `json:"networkNamespace,omitempty"`
// Name of the host interface to enslave. Defaults to default route interface
Master string `json:"master,omitempty"`
// IPAM configuration to be used for this network.
IPAM string `json:"ipam,omitempty"`
}

// IPoIBNetworkStatus defines the observed state of IPoIBNetwork
type IPoIBNetworkStatus struct {
// Reflects the state of the IPoIBNetwork
// +kubebuilder:validation:Enum={"notReady", "ready", "error"}
State State `json:"state"`
// Network attachment definition generated from IPoIBNetworkSpec
IPoIBNetworkAttachmentDef string `json:"ipoibNetworkAttachmentDef,omitempty"`
// Informative string in case the observed state is error
Reason string `json:"reason,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:object:generate=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.state`,priority=0
// +kubebuilder:printcolumn:name="Age",type=string,JSONPath=`.metadata.creationTimestamp`,priority=0

// IPoIBNetwork is the Schema for the ipoibnetworks API
type IPoIBNetwork struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec IPoIBNetworkSpec `json:"spec,omitempty"`
Status IPoIBNetworkStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:object:generate=true

// IPoIBNetworkList contains a list of IPoIBNetwork
type IPoIBNetworkList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []IPoIBNetwork `json:"items"`
}

func init() {
SchemeBuilder.Register(&IPoIBNetwork{}, &IPoIBNetworkList{})
}
2 changes: 2 additions & 0 deletions api/v1alpha1/nicclusterpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ type SecondaryNetworkSpec struct {
Multus *MultusSpec `json:"multus,omitempty"`
// Image information for CNI plugins
CniPlugins *ImageSpec `json:"cniPlugins,omitempty"`
// Image information for IPoIB CNI
IPoIB *ImageSpec `json:"ipoib,omitempty"`
// Image information for IPAM plugin
IpamPlugin *ImageSpec `json:"ipamPlugin,omitempty"`
}
Expand Down
95 changes: 94 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 86 additions & 0 deletions config/crd/bases/mellanox.com_ipoibnetworks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
creationTimestamp: null
name: ipoibnetworks.mellanox.com
spec:
group: mellanox.com
names:
kind: IPoIBNetwork
listKind: IPoIBNetworkList
plural: ipoibnetworks
singular: ipoibnetwork
scope: Cluster
versions:
- additionalPrinterColumns:
- jsonPath: .status.state
name: Status
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: IPoIBNetwork is the Schema for the ipoibnetworks 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: IPoIBNetworkSpec defines the desired state of IPoIBNetwork
properties:
ipam:
description: IPAM configuration to be used for this network.
type: string
master:
description: Name of the host interface to enslave. Defaults to default
route interface
type: string
networkNamespace:
description: Namespace of the NetworkAttachmentDefinition custom resource
type: string
type: object
status:
description: IPoIBNetworkStatus defines the observed state of IPoIBNetwork
properties:
ipoibNetworkAttachmentDef:
description: Network attachment definition generated from IPoIBNetworkSpec
type: string
reason:
description: Informative string in case the observed state is error
type: string
state:
description: Reflects the state of the IPoIBNetwork
enum:
- notReady
- ready
- error
type: string
required:
- state
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
21 changes: 21 additions & 0 deletions config/crd/bases/mellanox.com_nicclusterpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,27 @@ spec:
- repository
- version
type: object
ipoib:
description: Image information for IPoIB CNI
properties:
image:
pattern: '[a-zA-Z0-9\-]+'
type: string
imagePullSecrets:
items:
type: string
type: array
repository:
pattern: '[a-zA-Z0-9\.\-\/]+'
type: string
version:
pattern: '[a-zA-Z0-9\.-]+'
type: string
required:
- image
- repository
- version
type: object
multus:
description: Image and configuration information for multus
properties:
Expand Down
1 change: 1 addition & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ resources:
- bases/mellanox.com_macvlannetworks.yaml
- bases/mellanox.com_nicclusterpolicies.yaml
- bases/mellanox.com_hostdevicenetworks.yaml
- bases/mellanox.com_ipoibnetworks.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ spec:
- kind: MacvlanNetwork
name: macvlannetworks.mellanox.com
version: v1alpha1
- kind: IPoIBNetwork
name: ipoibnetworks.mellanox.com
version: v1alpha1
- kind: NetworkAttachmentDefinition
name: network-attachment-definitions.k8s.cni.cncf.io
version: v1
Expand Down
20 changes: 20 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,26 @@ rules:
- get
- patch
- update
- apiGroups:
- mellanox.com
resources:
- ipoibnetworks
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- mellanox.com
resources:
- ipoibnetworks/status
verbs:
- get
- patch
- update
- apiGroups:
- mellanox.com
resources:
Expand Down
1 change: 1 addition & 0 deletions config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ resources:
- mellanox.com_v1alpha1_macvlannetwork.yaml
- mellanox.com_v1alpha1_nicclusterpolicy.yaml
- mellanox.com_v1alpha1_hostdevicenetwork.yaml
- mellanox.com_v1alpha1_ipoibnetwork.yaml
#+kubebuilder:scaffold:manifestskustomizesamples
29 changes: 29 additions & 0 deletions config/samples/mellanox.com_v1alpha1_ipoibnetwork.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 2022 NVIDIA CORPORATION & AFFILIATES
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: mellanox.com/v1alpha1
kind: IPoIBNetwork
metadata:
name: example-ipoibnetwork
spec:
networkNamespace: "default"
master: "ibs3f1"
ipam: |
{
"type": "whereabouts",
"range": "192.168.6.225/28",
"exclude": [
"192.168.6.229/30",
"192.168.6.236/32"
]
}
Loading