Skip to content

Commit 111da39

Browse files
feat(actions): parametrized actions to scale workloads (#15505) (#20097)
Signed-off-by: Ratul Basak <[email protected]> Signed-off-by: Alexandre Gaudreault <[email protected]> Co-authored-by: Alexandre Gaudreault <[email protected]>
1 parent 6625d07 commit 111da39

File tree

27 files changed

+1040
-318
lines changed

27 files changed

+1040
-318
lines changed

USERS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Currently, the following organizations are **officially** using Argo CD:
9595
1. [Daydream](https://daydream.ing)
9696
1. [Deloitte](https://www.deloitte.com/)
9797
1. [Deutsche Telekom AG](https://telekom.com)
98+
1. [Deutsche Bank AG](https://www.deutsche-bank.de/)
9899
1. [Devopsi - Poland Software/DevOps Consulting](https://devopsi.pl/)
99100
1. [Devtron Labs](https://github.com/devtron-labs/devtron)
100101
1. [DigitalEd](https://www.digitaled.com)

assets/swagger.json

Lines changed: 50 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/argocd/commands/admin/settings.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"sigs.k8s.io/yaml"
2525

2626
"github.com/argoproj/argo-cd/v3/common"
27+
applicationpkg "github.com/argoproj/argo-cd/v3/pkg/apiclient/application"
2728
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
2829
"github.com/argoproj/argo-cd/v3/util/argo/normalizers"
2930
"github.com/argoproj/argo-cd/v3/util/cli"
@@ -563,6 +564,8 @@ argocd admin settings resource-overrides action list /tmp/deploy.yaml --argocd-c
563564
}
564565

565566
func NewResourceActionRunCommand(cmdCtx commandContext) *cobra.Command {
567+
var resourceActionParameters []string
568+
566569
command := &cobra.Command{
567570
Use: "run-action RESOURCE_YAML_PATH ACTION",
568571
Aliases: []string{"action"},
@@ -579,6 +582,23 @@ argocd admin settings resource-overrides action /tmp/deploy.yaml restart --argoc
579582
}
580583
action := args[1]
581584

585+
// Parse resource action parameters
586+
parsedParams := make([]*applicationpkg.ResourceActionParameters, 0)
587+
if len(resourceActionParameters) > 0 {
588+
for _, param := range resourceActionParameters {
589+
parts := strings.SplitN(param, "=", 2)
590+
if len(parts) != 2 {
591+
log.Fatalf("Invalid parameter format: %s", param)
592+
}
593+
name := parts[0]
594+
value := parts[1]
595+
parsedParams = append(parsedParams, &applicationpkg.ResourceActionParameters{
596+
Name: &name,
597+
Value: &value,
598+
})
599+
}
600+
}
601+
582602
executeResourceOverrideCommand(ctx, cmdCtx, args, func(res unstructured.Unstructured, override v1alpha1.ResourceOverride, overrides map[string]v1alpha1.ResourceOverride) {
583603
gvk := res.GroupVersionKind()
584604
if override.Actions == "" {
@@ -590,7 +610,7 @@ argocd admin settings resource-overrides action /tmp/deploy.yaml restart --argoc
590610
action, err := luaVM.GetResourceAction(&res, action)
591611
errors.CheckError(err)
592612

593-
modifiedRes, err := luaVM.ExecuteResourceAction(&res, action.ActionLua)
613+
modifiedRes, err := luaVM.ExecuteResourceAction(&res, action.ActionLua, parsedParams)
594614
errors.CheckError(err)
595615

596616
for _, impactedResource := range modifiedRes {
@@ -615,5 +635,7 @@ argocd admin settings resource-overrides action /tmp/deploy.yaml restart --argoc
615635
})
616636
},
617637
}
638+
639+
command.Flags().StringArrayVar(&resourceActionParameters, "param", []string{}, "Action parameters (e.g. --param key1=value1)")
618640
return command
619641
}

docs/assets/scale_resources_1.png

74.3 KB
Loading

docs/assets/scale_resources_2.png

27 KB
Loading

docs/assets/scale_resources_3.png

66.5 KB
Loading

docs/operator-manual/resource_actions_builtin.md

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/user-guide/commands/argocd_admin_settings_resource-overrides_run-action.md

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Scale Resources in ArgoCD UI
2+
3+
This enables users to scale resources directly from the ArgoCD UI. Users will be able to increase or decrease the number of replicas (Pods) for Deployments and StatefulSets by using an input field. The feature aims to enhance user experience, especially for non-technical users, by eliminating the need to modify configuration files or use kubectl commands for scaling.
4+
5+
6+
## Example Usage
7+
1. User navigates to a Deployment or StatefulSet in any ArgoCD application.
8+
2. User clicks on the Actions dropdown and selects "Scale".
9+
![action button for scaling](../assets/scale_resources_1.png)
10+
3. A modal pops up showing an input field `Enter input parameters for action: scale` with the current number of Pods.
11+
4. User adjusts the number of Pods by entering a number.
12+
![input field for scaling](../assets/scale_resources_2.png)
13+
5. User presses OK, and the resource is scaled accordingly.
14+
![result for scaling](../assets/scale_resources_3.png)
15+
16+
17+
!!! note
18+
This feature will only apply to `Deployments`, and `StatefulSets`.
19+
20+
!!! note
21+
If you use HPA (Horizontal Pod Autoscaling) or enabled ArgoCD auto-sync, changing the replica count in scale actions would be overwritten.
22+
Ensure that invalid values (e.g., `non-numeric` characters, `negative` numbers, or values beyond the `max integer limit`) cannot be entered.

0 commit comments

Comments
 (0)