Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support creating addons as part of 'cluster create' command #487

Merged
merged 2 commits into from
Jan 7, 2025

Conversation

squizzi
Copy link
Contributor

@squizzi squizzi commented Jan 2, 2025

This adds a new flag to the cluster create command called --addon. The addon flag is a StringArrayVar so it can be specified multiple times to add multiple types of addons, since we only support object-store at this time an example was added for that:

  # Create a cluster with addons
  replicated cluster create --distribution eks --version 1.21 --nodes 3 --addon object-store --ttl 24h

Since addons share the arguments for ClusterID, OutputFormat, Duration and DryRun those all get inherited by values used in the clusterCreate command.

The only unique flag is bucket-prefix which has been added as an argument to clusterCreate with some validation added to ensure it is used when the addons array contains object-store.

I also refactored the existing args into runnerArgs so the args can more easily shared across different commands.

Testing

Validation

bin/replicated cluster create --distribution eks --version 1.31 --nodes 3 --addon not-object-store --ttl 24h
Error: validate addon args: unknown addon: not-object-store

bin/replicated cluster create --distribution eks --version 1.31 --nodes 3 --addon object-store --ttl 24h
<Omitted cmd.Help printing>
Error: validate addon args: bucket-prefix is required for object-store addon

Cluster Create

Works still without --addon specified:

bin/replicated cluster create --distribution eks --version 1.31 --nodes 3
ID          NAME                           DISTRIBUTION    VERSION       STATUS          CREATED                           EXPIRES                           COST
52db2783    silly_beaver                   eks             1.31          queued          2025-01-02 12:10 PST              -                                 $0.85

Adds an object-store when --addon specified:

bin/replicated cluster create --distribution eks --version 1.31 --nodes 3 --addon object-store --ttl 24h --bucket-prefix "banana"
ID          TYPE            STATUS          DATA
9b0ffa24    Object Store    pending         {"bucket_prefix":"banana"}
ID          NAME                           DISTRIBUTION    VERSION       STATUS          CREATED                           EXPIRES                           COST
6a7652cc    nostalgic_wing                 eks             1.31          queued          2025-01-02 12:13 PST              -                                 $8.79

# Addon goes ready
bin/replicated cluster addon ls 6a7652cc
ID          TYPE            STATUS          DATA
9b0ffa24    Object Store    ready           {"bucket_prefix":"banana","bucket_name":"banana-9b0ffa24-cmx","service_account_namespace":"cmx","service_account_name":"banana-9b0ffa24-cmx","service_account_name_read_only":"banana-9b0ffa24-cmx-ro"}

@squizzi squizzi requested a review from jdewinne January 2, 2025 20:16
@squizzi squizzi force-pushed the squizzi/sc-107825/addons-as-flag branch from a73cce9 to 1e1fc93 Compare January 2, 2025 20:19
@squizzi
Copy link
Contributor Author

squizzi commented Jan 4, 2025

Error: validate addon args: unknown addon: not-object-store

It'd be nice to print a list of valid addons here, but for now we'd only be printing one. We could do it by hand, ideally it'd be an API endpoint error like we do for instance types that returns this info, but that seems overkill for right now.

@squizzi squizzi merged commit 16c6676 into main Jan 7, 2025
5 checks passed
@squizzi squizzi deleted the squizzi/sc-107825/addons-as-flag branch January 7, 2025 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants