Skip to content

Commit

Permalink
Reduce user-k8s-client caching (#1778)
Browse files Browse the repository at this point in the history
* Reduce user-k8s-client caching

- When a cluster comes up we can cache the client immediately with
  missing Flux CRDs, apps/sources won't work. System doesn't recover
  until the client expires in 30mins
- Also add extraEnvVars for users to use that doesn't wipe out default
  envVars

* Fixes missing end

* Adds some logging

* Fixes userNamespace cache cleanup

- Was only every 5mins

* main is up to date now
  • Loading branch information
foot authored Oct 28, 2022
1 parent c8d1ae2 commit 39932d4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions charts/mccp/templates/clusters-service/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.extraEnvVars }}
{{- with .Values.extraEnvVars }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
volumeMounts:
- name: ui-server-volume
mountPath: /html
Expand Down
14 changes: 10 additions & 4 deletions charts/mccp/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ ingress:
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: ""
paths:
- path: /
pathType: ImplementationSpecific
- host: ""
paths:
- path: /
pathType: ImplementationSpecific
#
tls: []
# - secretName: chart-example-tls
Expand All @@ -135,6 +135,12 @@ envVars:
value: "true"
- name: WEAVE_GITOPS_FEATURE_CLUSTER
value: "true"
- name: WEAVE_GITOPS_USERS_CLIENTS_TTL
value: "30s"

# extraEnvVars is a list of extra environment variables to set on the
# deployment. These are in addition to the envVars above.
extraEnvVars: []

networkPolicy:
enabled: true
Expand Down
3 changes: 3 additions & 0 deletions cmd/clusters-service/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,10 @@ func StartServer(ctx context.Context, log logr.Logger, tempDir string, p Params)

clientsFactory := clustersmngr.CachedClientFactory
if !p.UseK8sCachedClients {
log.Info("Using un-cached clients")
clientsFactory = clustersmngr.ClientFactory
} else {
log.Info("Using cached clients")
}

clustersManager := clustersmngr.NewClustersManager(
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/namespaces/userCache.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

const (
cacheTTL = time.Minute
cacheResolutionTime = 5 * time.Minute
cacheResolutionTime = 30 * time.Second
)

type UsersResourcesNamespaces struct {
Expand Down

0 comments on commit 39932d4

Please sign in to comment.