Merge remote-tracking branch 'upstream/master' into 951-namespace-scope-rbac

# Conflicts:
#	internal/pkg/cmd/reloader.go
#	internal/pkg/cmd/reloader_test.go
This commit is contained in:
Michał Marszałek
2026-07-02 11:07:13 +02:00
6 changed files with 60 additions and 9 deletions
@@ -1,8 +1,8 @@
apiVersion: v1
name: reloader
description: Reloader chart that runs on kubernetes
version: 2.2.12
appVersion: v1.4.17
version: 2.2.14
appVersion: v1.4.19
keywords:
- Reloader
- kubernetes
@@ -19,7 +19,7 @@ fullnameOverride: ""
image:
name: stakater/reloader
repository: ghcr.io/stakater/reloader
tag: v1.4.17
tag: v1.4.19
# digest: sha256:1234567
pullPolicy: IfNotPresent
@@ -143,7 +143,7 @@ reloader:
labels:
provider: stakater
group: com.stakater.platform
version: v1.4.14
version: v1.4.19
# Support for extra environment variables.
env:
# Open supports Key value pair as environment variables.
+1 -1
View File
@@ -1,6 +1,6 @@
module github.com/stakater/Reloader
go 1.26.3
go 1.26.4
require (
github.com/argoproj/argo-rollouts v1.9.0
+16 -3
View File
@@ -117,6 +117,20 @@ func resolveWatchNamespaces(namespaces []string, kubernetesNamespace string) ([]
return []string{v1.NamespaceAll}, true
}
// namespaceWatchScopeMessage returns the startup log message describing the
// namespace scope Reloader will watch when KUBERNETES_NAMESPACE is unset
// (global mode). It reflects --namespaces-to-ignore so the log is not
// misleading when namespace filtering is configured.
func namespaceWatchScopeMessage(ignoredNamespaces []string) string {
if len(ignoredNamespaces) > 0 {
return fmt.Sprintf(
"KUBERNETES_NAMESPACE is unset, will detect changes in all namespaces except: %s.",
strings.Join(ignoredNamespaces, ", "),
)
}
return "KUBERNETES_NAMESPACE is unset, will detect changes in all namespaces."
}
func startReloader(cmd *cobra.Command, args []string) {
common.GetCommandLineOptions()
err := configureLogging(options.LogFormat, options.LogLevel)
@@ -126,9 +140,7 @@ func startReloader(cmd *cobra.Command, args []string) {
logrus.Info("Starting Reloader")
watchNamespaces, isGlobal := resolveWatchNamespaces(options.Namespaces, os.Getenv("KUBERNETES_NAMESPACE"))
if isGlobal {
logrus.Warnf("KUBERNETES_NAMESPACE is unset, will detect changes in all namespaces.")
} else if len(options.Namespaces) > 0 {
if !isGlobal && len(options.Namespaces) > 0 {
logrus.Infof("Watching scoped namespaces: %s", strings.Join(watchNamespaces, ", "))
}
@@ -151,6 +163,7 @@ func startReloader(cmd *cobra.Command, args []string) {
if isGlobal {
ignoredNamespacesList = options.NamespacesToIgnore
logrus.Warn(namespaceWatchScopeMessage(ignoredNamespacesList))
namespaceLabelSelector, err = common.GetNamespaceLabelSelector(options.NamespaceSelectors)
if err != nil {
logrus.Fatal(err)
+37
View File
@@ -60,3 +60,40 @@ func TestResolveWatchNamespaces(t *testing.T) {
})
}
}
func TestNamespaceWatchScopeMessage(t *testing.T) {
tests := []struct {
name string
ignoredNamespaces []string
want string
}{
{
name: "no ignored namespaces - all namespaces",
ignoredNamespaces: nil,
want: "KUBERNETES_NAMESPACE is unset, will detect changes in all namespaces.",
},
{
name: "empty ignored namespaces - all namespaces",
ignoredNamespaces: []string{},
want: "KUBERNETES_NAMESPACE is unset, will detect changes in all namespaces.",
},
{
name: "single ignored namespace",
ignoredNamespaces: []string{"kube-system"},
want: "KUBERNETES_NAMESPACE is unset, will detect changes in all namespaces except: kube-system.",
},
{
name: "multiple ignored namespaces",
ignoredNamespaces: []string{"kube-system", "kube-public"},
want: "KUBERNETES_NAMESPACE is unset, will detect changes in all namespaces except: kube-system, kube-public.",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := namespaceWatchScopeMessage(tt.ignoredNamespaces); got != tt.want {
t.Errorf("namespaceWatchScopeMessage(%v) = %q, want %q", tt.ignoredNamespaces, got, tt.want)
}
})
}
}
+2 -1
View File
@@ -204,9 +204,10 @@ CHART_FILE="deployments/kubernetes/chart/reloader/Chart.yaml"
sed -i "s/^version:.*/version: ${CHART_VERSION}/" "$CHART_FILE"
sed -i "s/^appVersion:.*/appVersion: v${APP_VERSION}/" "$CHART_FILE"
# Bump values.yaml: image.tag
# Bump values.yaml: image.tag and the deployment version label
VALUES_FILE="deployments/kubernetes/chart/reloader/values.yaml"
sed -i "s/^\( tag:\).*/\1 v${APP_VERSION}/" "$VALUES_FILE"
sed -i "s/^\( version:\).*/\1 v${APP_VERSION}/" "$VALUES_FILE"
# Show changes for review
info "Changes:"