Search code examples
amazon-s3bucketobject-storagenoobaa-data-services

How to check content of a Noobaa bucket


I am able to check status of Nooba bucket using noobaa bucket status <bucket> command.

$ noobaa bucket status XYZ
INFO[0005] ✅ Exists: NooBaa "noobaa"                    
INFO[0005] ✅ Exists: Service "noobaa-mgmt"              
INFO[0006] ✅ Exists: Secret "noobaa-operator"           
INFO[0006] ✅ Exists: Secret "noobaa-admin"              
INFO[0008] ✈️  RPC: bucket.read_bucket() Request: {Name:XYZ} 
INFO[0010] ✅ RPC: bucket.read_bucket() Response OK: took 14.3ms 

Bucket status:
  Bucket                 : XYZ
  OBC Namespace          : xyz-namespace
  OBC BucketClass        : default-bucket-class
  Type                   : REGULAR
  Mode                   : OPTIMAL
  ResiliencyStatus       : OPTIMAL
  QuotaStatus            : QUOTA_NOT_SET
  Num Objects            : 1
  Data Size              : 3.000 B
  Data Size Reduced      : 5.000 B
  Data Space Avail       : 1.000 PB

But I am not able to check content present inside Noobaa bucket.

How can we check content of a Noobaa bucket? using Noobaa CLI or any other way?


Solution

  • Your question made me realize that noobaa CLI should have noobaa object list command so I opened a new issue for this enhancement on the operator github repo. Thanks :)

    Until this is added, there are several ways we use to list objects:

    1. run noobaa ui - notice that it opens the browser quickly, but on the terminal it prints the credentials for you to use for login. You can probably find the buckets and the drill down to the objects in the UI on your own, and you can also check out some recorded videos that navigate the UI - for example this video.

    2. Take the admin S3 credentials and endpoint from noobaa status and then use your favorite s3 client - I currently use aws-cli or rclone:

      alias s3='AWS_ACCESS_KEY_ID=$NOOBAA_ACCESS_KEY AWS_SECRET_ACCESS_KEY=$NOOBAA_SECRET_KEY aws --endpoint $NOOBAA_S3_ENDPOINT --no-verify-ssl s3'
      

      and then:

      s3 ls XYZ
      
    3. Not many noticed but the NooBaa system CR contains a useful Readme text in its status, with commands to "Test S3 client" - ready to copy-paste to set up your aws-cli, including kubectl port-forward to support secure networks and reading the credentials from secrets. Check it out with kubectl describe noobaa. This 40 seconds youtube video shows this briefly. BTW, the readme text is generated for the system but its text does not contain actual secrets, only kubectl commands to read those secrets if permitted to.

      $ kubectl describe noobaa
      ...
      
      Phase:                Ready
      Readme:
      
      Welcome to NooBaa!
      -----------------
      NooBaa Core Version:     5.3.0-9f579d9
      NooBaa Operator Version: 2.1.0
      
      Lets get started:
      
      1. Connect to Management console:
      
          Read your mgmt console login information (email & password) from secret: "noobaa-admin".
      
          kubectl get secret noobaa-admin -n backup-service -o json | jq '.data|map_values(@base64d)'
      
          Open the management console service - take External IP/DNS or Node Port or use port forwarding:
      
          kubectl port-forward -n backup-service service/noobaa-mgmt 11443:443 &
          open https://localhost:11443
      
      2. Test S3 client:
      
          kubectl port-forward -n backup-service service/s3 10443:443 &
          NOOBAA_ACCESS_KEY=$(kubectl get secret noobaa-admin -n backup-service -o json | jq -r '.data.AWS_ACCESS_KEY_ID|@base64d')
          NOOBAA_SECRET_KEY=$(kubectl get secret noobaa-admin -n backup-service -o json | jq -r '.data.AWS_SECRET_ACCESS_KEY|@base64d')
          alias s3='AWS_ACCESS_KEY_ID=$NOOBAA_ACCESS_KEY AWS_SECRET_ACCESS_KEY=$NOOBAA_SECRET_KEY aws --endpoint https://localhost:10443 --no-verify-ssl s3'
          s3 ls
      
      ...
      
    4. Last option, which should have been mentioned first, but unfortunately I just saw it is broken in the current version v2.1.0 (opened new issue), is to use the generic noobaa api command in order to call the object_api list_objects method like so:

      noobaa api object list_objects '{ "bucket": "first.bucket" }'
      

    I hope that helps, feel free to open github issues with suggestions/issues.

    Thanks!

    (NooBaa CTO)