Skip to content

Commit

Permalink
Merge branch 'main' into track-released-oss
Browse files Browse the repository at this point in the history
  • Loading branch information
yiannistri authored Oct 26, 2023
2 parents 7eadcc4 + b8baa42 commit 7ca4575
Show file tree
Hide file tree
Showing 32 changed files with 762 additions and 210 deletions.
25 changes: 25 additions & 0 deletions api/query/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ service Query {
get: "/v1/debug/access-rules"
};
}

rpc ListEnabledComponents(ListEnabledComponentsRequest)
returns (ListEnabledComponentsResponse) {
option (google.api.http) = {
get: "/v1/enabled-components"
};
}
}

message QueryRequest {
Expand Down Expand Up @@ -111,3 +118,21 @@ message Facet {
string field = 1;
repeated string values = 2;
}

// EnabledComponent represents a component of the UI that can be enabled or disabled
enum EnabledComponent {
unknown = 0;
applications = 1;
sources = 2;
gitopssets = 3;
templates = 4;
}

message ListEnabledComponentsRequest {

}

message ListEnabledComponentsResponse {
repeated EnabledComponent components = 1;
}

44 changes: 44 additions & 0 deletions api/query/query.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@
]
}
},
"/v1/enabled-components": {
"get": {
"operationId": "Query_ListEnabledComponents",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1ListEnabledComponentsResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"Query"
]
}
},
"/v1/facets": {
"get": {
"operationId": "Query_ListFacets",
Expand Down Expand Up @@ -168,6 +190,17 @@
}
}
},
"v1EnabledComponent": {
"type": "string",
"enum": [
"unknown",
"applications",
"sources",
"gitopssets",
"templates"
],
"default": "unknown"
},
"v1Facet": {
"type": "object",
"properties": {
Expand All @@ -182,6 +215,17 @@
}
}
},
"v1ListEnabledComponentsResponse": {
"type": "object",
"properties": {
"components": {
"type": "array",
"items": {
"$ref": "#/definitions/v1EnabledComponent"
}
}
}
},
"v1ListFacetsResponse": {
"type": "object",
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion charts/mccp/templates/clusters-service/collector.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.enableExplorer }}
{{- if .Values.explorer.enabled }}
---
apiVersion: v1
kind: ServiceAccount
Expand Down
1 change: 1 addition & 0 deletions charts/mccp/templates/clusters-service/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ data:
MONITORING_BIND_ADDRESS: ":{{ .Values.monitoring.service.port }}"
MONITORING_METRICS_ENABLED: {{ .Values.monitoring.metrics.enabled | quote }}
MONITORING_PROFILING_ENABLED: {{ .Values.monitoring.profiling.enabled | quote }}
EXPLORER_ENABLED_FOR: {{ .Values.explorer.enabledFor | join "," | quote }}
10 changes: 5 additions & 5 deletions charts/mccp/templates/clusters-service/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,22 @@ spec:
- name: WEAVE_GITOPS_FEATURE_PIPELINES
value: "true"
{{- end }}
{{- if .Values.enableExplorer }}
{{- if .Values.explorer.enabled }}
- name: WEAVE_GITOPS_FEATURE_EXPLORER
value: "true"
{{- end }}
{{- if .Values.enableTerraformUI }}
- name: WEAVE_GITOPS_FEATURE_TERRAFORM_UI
value: "true"
{{- end }}
{{- if .Values.useQueryServiceBackend }}
- name: WEAVE_GITOPS_FEATURE_QUERY_SERVICE_BACKEND
value: "true"
{{- end }}
{{- if .Values.enableRunUI }}
- name: WEAVE_GITOPS_FEATURE_RUN_UI
value: "true"
{{- end }}
{{- if .Values.enableNewPipelines }}
- name: WEAVE_GITOPS_FEATURE_NEW_PIPELINES
value: "true"
{{- end }}
{{- if .Values.envVars }}
{{- with .Values.envVars }}
{{- toYaml . | nindent 12 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/mccp/templates/clusters-service/impersonator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rules:
- apiGroups: [""]
resources: ["users", "groups"]
verbs: ["impersonate"]
{{- if .Values.enableExplorer }}
{{- if .Values.explorer.enabled }}
- apiGroups: [ "" ]
resources: [ "serviceaccounts" ]
verbs: [ "impersonate" ]
Expand Down
2 changes: 1 addition & 1 deletion charts/mccp/templates/rbac/gitopscluster_reader_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rules:
resources: ["gitopsclusters"]
verbs: ["get", "watch", "list"]

{{- if .Values.enableExplorer }}
{{- if .Values.explorer.enabled }}
- apiGroups: ["rbac.authorization.k8s.io"]
resources: ["clusterroles", "clusterrolebindings", "roles", "rolebindings"]
verbs: ["get", "watch", "list"]
Expand Down
15 changes: 10 additions & 5 deletions charts/mccp/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ enableTerraformUI: false
# Turns on UI elements for GitOps Run
enableRunUI: false

# When set to true, this turns on the new Pipelines UI. This includes deploying the new API and controller.
enableNewPipelines: false

config:
logLevel: info
cluster:
Expand Down Expand Up @@ -211,16 +214,18 @@ cluster-controller:
tag: v1.5.2

#### Explorer
# Turns on explorer to true
enableExplorer: false
# Uses the query service for Applications and Sources views
useQueryServiceBackend: false

explorer:
enabled: false
collector:
# ServiceAccount that explorer will use to watch clusters for resources
serviceAccount:
name: "collector"
namespace: "flux-system"
cleaner:
disabled: false
enabledFor:
- applications
- sources
- gitopssets
- templates

8 changes: 8 additions & 0 deletions cmd/clusters-service/app/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type Options struct {
CollectorServiceAccount collector.ImpersonateServiceAccount
MonitoringOptions monitoring.Options
EnableObjectCleaner bool
ExplorerEnabledFor []string
}

type Option func(*Options)
Expand Down Expand Up @@ -290,3 +291,10 @@ func WithObjectCleaner(enabled bool) Option {
o.EnableObjectCleaner = enabled
}
}

// ExplorerEnabledFor turns on and off the explorer for different parts of the UI
func WithExplorerEnabledFor(enabledFor []string) Option {
return func(o *Options) {
o.ExplorerEnabledFor = append(o.ExplorerEnabledFor, enabledFor...)
}
}
4 changes: 4 additions & 0 deletions cmd/clusters-service/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ type Params struct {
ProfilingEnabled bool `mapstructure:"monitoring-profiling-enabled"`
EnableObjectCleaner bool `mapstructure:"enable-object-cleaner"`
NoAuthUser string `mapstructure:"insecure-no-authentication-user"`
ExplorerEnabledFor []string `mapstructure:"explorer-enabled-for"`
}

type OIDCAuthenticationOptions struct {
Expand Down Expand Up @@ -268,6 +269,7 @@ func NewAPIServerCommand() *cobra.Command {
cmdFlags.String("collector-serviceaccount-name", "", "name of the serviceaccount that collector impersonates to watch leaf clusters.")
cmdFlags.String("collector-serviceaccount-namespace", "", "namespace of the serviceaccount that collector impersonates to watch leaf clusters.")
cmdFlags.Bool("explorer-cleaner-disabled", false, "Enables the Explorer object cleaner that manages retaining objects")
cmdFlags.StringSlice("explorer-enabled-for", []string{}, "List of components that the Explorer is enabled for")

// Monitoring
cmdFlags.Bool("monitoring-enabled", false, "creates monitoring server")
Expand Down Expand Up @@ -578,6 +580,7 @@ func StartServer(ctx context.Context, p Params, logOptions flux_logger.Options)
WithCollectorServiceAccount(p.CollectorServiceAccountName, p.CollectorServiceAccountNamespace),
WithMonitoring(p.MonitoringEnabled, p.MonitoringBindAddress, p.MetricsEnabled, p.ProfilingEnabled, log),
WithObjectCleaner(p.EnableObjectCleaner),
WithExplorerEnabledFor(p.ExplorerEnabledFor),
)
}

Expand Down Expand Up @@ -698,6 +701,7 @@ func RunInProcessGateway(ctx context.Context, addr string, setters ...Option) er
ObjectKinds: configuration.SupportedObjectKinds,
ServiceAccount: args.CollectorServiceAccount,
EnableObjectCleaner: args.EnableObjectCleaner,
EnabledFor: args.ExplorerEnabledFor,
})
if err != nil {
return fmt.Errorf("hydrating query server: %w", err)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.enableExplorer }}
{{- if .Values.explorer.enabled }}
---
apiVersion: v1
kind: ServiceAccount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ spec:
- name: WEAVE_GITOPS_FEATURE_PIPELINES
value: "true"
{{- end }}
{{- if .Values.enableExplorer }}
{{- if .Values.explorer.enabled }}
- name: WEAVE_GITOPS_FEATURE_EXPLORER
value: "true"
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rules:
- apiGroups: [""]
resources: ["users", "groups"]
verbs: ["impersonate"]
{{- if .Values.enableExplorer }}
{{- if .Values.explorer.enabled }}
- apiGroups: [ "" ]
resources: [ "serviceaccounts" ]
verbs: [ "impersonate" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rules:
resources: ["gitopsclusters"]
verbs: ["get", "watch", "list"]

{{- if .Values.enableExplorer }}
{{- if .Values.explorer.enabled }}
- apiGroups: ["rbac.authorization.k8s.io"]
resources: ["clusterroles", "clusterrolebindings", "roles", "rolebindings"]
verbs: ["get", "watch", "list"]
Expand Down
2 changes: 1 addition & 1 deletion hack/azure-marketplace/mccp/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ config:
content: ''
hideVersion: false
logoURL: ''
enableExplorer: false
enablePipelines: true
enableRunUI: false
enableTerraformUI: false
Expand All @@ -67,6 +66,7 @@ envVars:
- name: WEAVE_GITOPS_USERS_CLIENTS_TTL
value: 30s
explorer:
enabled: false
cleaner:
disabled: false
collector:
Expand Down
Loading

0 comments on commit 7ca4575

Please sign in to comment.