Skip to content

Commit

Permalink
Merge pull request #125 from zshi-redhat/ovs-hw-offload-new-api
Browse files Browse the repository at this point in the history
OVS HWOL: support multiple MCPs
  • Loading branch information
pliurh authored Jul 9, 2021
2 parents e0a92fe + 463afa9 commit 372cf5b
Show file tree
Hide file tree
Showing 26 changed files with 637 additions and 422 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ _build-%:
_plugin-%: vet
@hack/build-plugins.sh $*

plugins: _plugin-intel _plugin-mellanox _plugin-generic _plugin-virtual _plugin-mco _plugin-k8s
plugins: _plugin-intel _plugin-mellanox _plugin-generic _plugin-virtual _plugin-k8s

clean:
@rm -rf $(TARGET_DIR)
Expand Down
9 changes: 5 additions & 4 deletions api/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ import (
)

const (
LASTNETWORKNAMESPACE = "operator.sriovnetwork.openshift.io/last-network-namespace"
FINALIZERNAME = "netattdef.finalizers.sriovnetwork.openshift.io"
ESWITCHMODE_LEGACY = "legacy"
ESWITCHMODE_SWITCHDEV = "switchdev"
LASTNETWORKNAMESPACE = "operator.sriovnetwork.openshift.io/last-network-namespace"
NETATTDEFFINALIZERNAME = "netattdef.finalizers.sriovnetwork.openshift.io"
POOLCONFIGFINALIZERNAME = "poolconfig.finalizers.sriovnetwork.openshift.io"
ESWITCHMODE_LEGACY = "legacy"
ESWITCHMODE_SWITCHDEV = "switchdev"
)

const invalidVfIndex = -1
Expand Down
49 changes: 49 additions & 0 deletions api/v1/sriovnetworkpoolconfig_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package v1

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

// SriovNetworkPoolConfigSpec defines the desired state of SriovNetworkPoolConfig
type SriovNetworkPoolConfigSpec struct {
// OvsHardwareOffloadConfig describes the OVS HWOL configuration for selected Nodes
OvsHardwareOffloadConfig OvsHardwareOffloadConfig `json:"ovsHardwareOffloadConfig,omitempty"`
}

type OvsHardwareOffloadConfig struct {
// Name is mandatory and must be unique.
// On Kubernetes:
// Name is the name of OvsHardwareOffloadConfig
// On OpenShift:
// Name is the name of MachineConfigPool to be enabled with OVS hardware offload
Name string `json:"name,omitempty"`
}

// SriovNetworkPoolConfigStatus defines the observed state of SriovNetworkPoolConfig
type SriovNetworkPoolConfigStatus struct {
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

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

Spec SriovNetworkPoolConfigSpec `json:"spec,omitempty"`
Status SriovNetworkPoolConfigStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&SriovNetworkPoolConfig{}, &SriovNetworkPoolConfigList{})
}
105 changes: 105 additions & 0 deletions api/v1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.3.0
creationTimestamp: null
name: sriovnetworkpoolconfigs.sriovnetwork.openshift.io
spec:
group: sriovnetwork.openshift.io
names:
kind: SriovNetworkPoolConfig
listKind: SriovNetworkPoolConfigList
plural: sriovnetworkpoolconfigs
singular: sriovnetworkpoolconfig
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
description: SriovNetworkPoolConfig is the Schema for the sriovnetworkpoolconfigs
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: SriovNetworkPoolConfigSpec defines the desired state of SriovNetworkPoolConfig
properties:
ovsHardwareOffloadConfig:
description: OvsHardwareOffloadConfig describes the OVS HWOL configuration
for selected Nodes
properties:
name:
description: 'Name is mandatory and must be unique. On Kubernetes:
Name is the name of OvsHardwareOffloadConfig On OpenShift: Name
is the name of MachineConfigPool to be enabled with OVS hardware
offload'
type: string
type: object
type: object
status:
description: SriovNetworkPoolConfigStatus defines the observed state of
SriovNetworkPoolConfig
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
9 changes: 6 additions & 3 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ resources:
- bases/sriovnetwork.openshift.io_sriovibnetworks.yaml
- bases/sriovnetwork.openshift.io_sriovnetworknodepolicies.yaml
- bases/sriovnetwork.openshift.io_sriovoperatorconfigs.yaml
#+kubebuilder:scaffold:crdkustomizeresource
- bases/sriovnetwork.openshift.io_sriovnetworkpoolconfigs.yaml
# +kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
Expand All @@ -17,7 +18,8 @@ patchesStrategicMerge:
#- patches/webhook_in_sriovibnetworks.yaml
#- patches/webhook_in_sriovnetworknodepolicies.yaml
#- patches/webhook_in_sriovoperatorconfigs.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch
#- patches/webhook_in_sriovnetworkpoolconfigs.yaml
# +kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
Expand All @@ -26,7 +28,8 @@ patchesStrategicMerge:
#- patches/cainjection_in_sriovibnetworks.yaml
#- patches/cainjection_in_sriovnetworknodepolicies.yaml
#- patches/cainjection_in_sriovoperatorconfigs.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
#- patches/cainjection_in_sriovnetworkpoolconfigs.yaml
# +kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
configurations:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
# CRD conversion requires k8s 1.13 or later.
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: sriovnetworkpoolconfigs.sriovnetwork.openshift.io
17 changes: 17 additions & 0 deletions config/crd/patches/webhook_in_sriovnetworkpoolconfigs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# The following patch enables conversion webhook for CRD
# CRD conversion requires k8s 1.13 or later.
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: sriovnetworkpoolconfigs.sriovnetwork.openshift.io
spec:
conversion:
strategy: Webhook
webhookClientConfig:
# this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank,
# but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager)
caBundle: Cg==
service:
namespace: system
name: webhook-service
path: /convert
24 changes: 24 additions & 0 deletions config/rbac/sriovnetworkpoolconfig_editor_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# permissions for end users to edit sriovnetworkpoolconfigs.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: sriovnetworkpoolconfig-editor-role
rules:
- apiGroups:
- sriovnetwork.openshift.io
resources:
- sriovnetworkpoolconfigs
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- sriovnetwork.openshift.io
resources:
- sriovnetworkpoolconfigs/status
verbs:
- get
20 changes: 20 additions & 0 deletions config/rbac/sriovnetworkpoolconfig_viewer_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# permissions for end users to view sriovnetworkpoolconfigs.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: sriovnetworkpoolconfig-viewer-role
rules:
- apiGroups:
- sriovnetwork.openshift.io
resources:
- sriovnetworkpoolconfigs
verbs:
- get
- list
- watch
- apiGroups:
- sriovnetwork.openshift.io
resources:
- sriovnetworkpoolconfigs/status
verbs:
- get
7 changes: 7 additions & 0 deletions config/samples/sriovnetwork_v1_sriovnetworkpoolconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: sriovnetwork.openshift.io/v1
kind: SriovNetworkPoolConfig
metadata:
name: sriovnetworkpoolconfig-sample
spec:
# Add fields here
foo: bar
Loading

0 comments on commit 372cf5b

Please sign in to comment.