Skip to content

Commit

Permalink
Merge pull request #296 from subhamkrai/add-radosgw-admin
Browse files Browse the repository at this point in the history
core: adding 'radosgw-admin' command support
  • Loading branch information
subhamkrai authored Jun 6, 2024
2 parents 5cd1e23 + e89ebf7 commit bb975f7
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/go-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ jobs:
set -ex
kubectl rook-ceph --context=$(kubectl config current-context) rados df
- name: radosgw-admin create user
run: |
set -ex
kubectl rook-ceph radosgw-admin user create --display-name="johnny rotten" --uid=johnny
- name: Mon restore
run: |
set -ex
Expand Down Expand Up @@ -238,6 +243,11 @@ jobs:
set -ex
kubectl rook-ceph --operator-namespace test-operator -n test-cluster rados df
- name: radosgw-admin create user
run: |
set -ex
kubectl rook-ceph --operator-namespace test-operator -n test-cluster radosgw-admin user create --display-name="johnny rotten" --uid=johnny
- name: Ceph status using context
run: |
set -ex
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ These are args currently supported:

- `rados <args>` : Run a Rados CLI command. Supports any arguments the `rados` command supports. See [Rados docs](https://docs.ceph.com/en/latest/man/8/rados/) for more.

- `radosgw-admin <args>` : Run an RGW CLI command. Supports any arguments the `radosgw-admin` command supports. See the [radosgw-admin docs](https://docs.ceph.com/en/latest/man/8/radosgw-admin/) for more.

- `rbd <args>` : Call a 'rbd' CLI command with arbitrary args

- `mons` : Print mon endpoints
Expand Down
42 changes: 42 additions & 0 deletions cmd/commands/radosgw.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright 2024 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package command

import (
"github.com/rook/kubectl-rook-ceph/pkg/exec"
"github.com/rook/kubectl-rook-ceph/pkg/logging"
"github.com/spf13/cobra"
)

// RadosgwCmd represents the radosgw command
var RadosgwCmd = &cobra.Command{
Use: "radosgw-admin",
Short: "call a 'radosgw-admin' CLI command",
DisableFlagParsing: true,
Args: cobra.MinimumNArgs(1),
PreRun: func(cmd *cobra.Command, args []string) {
verifyOperatorPodIsRunning(cmd.Context(), clientSets)
},
Run: func(cmd *cobra.Command, args []string) {
logging.Info("running 'radosgw-admin' command with args: %v", args)
_, err := exec.RunCommandInOperatorPod(cmd.Context(), clientSets, cmd.Use, args, operatorNamespace, cephClusterNamespace, false)
if err != nil {
logging.Fatal(err)
}
},
}
1 change: 1 addition & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ func addcommands() {
command.SubvolumeCmd,
command.RadosCmd,
command.FlattenRBDPVCCmd,
command.RadosgwCmd,
)
}
18 changes: 18 additions & 0 deletions docs/radosgw-admin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# radosgw-admin

This runs any radosgw-admin CLI command with arbitrary args.

## Examples

```bash
kubectl rook-ceph radosgw-admin user create --display-name="my user" --uid=myuser

# Info: running 'radosgw-admin' command with args: [user create --display-name=my-user --uid=myuser]
# {
# "user_id": "myuser",
# "display_name": "my user",
# ...
# ...
# ...
# }
```
2 changes: 2 additions & 0 deletions pkg/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ func execCmdInPod(ctx context.Context, clientsets *k8sutil.Clientsets,
cmd = append(cmd, fmt.Sprintf("--conf=/var/lib/rook/%s/%s.config", clusterNamespace, clusterNamespace))
} else if cmd[0] == "rados" {
cmd = append(cmd, fmt.Sprintf("--conf=/var/lib/rook/%s/%s.config", clusterNamespace, clusterNamespace))
} else if cmd[0] == "radosgw-admin" {
cmd = append(cmd, fmt.Sprintf("--conf=/var/lib/rook/%s/%s.config", clusterNamespace, clusterNamespace))
}

// Prepare the API URL used to execute another process within the Pod. In
Expand Down

0 comments on commit bb975f7

Please sign in to comment.