Skip to content

Commit dce474f

Browse files
authored
Merge pull request #201 from che-incubator/update-project
chore: update project scaffolding and dependencies
2 parents 58661a0 + 82c4f7f commit dce474f

13 files changed

Lines changed: 350 additions & 357 deletions

File tree

.devfile.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
schemaVersion: 2.3.0
2+
metadata:
3+
name: configbump
4+
components:
5+
- name: tools
6+
container:
7+
image: quay.io/devfile/devworkspace-devtools:latest
8+
memoryRequest: 1Gi
9+
memoryLimit: 16Gi
10+
cpuLimit: '4'
11+
cpuRequest: '0.5'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*.dll
55
*.so
66
*.dylib
7+
__debug_bin
8+
/configbump
79

810
# Test binary, built with `go test -c`
911
*.test

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"RooVeterinaryInc.roo-cline"
4+
]
5+
}

.vscode/launch.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@
1111
"mode": "auto",
1212
"program": "${fileDirname}",
1313
"env": {},
14-
"args": ["--dir", "test", "--namespace", "default", "--labels", "bump=true"]
14+
"args": [
15+
"--dir",
16+
"test",
17+
"--namespace",
18+
"default",
19+
"--labels",
20+
"bump=true"
21+
]
1522
}
1623
]
1724
}

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ When the process signalling is implemented, this tool will be compatible with ma
2121

2222
We originally wrote a prototype of this tool in Rust (https://github.com/metlos/cm-bump) that implements both configmap syncing and process signalling and we successfully used it for dynamic reconfiguration of HAProxy, Nginx and Traefik.
2323

24-
## Configuration
24+
## Run
2525

2626
```
2727
$ ./configbump --help
@@ -38,6 +38,21 @@ Options:
3838
--version display version and exit
3939
```
4040

41+
## Build
42+
43+
build the container by running these commands in the project root directory:
44+
45+
```sh
46+
IMG=quay.io/che-incubator/configbump:next
47+
podman build -t ${IMG} -f build/dockerfiles/Dockerfile .
48+
```
49+
50+
Or build the configbump binary like this (requires Go 1.25.5+):
51+
52+
```sh
53+
go build -a -ldflags '-w -s' -a -installsuffix cgo -o configbump cmd/configbump/main.go
54+
```
55+
4156
## Examples
4257

4358
An example of using Traefik with configbump as a sidecar in a single pod to enable configbump dynamically downloading configuration files to a directory that Traefik watches for configuration changes can be found in deploy_example.yaml file.

RELEASE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
Use "Release Che Configbump" workflow for release, which can be triggered manually on GitHub page of the repository at Actions -> "Release Che Configbump" -> "Run workflow"
44

55
Normally this workflow will be triggered as part of a Che release - see https://github.com/eclipse-che/che-release/actions/workflows/release-orchestrate-overall.yml
6+

build/dockerfiles/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# see also brew.Dockerfile
1313

1414
# https://registry.access.redhat.com/ubi9/go-toolset
15-
FROM registry.access.redhat.com/ubi9/go-toolset:9.5-1745328278 as builder
15+
FROM registry.access.redhat.com/ubi9/go-toolset:9.7-1769430014 as builder
1616
USER 0
1717
ENV GOPATH=/go/ \
1818
CGO_ENABLED=1
@@ -30,7 +30,7 @@ RUN export ARCH="$(uname -m)" && if [[ ${ARCH} == "x86_64" ]]; then export ARCH=
3030
chmod 755 /usr/local/bin/configbump
3131

3232
# https://registry.access.redhat.com/ubi9-minimal
33-
FROM registry.access.redhat.com/ubi9-minimal:9.5-1742914212 as runtime
33+
FROM registry.access.redhat.com/ubi9-minimal:9.7-1771346502 as runtime
3434
#hadolint ignore=DL4006
3535
RUN microdnf -y install shadow-utils && \
3636
adduser appuser && \

cmd/configbump/main.go

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
package main
22

33
import (
4-
"github.com/go-logr/zapr"
5-
"go.uber.org/zap"
4+
"context"
5+
"errors"
66
"os"
77

88
arg "github.com/alexflint/go-arg"
99
"github.com/che-incubator/configbump/pkg/configmaps"
10-
"github.com/operator-framework/operator-sdk/pkg/k8sutil"
11-
"github.com/operator-framework/operator-sdk/pkg/ready"
10+
"github.com/go-logr/zapr"
11+
"go.uber.org/zap"
12+
13+
// controller-runtime imports
14+
"sigs.k8s.io/controller-runtime/pkg/cache"
1215
"sigs.k8s.io/controller-runtime/pkg/client/config"
13-
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
16+
logf "sigs.k8s.io/controller-runtime/pkg/log"
1417
"sigs.k8s.io/controller-runtime/pkg/manager"
15-
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
18+
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
19+
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
1620
)
1721

1822
// Opts represents the commandline arguments to the executable
@@ -43,6 +47,9 @@ const controllerName = "config-bump"
4347
var log = logf.Log.WithName(controllerName)
4448

4549
func main() {
50+
// Setup signal handler to gracefully shut down the manager
51+
ctx := signals.SetupSignalHandler()
52+
4653
zap, err := zap.NewProduction()
4754
if err != nil {
4855
println("Failed to initialize a zap logger.")
@@ -61,51 +68,52 @@ func main() {
6168

6269
// once process signalling is implemented, we can call:
6370
// initializeConfigMapController(opts.Labels, opts.Dir, b.Bump)
64-
if err := initializeConfigMapController(opts.Labels, opts.Dir, opts.Namespace, func() error { return nil }); err != nil {
71+
if err := initializeConfigMapController(ctx, opts.Labels, opts.Dir, opts.Namespace, func() error { return nil }); err != nil {
6572
log.Error(err, "Could not initialize the config map sync controller")
6673
os.Exit(1)
6774
}
6875
}
6976

70-
func initializeConfigMapController(labels string, baseDir string, namespace string, onReconcileDone func() error) error {
71-
// Get a config to talk to the apiserver
77+
func initializeConfigMapController(ctx context.Context, labels string, baseDir string, namespace string, onReconcileDone func() error) error {
7278
cfg, err := config.GetConfig()
7379
if err != nil {
80+
log.Error(err, "Could not get config from API server")
7481
return err
7582
}
7683

7784
if namespace == "" {
78-
namespace, err = k8sutil.GetWatchNamespace()
79-
if err != nil {
80-
namespace, err = k8sutil.GetOperatorNamespace()
81-
if err != nil {
82-
return err
83-
}
84-
}
85-
}
86-
87-
ready := ready.NewFileReady()
88-
err = ready.Set()
89-
if err != nil {
85+
err := errors.New("namespace was not provided via commandline arguments")
86+
log.Error(err, "Configmap controller initialization failed")
9087
return err
9188
}
92-
defer ready.Unset()
9389

94-
mgr, err := manager.New(cfg, manager.Options{MetricsBindAddress: "0", Namespace: namespace})
90+
mgr, err := manager.New(cfg, manager.Options{
91+
Metrics: metricsserver.Options{
92+
BindAddress: "0",
93+
},
94+
Cache: cache.Options{
95+
DefaultNamespaces: map[string]cache.Config{namespace: cache.Config{}},
96+
},
97+
})
9598
if err != nil {
99+
log.Error(err, "Could not create a manager for creating controllers")
96100
return err
97101
}
98102

99-
_, err = configmaps.New(mgr, configmaps.ConfigMapReconcilerConfig{
103+
configmapReconciler, err := configmaps.New(mgr, configmaps.ConfigMapReconcilerConfig{
100104
BaseDir: baseDir,
101105
Labels: labels,
102106
OnReconcileDone: onReconcileDone,
103107
Namespace: namespace,
104108
})
105-
106109
if err != nil {
110+
log.Error(err, "Could not initialize configmaps reconciler")
107111
return err
108112
}
109113

110-
return mgr.Start(signals.SetupSignalHandler())
114+
if err = configmapReconciler.SetupWithManager(mgr); err != nil {
115+
log.Error(err, "Could not setup the manager with configmaps reconciler")
116+
return err
117+
}
118+
return mgr.Start(ctx)
111119
}

deploy_example.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ spec:
4444
serviceAccountName: sa-able-to-access-k8s-api-and-read-configmaps
4545
containers:
4646
- name: traefik
47-
image: docker.io/traefik:v2.2.8
47+
image: quay.io/eclipse/che--traefik:v3.6.13-abb4f51887319c9b9d9cfe1d3cdf9379a771138003bf683f10e97697e148f95f
4848
volumeMounts:
4949
- name: config
5050
mountPath: /etc/traefik
5151
- name: dynamic-config
5252
mountPath: "/dynamic-config"
5353
- name: config-map-sync
54-
image: quay.io/che-incubator/configbump:latest
54+
image: quay.io/che-incubator/configbump:next
5555
env:
5656
- name: CONFIG_BUMP_DIR
5757
value: "/dynamic-config"

go.mod

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,71 @@
11
module github.com/che-incubator/configbump
22

3-
go 1.23.0
4-
5-
toolchain go1.23.8
3+
go 1.25.5
64

75
require (
8-
github.com/alexflint/go-arg v1.3.0
9-
github.com/go-logr/zapr v0.1.0
10-
github.com/operator-framework/operator-sdk v0.5.0
11-
go.uber.org/zap v1.9.1
12-
k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b
13-
k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d
14-
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
15-
sigs.k8s.io/controller-runtime v0.2.1
6+
github.com/alexflint/go-arg v1.6.1
7+
github.com/go-logr/zapr v1.3.0
8+
go.uber.org/zap v1.27.0
9+
k8s.io/api v0.34.1
10+
k8s.io/apimachinery v0.34.1
11+
k8s.io/client-go v0.34.1
12+
sigs.k8s.io/controller-runtime v0.22.1
1613
)
1714

1815
require (
19-
github.com/alexflint/go-scalar v1.0.0 // indirect
16+
github.com/alexflint/go-scalar v1.2.0 // indirect
2017
github.com/beorn7/perks v1.0.1 // indirect
21-
github.com/cespare/xxhash/v2 v2.1.1 // indirect
22-
github.com/davecgh/go-spew v1.1.1 // indirect
23-
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
24-
github.com/go-logr/logr v0.1.0 // indirect
18+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
19+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
20+
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
21+
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
22+
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
23+
github.com/fsnotify/fsnotify v1.9.0 // indirect
24+
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
25+
github.com/go-logr/logr v1.4.2 // indirect
26+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
27+
github.com/go-openapi/jsonreference v0.20.2 // indirect
28+
github.com/go-openapi/swag v0.23.0 // indirect
2529
github.com/gogo/protobuf v1.3.2 // indirect
26-
github.com/golang/groupcache v0.0.0-20180513044358-24b0969c4cb7 // indirect
27-
github.com/golang/protobuf v1.5.0 // indirect
28-
github.com/google/gofuzz v1.0.0 // indirect
29-
github.com/googleapis/gnostic v0.3.1 // indirect
30-
github.com/hashicorp/golang-lru v0.0.0-20180201235237-0fb14efe8c47 // indirect
31-
github.com/imdario/mergo v0.3.6 // indirect
32-
github.com/json-iterator/go v1.1.11 // indirect
33-
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
30+
github.com/google/btree v1.1.3 // indirect
31+
github.com/google/gnostic-models v0.7.0 // indirect
32+
github.com/google/go-cmp v0.7.0 // indirect
33+
github.com/google/uuid v1.6.0 // indirect
34+
github.com/josharian/intern v1.0.0 // indirect
35+
github.com/json-iterator/go v1.1.12 // indirect
36+
github.com/mailru/easyjson v0.7.7 // indirect
3437
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
35-
github.com/modern-go/reflect2 v1.0.1 // indirect
36-
github.com/pborman/uuid v0.0.0-20170612153648-e790cca94e6c // indirect
38+
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
39+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
3740
github.com/pkg/errors v0.9.1 // indirect
38-
github.com/prometheus/client_golang v1.11.1 // indirect
39-
github.com/prometheus/client_model v0.2.0 // indirect
40-
github.com/prometheus/common v0.26.0 // indirect
41-
github.com/prometheus/procfs v0.6.0 // indirect
42-
github.com/spf13/pflag v1.0.2 // indirect
43-
go.uber.org/atomic v1.3.2 // indirect
44-
go.uber.org/multierr v1.1.0 // indirect
45-
golang.org/x/crypto v0.35.0 // indirect
46-
golang.org/x/net v0.25.0 // indirect
47-
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 // indirect
48-
golang.org/x/sys v0.30.0 // indirect
49-
golang.org/x/term v0.29.0 // indirect
50-
golang.org/x/text v0.22.0 // indirect
51-
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 // indirect
52-
gomodules.xyz/jsonpatch/v2 v2.0.1 // indirect
53-
google.golang.org/appengine v1.4.0 // indirect
54-
google.golang.org/protobuf v1.33.0 // indirect
55-
gopkg.in/fsnotify.v1 v1.4.7 // indirect
41+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
42+
github.com/prometheus/client_golang v1.22.0 // indirect
43+
github.com/prometheus/client_model v0.6.1 // indirect
44+
github.com/prometheus/common v0.62.0 // indirect
45+
github.com/prometheus/procfs v0.15.1 // indirect
46+
github.com/spf13/pflag v1.0.6 // indirect
47+
github.com/x448/float16 v0.8.4 // indirect
48+
go.uber.org/multierr v1.11.0 // indirect
49+
go.yaml.in/yaml/v2 v2.4.2 // indirect
50+
go.yaml.in/yaml/v3 v3.0.4 // indirect
51+
golang.org/x/net v0.38.0 // indirect
52+
golang.org/x/oauth2 v0.27.0 // indirect
53+
golang.org/x/sync v0.12.0 // indirect
54+
golang.org/x/sys v0.31.0 // indirect
55+
golang.org/x/term v0.30.0 // indirect
56+
golang.org/x/text v0.23.0 // indirect
57+
golang.org/x/time v0.9.0 // indirect
58+
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
59+
google.golang.org/protobuf v1.36.5 // indirect
60+
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
5661
gopkg.in/inf.v0 v0.9.1 // indirect
57-
gopkg.in/yaml.v2 v2.4.0 // indirect
58-
k8s.io/klog v0.3.0 // indirect
59-
k8s.io/kube-openapi v0.0.0-20180731170545-e3762e86a74c // indirect
60-
k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5 // indirect
61-
sigs.k8s.io/yaml v1.1.0 // indirect
62+
gopkg.in/yaml.v3 v3.0.1 // indirect
63+
k8s.io/apiextensions-apiserver v0.34.0 // indirect
64+
k8s.io/klog/v2 v2.130.1 // indirect
65+
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
66+
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect
67+
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
68+
sigs.k8s.io/randfill v1.0.0 // indirect
69+
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
70+
sigs.k8s.io/yaml v1.6.0 // indirect
6271
)

0 commit comments

Comments
 (0)