samba-in-kubernetes / samba-operator

An operator for a Samba as a service on PVCs in kubernetes
Apache License 2.0
108 stars 24 forks source link

Add additional printer columns for SmbShare CR #191

Closed anoopcs9 closed 2 years ago

anoopcs9 commented 2 years ago

Apart from AGE following details are added to kubectl get output:

Before:

# kubectl get smbshares
NAME      AGE
cshare1   2m1s

After:

# kubectl get smbshares
NAME      SHARE-NAME   SHARE-PATH   AVAILABILITY   AGE
cshare1   CTDB Me                   clustered      5m1s

Above SmbShare CR was created using smbshare_ctdb1.yaml

Ref: https://book.kubebuilder.io/reference/markers/crd.html

anoopcs9 commented 2 years ago

Are there generated files that will need to be checked in?

make manifests will bring in the following required changes to SmbShare CRD.

diff --git a/config/crd/bases/samba-operator.samba.org_smbshares.yaml b/config/crd/bases/samba-operator.samba.org_smbshares.yaml
index 54d34e6..f2f6753 100644
--- a/config/crd/bases/samba-operator.samba.org_smbshares.yaml
+++ b/config/crd/bases/samba-operator.samba.org_smbshares.yaml
@@ -14,7 +14,23 @@ spec:
     singular: smbshare
   scope: Namespaced
   versions:
-    - name: v1alpha1
+    - additionalPrinterColumns:
+        - description: Name of the Samba share
+          jsonPath: .spec.shareName
+          name: Share-name
+          type: string
+        - description: Path for the share within PVC
+          jsonPath: .spec.storage.pvc.path
+          name: Share-path
+          type: string
+        - description: Samba availability mode
+          jsonPath: .spec.scaling.availabilityMode
+          name: Availability
+          type: string
+        - jsonPath: .metadata.creationTimestamp
+          name: Age
+          type: date
+      name: v1alpha1
       schema:
         openAPIV3Schema:
           description: SmbShare is the Schema for the smbshares API
@@ -46,6 +62,7 @@ spec:
                   description: Scaling specifies parameters relating to how share resources can and should be scaled.
                   properties:
                     availabilityMode:
+                      default: standard
                       description: AvailabilityMode specifies how the operator is to scale share resources for (high-)availability purposes.
                       enum:
                         - standard

May be we also add the above diff to the commit.