From c3a275252f4a54a5fe5369809fd79ff5dbaba3de Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Wed, 22 Aug 2018 12:24:53 +0200 Subject: [PATCH] Introduce new `CSINodeInfo` CRD API Object --- .../csi-api/pkg/apis/csi/v1alpha1/doc.go | 1 + .../csi-api/pkg/apis/csi/v1alpha1/register.go | 6 ++- .../csi-api/pkg/apis/csi/v1alpha1/types.go | 41 +++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/doc.go b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/doc.go index b60c9314875..59bbb3f3f0a 100644 --- a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/doc.go +++ b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/doc.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package v1alpha1 provides alpha API for CSI API objects. // +k8s:deepcopy-gen=package,register // +groupName=csi.storage.k8s.io // +k8s:openapi-gen=true diff --git a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/register.go b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/register.go index e09f9ff1c4d..3bf48fa7e50 100644 --- a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/register.go +++ b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/register.go @@ -34,8 +34,10 @@ func Resource(resource string) schema.GroupResource { } var ( + // SchemeBuilder collects schemas to build. SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) - AddToScheme = SchemeBuilder.AddToScheme + // AddToScheme is used by generated client to add this scheme to the generated client. + AddToScheme = SchemeBuilder.AddToScheme ) // Adds the list of known types to the given scheme. @@ -43,6 +45,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &CSIDriver{}, &CSIDriverList{}, + &CSINodeInfo{}, + &CSINodeInfoList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) diff --git a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/types.go b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/types.go index c09f1bc105f..457942b1f86 100644 --- a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/types.go +++ b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/types.go @@ -74,3 +74,44 @@ type CSIDriverSpec struct { // +optional PodInfoRequiredOnMount *bool `json:"podInfoRequiredOnMount"` } + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CSINodeInfo holds information about all CSI drivers installed on a node. +type CSINodeInfo struct { + metav1.TypeMeta `json:",inline"` + // ObjectMeta.Name must be node name. + metav1.ObjectMeta `json:"metadata,omitempty"` + + // List of CSI drivers running on the node and their properties. + CSIDrivers []CSIDriverInfo `json:"csiDrivers"` +} + +// CSIDriverInfo contains information about one CSI driver installed on a node. +type CSIDriverInfo struct { + // Driver is the name of the CSI driver that this object refers to. + // This MUST be the same name returned by the CSI GetPluginName() call for + // that driver. + Driver string `json:"driver"` + + // ID of the node from the driver point of view. + NodeID string `json:"nodeID"` + + // Topology keys reported by the driver on the node. + TopologyKeys []string `json:"topologyKeys"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CSINodeInfoList is a collection of CSINodeInfo objects. +type CSINodeInfoList struct { + metav1.TypeMeta `json:",inline"` + // Standard list metadata + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + // Items is the list of CSINodeInfo + Items []CSINodeInfo `json:"items"` +}