Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion backend/cmd/headlamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const (
type clientConfig struct {
Clusters []Cluster `json:"clusters"`
IsDynamicClusterEnabled bool `json:"isDynamicClusterEnabled"`
FiltersWarningsOnly bool `json:"filtersWarningsOnly"`
}

type OauthConfig struct {
Expand Down Expand Up @@ -1750,7 +1751,11 @@ func parseClusterFromKubeConfig(kubeConfigs []string) ([]Cluster, []error) {
func (c *HeadlampConfig) getConfig(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")

clientConfig := clientConfig{c.getClusters(), c.EnableDynamicClusters}
clientConfig := clientConfig{
Clusters: c.getClusters(),
IsDynamicClusterEnabled: c.EnableDynamicClusters,
FiltersWarningsOnly: c.FiltersWarningsOnly,
}

if err := json.NewEncoder(w).Encode(&clientConfig); err != nil {
logger.Log(logger.LevelError, nil, err, "encoding config")
Expand Down
6 changes: 5 additions & 1 deletion backend/cmd/stateless.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ func (c *HeadlampConfig) parseKubeConfig(w http.ResponseWriter, r *http.Request)
return
}

clientConfig := clientConfig{contexts, c.EnableDynamicClusters}
clientConfig := clientConfig{
Clusters: contexts,
IsDynamicClusterEnabled: c.EnableDynamicClusters,
FiltersWarningsOnly: c.FiltersWarningsOnly,
}

if err := json.NewEncoder(w).Encode(&clientConfig); err != nil {
logger.Log(logger.LevelError, nil, err, "encoding config")
Expand Down
3 changes: 3 additions & 0 deletions backend/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ type Config struct {
UseOTLPHTTP *bool `koanf:"use-otlp-http"`
StdoutTraceEnabled *bool `koanf:"stdout-trace-enabled"`
SamplingRate *float64 `koanf:"sampling-rate"`
// FiltersWarningsOnly is the default state of the events filter (true = only warnings, false = all events).
FiltersWarningsOnly bool `koanf:"filters-warnings-only"`
// TLS config
TLSCertPath string `koanf:"tls-cert-path"`
TLSKeyPath string `koanf:"tls-key-path"`
Expand Down Expand Up @@ -448,6 +450,7 @@ func addGeneralFlags(f *flag.FlagSet) {
f.Uint("port", defaultPort, "Port to listen from")
f.String("proxy-urls", "", "Allow proxy requests to specified URLs")
f.Bool("enable-helm", false, "Enable Helm operations")
f.Bool("filters-warnings-only", true, "Whether to filter events by warnings only by default")
}

func addOIDCFlags(f *flag.FlagSet) {
Expand Down
1 change: 1 addition & 0 deletions backend/pkg/headlampconfig/headlampConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ type HeadlampCFG struct {
TLSCertPath string
TLSKeyPath string
SessionTTL int
FiltersWarningsOnly bool
}
1 change: 1 addition & 0 deletions charts/headlamp/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ spec:
{{- with .Values.config.tlsKeyPath }}
- "-tls-key-path={{ . }}"
{{- end }}
- "-filters-warnings-only={{ dig "events" "warningsOnly" true .Values.config }}"
{{- with .Values.config.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ spec:
- "-oidc-validator-client-id=$(OIDC_VALIDATOR_CLIENT_ID)"
# Check if validatorIssuerURL is non empty either from env or oidc.config
- "-oidc-validator-idp-issuer-url=$(OIDC_VALIDATOR_ISSUER_URL)"
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
1 change: 1 addition & 0 deletions charts/headlamp/tests/expected_templates/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ spec:
- "-plugins-dir=/headlamp/plugins"
- "-session-ttl=86400"
# Check if externalSecret is disabled
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
1 change: 1 addition & 0 deletions charts/headlamp/tests/expected_templates/extra-args.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ spec:
- "-plugins-dir=/headlamp/plugins"
- "-session-ttl=86400"
# Check if externalSecret is disabled
- "-filters-warnings-only=true"
- -insecure-ssl
ports:
- name: http
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ spec:
- "-plugins-dir=/headlamp/plugins"
- "-session-ttl=86400"
# Check if externalSecret is disabled
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ spec:
- "-plugins-dir=/headlamp/plugins"
- "-session-ttl=86400"
# Check if externalSecret is disabled
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ spec:
- "-plugins-dir=/headlamp/plugins"
- "-session-ttl=86400"
# Check if externalSecret is disabled
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ spec:
- "-session-ttl=86400"
# Check if externalSecret is disabled
- "-me-user-info-url=$(ME_USER_INFO_URL)"
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ spec:
- "-session-ttl=86400"
# Check if externalSecret is disabled
- "-me-user-info-url=$(ME_USER_INFO_URL)"
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ spec:
- "-oidc-idp-issuer-url=$(OIDC_ISSUER_URL)"
# Check if scopes are non empty either from env or oidc.config
- "-oidc-scopes=$(OIDC_SCOPES)"
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ spec:
- "-plugins-dir=/headlamp/plugins"
- "-session-ttl=86400"
# Check if externalSecret is disabled
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ spec:
- "-oidc-idp-issuer-url=$(OIDC_ISSUER_URL)"
# Check if scopes are non empty either from env or oidc.config
- "-oidc-scopes=$(OIDC_SCOPES)"
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ spec:
- "-oidc-idp-issuer-url=$(OIDC_ISSUER_URL)"
# Check if scopes are non empty either from env or oidc.config
- "-oidc-scopes=$(OIDC_SCOPES)"
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ spec:
- "-oidc-idp-issuer-url=$(OIDC_ISSUER_URL)"
# Check if scopes are non empty either from env or oidc.config
- "-oidc-scopes=$(OIDC_SCOPES)"
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ spec:
- "-oidc-idp-issuer-url=$(OIDC_ISSUER_URL)"
# Check if scopes are non empty either from env or oidc.config
- "-oidc-scopes=$(OIDC_SCOPES)"
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ spec:
- "-oidc-client-secret=$(OIDC_CLIENT_SECRET)"
- "-oidc-idp-issuer-url=$(OIDC_ISSUER_URL)"
- "-oidc-scopes=$(OIDC_SCOPES)"
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
1 change: 1 addition & 0 deletions charts/headlamp/tests/expected_templates/oidc-pkce.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ spec:
# Check if scopes are non empty either from env or oidc.config
- "-oidc-scopes=$(OIDC_SCOPES)"
- "-oidc-use-pkce=$(OIDC_USE_PKCE)"
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ spec:
- "-oidc-validator-idp-issuer-url=$(OIDC_VALIDATOR_ISSUER_URL)"
# Check if useAccessToken is non false either from env or oidc.config
- "-oidc-use-access-token=$(OIDC_USE_ACCESS_TOKEN)"
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ spec:
- "-plugins-dir=/headlamp/plugins"
- "-session-ttl=86400"
# Check if externalSecret is disabled
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ spec:
- "-plugins-dir=/headlamp/plugins"
- "-session-ttl=86400"
# Check if externalSecret is disabled
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
1 change: 1 addition & 0 deletions charts/headlamp/tests/expected_templates/tls-added.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ spec:
# Check if externalSecret is disabled
- "-tls-cert-path=/headlamp-cert/headlamp-ca.crt"
- "-tls-key-path=/headlamp-cert/headlamp-tls.key"
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ spec:
- "-plugins-dir=/headlamp/plugins"
- "-session-ttl=86400"
# Check if externalSecret is disabled
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ spec:
- "-plugins-dir=/headlamp/plugins"
- "-session-ttl=86400"
# Check if externalSecret is disabled
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ spec:
- "-plugins-dir=/headlamp/plugins"
- "-session-ttl=86400"
# Check if externalSecret is disabled
- "-filters-warnings-only=true"
ports:
- name: http
containerPort: 4466
Expand Down
22 changes: 9 additions & 13 deletions charts/headlamp/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ config:
baseURL: ""
# -- session token TTL in seconds (default is 24 hours)
sessionTTL: 86400
events:
# -- Whether to filter events by warnings only by default
warningsOnly: true
oidc:
# Option 1:
# @param config.oidc.secret - OIDC secret configuration
Expand Down Expand Up @@ -161,8 +164,7 @@ podLabels: {}
hostUsers: true

# -- Headlamp pod's Security Context
podSecurityContext:
{}
podSecurityContext: {}
# fsGroup: 2000

# -- Headlamp containers Security Context
Expand All @@ -184,7 +186,6 @@ securityContext:
# drop:
# - ALL


service:
# -- Annotations to add to the service
annotations: {}
Expand All @@ -211,8 +212,7 @@ persistentVolumeClaim:
# -- Enable Persistent Volume Claim
enabled: false
# -- Annotations to add to the persistent volume claim (if enabled)
annotations:
{}
annotations: {}
# -- accessModes for the persistent volume claim, eg: ReadWriteOnce, ReadOnlyMany, ReadWriteMany etc.
accessModes: []
# -- size of the persistent volume claim, eg: 10Gi. Required if enabled is true.
Expand All @@ -228,8 +228,7 @@ ingress:
# -- Enable ingress controller resource
enabled: false
# -- Annotations for Ingress resource
annotations:
{}
annotations: {}
# kubernetes.io/tls-acme: "true"

# -- Additional labels to add to the Ingress resource
Expand All @@ -242,8 +241,7 @@ ingress:

# -- Hostname(s) for the Ingress resource
# Please refer to https://kubernetes.io/docs/reference/kubernetes-api/service-resources/ingress-v1/#IngressSpec for more information.
hosts:
[]
hosts: []
# - host: chart-example.local
# paths:
# - path: /
Expand Down Expand Up @@ -288,8 +286,7 @@ httpRoute:
# port: 80

# -- CPU/Memory resource requests/limits
resources:
{}
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
Expand Down Expand Up @@ -353,8 +350,7 @@ pluginsManager:
# cpu: "1000m"
# memory: "4096Mi"
# If omitted, the plugin manager will inherit the global securityContext
securityContext:
{}
securityContext: {}
# runAsUser: 1001
# runAsNonRoot: true
# allowPrivilegeEscalation: false
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/cluster/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ export default function Overview() {

function EventsSection() {
const EVENT_WARNING_SWITCH_FILTER_STORAGE_KEY = 'EVENT_WARNING_SWITCH_FILTER_STORAGE_KEY';
const EVENT_WARNING_SWITCH_DEFAULT = true;
const filtersWarningsOnly = useTypedSelector(state => state.config.filtersWarningsOnly);
const EVENT_WARNING_SWITCH_DEFAULT = filtersWarningsOnly;
const { t } = useTranslation(['translation', 'glossary']);
const location = useLocation();
const queryParams = new URLSearchParams(location.search);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const makeStore = () => {
timezone: 'UTC',
useEvict: true,
},
filtersWarningsOnly: true,
},
projects: {
headerActions: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const makeStore = () => {
timezone: 'UTC',
useEvict: true,
},
filtersWarningsOnly: true,
},
projects: {
headerActions: {},
Expand Down
13 changes: 12 additions & 1 deletion frontend/src/redux/configSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export interface ConfigState {
allClusters: {
[clusterName: string]: Cluster;
} | null;
/**
* Whether to filter events by warnings only by default.
*/
filtersWarningsOnly: boolean;
/**
* Settings is a map of settings names to settings values.
*/
Expand Down Expand Up @@ -71,6 +75,7 @@ export const initialState: ConfigState = {
clusters: null,
statelessClusters: null,
allClusters: null,
filtersWarningsOnly: true,
settings: {
tableRowsPerPageOptions:
storedSettings.tableRowsPerPageOptions || defaultTableRowsPerPageOptions,
Expand All @@ -89,8 +94,14 @@ const configSlice = createSlice({
* @param state - The current state.
* @param action - The payload action containing the config.
*/
setConfig(state, action: PayloadAction<{ clusters: ConfigState['clusters'] }>) {
setConfig(
state,
action: PayloadAction<{ clusters: ConfigState['clusters']; filtersWarningsOnly?: boolean }>
) {
state.clusters = action.payload.clusters;
if (action.payload.filtersWarningsOnly !== undefined) {
state.filtersWarningsOnly = action.payload.filtersWarningsOnly;
}
},
/**
* Save the config. To both the store, and localStorage.
Expand Down
Loading