From d0c6256288cb0051f01baf2c22174054d4b5e8e7 Mon Sep 17 00:00:00 2001 From: whg517 Date: Fri, 2 Aug 2024 20:18:05 +0800 Subject: [PATCH] feat: add short name and some other mark for crds (#75) --- api/v1alpha1/zookeepercluster_types.go | 8 +++++++ api/v1alpha1/zookeeperznode_types.go | 6 +++-- ...okeeper.zncdata.dev_zookeeperclusters.yaml | 9 +++++++- ...zookeeper.zncdata.dev_zookeeperznodes.yaml | 3 +++ ...keeper-operator.clusterserviceversion.yaml | 22 +++++++++++++++++++ 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/api/v1alpha1/zookeepercluster_types.go b/api/v1alpha1/zookeepercluster_types.go index fc55450..fb27a1a 100644 --- a/api/v1alpha1/zookeepercluster_types.go +++ b/api/v1alpha1/zookeepercluster_types.go @@ -49,7 +49,15 @@ const ( ) // +kubebuilder:object:root=true +// +kubebuilder:resource:path=zookeeperclusters,scope=Namespaced,shortName=zk;zks,singular=zookeepercluster // +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" +// +operator-sdk:csv:customresourcedefinitions:displayName="Zookeeper Cluster" +// This annotation provides a hint for OLM which resources are managed by SparkHistoryServer kind. +// It's not mandatory to list all resources. +// https://sdk.operatorframework.io/docs/olm-integration/generation/#csv-fields +// https://sdk.operatorframework.io/docs/building-operators/golang/references/markers/ +// +operator-sdk:csv:customresourcedefinitions:resources={{Deployment,app/v1},{Service,v1},{Pod,v1},{ConfigMap,v1},{PersistentVolumeClaim,v1},{PersistentVolume,v1},{PodDisruptionBudget,v1}} // ZookeeperCluster is the Schema for the zookeeperclusters API type ZookeeperCluster struct { diff --git a/api/v1alpha1/zookeeperznode_types.go b/api/v1alpha1/zookeeperznode_types.go index 74c00b8..4463e5e 100644 --- a/api/v1alpha1/zookeeperznode_types.go +++ b/api/v1alpha1/zookeeperznode_types.go @@ -20,8 +20,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:resource:path=zookeeperznodes,shortName=znode;znodes,singular=zookeeperznode +// +kubebuilder:subresource:status +// +operator-sdk:csv:customresourcedefinitions:displayName="Zookeeper Znode" // ZookeeperZnode is the Schema for the zookeeperznodes API type ZookeeperZnode struct { diff --git a/config/crd/bases/zookeeper.zncdata.dev_zookeeperclusters.yaml b/config/crd/bases/zookeeper.zncdata.dev_zookeeperclusters.yaml index 17e259e..75ae313 100644 --- a/config/crd/bases/zookeeper.zncdata.dev_zookeeperclusters.yaml +++ b/config/crd/bases/zookeeper.zncdata.dev_zookeeperclusters.yaml @@ -11,10 +11,17 @@ spec: kind: ZookeeperCluster listKind: ZookeeperClusterList plural: zookeeperclusters + shortNames: + - zk + - zks singular: zookeepercluster scope: Namespaced versions: - - name: v1alpha1 + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 schema: openAPIV3Schema: description: ZookeeperCluster is the Schema for the zookeeperclusters API diff --git a/config/crd/bases/zookeeper.zncdata.dev_zookeeperznodes.yaml b/config/crd/bases/zookeeper.zncdata.dev_zookeeperznodes.yaml index 6e4bd23..c1e105d 100644 --- a/config/crd/bases/zookeeper.zncdata.dev_zookeeperznodes.yaml +++ b/config/crd/bases/zookeeper.zncdata.dev_zookeeperznodes.yaml @@ -11,6 +11,9 @@ spec: kind: ZookeeperZnode listKind: ZookeeperZnodeList plural: zookeeperznodes + shortNames: + - znode + - znodes singular: zookeeperznode scope: Namespaced versions: diff --git a/config/manifests/bases/zookeeper-operator.clusterserviceversion.yaml b/config/manifests/bases/zookeeper-operator.clusterserviceversion.yaml index 512961e..3a6d5ba 100644 --- a/config/manifests/bases/zookeeper-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/zookeeper-operator.clusterserviceversion.yaml @@ -15,6 +15,28 @@ spec: displayName: Zookeeper Cluster kind: ZookeeperCluster name: zookeeperclusters.zookeeper.zncdata.dev + resources: + - kind: ConfigMap + name: "" + version: v1 + - kind: Deployment + name: "" + version: app/v1 + - kind: PersistentVolume + name: "" + version: v1 + - kind: PersistentVolumeClaim + name: "" + version: v1 + - kind: Pod + name: "" + version: v1 + - kind: PodDisruptionBudget + name: "" + version: v1 + - kind: Service + name: "" + version: v1 version: v1alpha1 - description: ZookeeperZnode is the Schema for the zookeeperznodes API displayName: Zookeeper Znode