A toolbox for OSD!
osdctl is a cli tool intended to eliminate toils for SREs when managing OSD related work.
Currently, it mainly supports related work for AWS, especially aws-account-operator.
- Go >= 1.13
- make
git clone https://github.com/openshift/osd-utils-cli.git
make build
Then you can find the osdctl
binary file in the ./bin
directory.
TBD
make test
For the detailed usage of each command, please refer to here.
reset
command resets the Account CR status and cleans up related secrets.
osdctl account reset test-cr
Reset account test-cr? (Y/N) y
Deleting secret test-cr-osdmanagedadminsre-secret
Deleting secret test-cr-secret
Deleting secret test-cr-sre-cli-credentials
Deleting secret test-cr-sre-console-url
You can skip the prompt by adding a flag -y
, but it is not recommended.
osdctl account reset test-cr -y
set
command enables you to patch Account CR status directly.
There are two ways of status patching:
- Using flags.
osdctl account set test-cr --state=Creating -r=true
- Using raw data. For patch strategy, only
merge
andjson
are supported. The default ismerge
.
osdctl account set test-cr --patch='{"status":{"state": "Failed", "claimed": false}}'
list account
command lists the Account CRs in the cluster. You can use flags to filter the status.
osdctl account list account --state=Creating
Name State AWS ACCOUNT ID Last Probe Time Last Transition Time Message
test-cr Creating 181787396432 2020-06-18 10:38:40 -0400 EDT 2020-06-18 10:38:40 -0400 EDT AWS account already created
# filter accounts by reused or claimed status
osdctl account list --reuse=true --claim=false
# custom output using jsonpath
osdctl account list -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.awsAccountID}{"\t"}{.status.state}{"\n"}{end}'
test-cr Creating 111111111111 2020-06-18 10:38:40 -0400 EDT 2020-06-18 10:38:40 -0400 EDT AWS account already created
list account-claim
command lists the Account Claim CRs in the cluster. You can use flags to filter the status.
osdctl account list account-claim --state=Ready
console
command generates an AWS console URL for the specified Account CR or AWS Account ID.
# generate console URL via Account CR name
osdctl account console -a test-cr
# generate console URL via AWS Account ID
osdctl account console -i 1111111111
clean-velero-snapshots
command cleans up the Velero managed buckets for the specified Account.
# clean up by providing the credentials via flags
osdctl account clean-velero-snapshots -a <AWS ACCESS KEY ID> -x <AWS SECRET ACCESS KEY>
# if flags are not provided, it will get credentials from credentials file,
# we also support specifying profile and config file path
osdctl account clean-velero-snapshots -p <profile name> -c <config file path>
check-secrets
command checks the IAM User Secret associated with Account Accout CR.
# no argument, check all account secrets
osdctl account check-secrets
# specify the Account CR name, then only check the IAM User Secret for that Account.
osdctl account check-secrets <Account CR Name>
- Get AWS Account Operator related resources
# Get Account Name by AWS Account ID, output to json
osdctl account get account -i <Account ID> -o json
# Get Account Claim CR by Account CR Name
osdctl account get account-claim -a <Account CR Name>
# Get Account Claim CR by AWS Account ID, output to yaml
osdctl account get account-claim -i <Account ID> -o yaml
# Get Legal Entity information by AWS Account ID
osdctl account get legal-entity -i <Account ID>
# Get Secrets information by AWS Account ID
osdctl account get secrets -i <Account ID>
test-cr-osdmanagedadminsre-secret
test-cr-secret
- Get AWS Account ID
# Get AWS Account ID by Account CR Name
osdctl get aws-account -a <Account CR Name>
# Get AWS Account ID by Account Claim CR Name and Namespace
osdctl get aws-account -c <Claim Name> -n <Claim Namepace>
rotate-secret
command rotates the credentials for one IAM User, it will print out the generated secret by default.
# specify by Account ID
osdctl account rotate-secret <IAM Username> -i 1111111111
# specify by Account CR Name
osdctl account rotate-secret <IAM Username> -a test-cr
# output the new secret to a path
osdctl account rotate-secret <IAM Username> -a test-cr --output=/test/secret --secret-name=secret
osdctl metrics
aws_account_operator_pool_size_vs_unclaimed{name="aws-account-operator"} => 893.000000
aws_account_operator_total_account_crs{name="aws-account-operator"} => 2173.000000
aws_account_operator_total_accounts_crs_claimed{name="aws-account-operator"} => 436.000000
......
osdctl clusterdeployment list
# apply via URL
osdctl federatedrole apply -u <URL>
# apply via local file
osdctl federatedrole apply -f <yaml file>