Skip to content

Commit

Permalink
feat: Scoped clusters (argoproj#7039)
Browse files Browse the repository at this point in the history
feat: Scoped clusters (argoproj#7039)

Signed-off-by: pashavictorovich <[email protected]>
Signed-off-by: viktorplakida <[email protected]>
  • Loading branch information
pasha-codefresh authored and plakyda1 committed Sep 28, 2021
1 parent 3729b46 commit 8315c85
Show file tree
Hide file tree
Showing 19 changed files with 735 additions and 502 deletions.
10 changes: 10 additions & 0 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3711,6 +3711,12 @@
"projectDetailedProjectsResponse": {
"type": "object",
"properties": {
"clusters": {
"type": "array",
"items": {
"$ref": "#/definitions/v1alpha1Cluster"
}
},
"globalProjects": {
"type": "array",
"items": {
Expand Down Expand Up @@ -5184,6 +5190,10 @@
"type": "string"
}
},
"project": {
"type": "string",
"title": "Reference between project and cluster that allow you automatically to be added as item inside Destinations project entity"
},
"refreshRequestedAt": {
"$ref": "#/definitions/v1Time"
},
Expand Down
9 changes: 7 additions & 2 deletions cmd/argocd/commands/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ import (
"text/tabwriter"

"github.com/mattn/go-isatty"
"k8s.io/client-go/kubernetes"

"github.com/argoproj/argo-cd/v2/util/cli"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"

cmdutil "github.com/argoproj/argo-cd/v2/cmd/util"
"github.com/argoproj/argo-cd/v2/common"
argocdclient "github.com/argoproj/argo-cd/v2/pkg/apiclient"
clusterpkg "github.com/argoproj/argo-cd/v2/pkg/apiclient/cluster"
argoappv1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/argoproj/argo-cd/v2/util/cli"
"github.com/argoproj/argo-cd/v2/util/clusterauth"
"github.com/argoproj/argo-cd/v2/util/errors"
"github.com/argoproj/argo-cd/v2/util/io"
Expand Down Expand Up @@ -135,6 +137,9 @@ func NewClusterAddCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clie
if clusterOpts.Shard >= 0 {
clst.Shard = &clusterOpts.Shard
}
if clusterOpts.Project != "" {
clst.Project = clusterOpts.Project
}
clstCreateReq := clusterpkg.ClusterCreateRequest{
Cluster: clst,
Upsert: clusterOpts.Upsert,
Expand Down
2 changes: 2 additions & 0 deletions cmd/util/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ type ClusterOptions struct {
Namespaces []string
ClusterResources bool
Name string
Project string
Shard int64
ExecProviderCommand string
ExecProviderArgs []string
Expand All @@ -126,6 +127,7 @@ func AddClusterFlags(command *cobra.Command, opts *ClusterOptions) {
command.Flags().StringArrayVar(&opts.Namespaces, "namespace", nil, "List of namespaces which are allowed to manage")
command.Flags().BoolVar(&opts.ClusterResources, "cluster-resources", false, "Indicates if cluster level resources should be managed. The setting is used only if list of managed namespaces is not empty.")
command.Flags().StringVar(&opts.Name, "name", "", "Overwrite the cluster name")
command.Flags().StringVar(&opts.Project, "project", "", "project of the cluster")
command.Flags().Int64Var(&opts.Shard, "shard", -1, "Cluster shard number; inferred from hostname if not set")
command.Flags().StringVar(&opts.ExecProviderCommand, "exec-command", "", "Command to run to provide client credentials to the cluster. You may need to build a custom ArgoCD image to ensure the command is available at runtime.")
command.Flags().StringArrayVar(&opts.ExecProviderArgs, "exec-command-args", nil, "Arguments to supply to the --exec-command executable")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ argocd admin cluster generate-spec CONTEXT [flags]
--name string Overwrite the cluster name
--namespace stringArray List of namespaces which are allowed to manage
-o, --output string Output format. One of: json|yaml (default "yaml")
--project string project of the cluster
--service-account string System namespace service account to use for kubernetes resource management. If not set then default "argocd-manager" SA will be used (default "argocd-manager")
--shard int Cluster shard number; inferred from hostname if not set (default -1)
--system-namespace string Use different system namespace (default "kube-system")
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/commands/argocd_cluster_add.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ argocd cluster add CONTEXT [flags]
--kubeconfig string use a particular kubeconfig file
--name string Overwrite the cluster name
--namespace stringArray List of namespaces which are allowed to manage
--project string project of the cluster
--service-account string System namespace service account to use for kubernetes resource management. If not set then default "argocd-manager" SA will be created
--shard int Cluster shard number; inferred from hostname if not set (default -1)
--system-namespace string Use different system namespace (default "kube-system")
Expand Down
2 changes: 1 addition & 1 deletion hack/generate-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ clean_swagger() {
}

echo "If additional types are added, the number of expected collisions may need to be increased"
EXPECTED_COLLISION_COUNT=57
EXPECTED_COLLISION_COUNT=64
collect_swagger server ${EXPECTED_COLLISION_COUNT}
clean_swagger server
clean_swagger reposerver
Expand Down
186 changes: 125 additions & 61 deletions pkg/apiclient/project/project.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8315c85

Please sign in to comment.