Skip to content

Commit 92e571b

Browse files
authored
Introduce devel mode for controlling log level (#529)
* Build images with clean git state * Remove excessive `requires` references The deploy order is kept even if `requires` is not set. However, `requires` causes more modules to be deployed than selected. * Drop default `--zap-log-level=info` Dropping the flag with its default value makes it easier to overwrite. * Drop default zap devel, use instead of log level * Add explicit devel mode
1 parent abf719d commit 92e571b

File tree

20 files changed

+95
-40
lines changed

20 files changed

+95
-40
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.envrc
33
hack/kind_kubeconfig.yaml
44
.gitguardian.yaml
5+
.ko.yaml
56

67
# Binaries for programs and plugins
78
*.exe

.run/shard (kind).run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<configuration default="false" name="checksum-controller (kind)" type="GoApplicationRunConfiguration" factoryName="Go Application">
33
<module name="kubernetes-controller-sharding" />
44
<working_directory value="$PROJECT_DIR$" />
5-
<parameters value="--zap-log-level=debug --shard-name=checksum-controller-host --lease-namespace=default" />
5+
<parameters value="--zap-devel --shard-name=checksum-controller-host --lease-namespace=default" />
66
<envs>
77
<env name="KUBECONFIG" value="$PROJECT_DIR$/hack/kind_kubeconfig.yaml" />
88
</envs>

.run/sharder (kind).run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<configuration default="false" name="sharder (kind)" type="GoApplicationRunConfiguration" factoryName="Go Application">
33
<module name="kubernetes-controller-sharding" />
44
<working_directory value="$PROJECT_DIR$" />
5-
<parameters value="--config=hack/config/sharder/host/config.yaml --zap-log-level=debug" />
5+
<parameters value="--config=hack/config/sharder/host/config.yaml --zap-devel" />
66
<envs>
77
<env name="LEADER_ELECT" value="false" />
88
<env name="KUBECONFIG" value="$PROJECT_DIR$/hack/kind_kubeconfig.yaml" />

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ run: $(KUBECTL) generate-fast ## Run the sharder from your host and deploy prere
140140
$(MAKE) deploy SKAFFOLD_MODULE=cert-manager
141141
$(KUBECTL) apply --server-side --force-conflicts -k config/crds
142142
$(KUBECTL) apply --server-side --force-conflicts -k hack/config/certificates/host
143-
go run ./cmd/sharder --config=hack/config/sharder/host/config.yaml --zap-log-level=debug
143+
go run ./cmd/sharder --config=hack/config/sharder/host/config.yaml --zap-devel
144144

145145
SHARD_NAME ?= checksum-controller-$(shell tr -dc bcdfghjklmnpqrstvwxz2456789 </dev/urandom | head -c 8)
146146

147147
.PHONY: run-checksum-controller
148148
run-checksum-controller: $(KUBECTL) ## Run checksum-controller from your host and deploy prerequisites.
149149
$(KUBECTL) apply --server-side --force-conflicts -k hack/config/checksum-controller/controllerring
150-
go run ./cmd/checksum-controller --shard-name=$(SHARD_NAME) --lease-namespace=default --zap-log-level=debug
150+
go run ./cmd/checksum-controller --shard-name=$(SHARD_NAME) --lease-namespace=default --zap-devel
151151

152152
PUSH ?= false
153153
images: export KO_DOCKER_REPO = $(GHCR_REPO)

cmd/checksum-controller/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ type options struct {
8888
func newOptions() *options {
8989
return &options{
9090
zapOptions: &zap.Options{
91-
Development: true,
9291
TimeEncoder: zapcore.ISO8601TimeEncoder,
9392
},
9493

cmd/sharder/app/options.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ type options struct {
6363
func newOptions() *options {
6464
return &options{
6565
zapOptions: &zap.Options{
66-
Development: true,
6766
TimeEncoder: zapcore.ISO8601TimeEncoder,
6867
},
6968
}

config/sharder/deployment.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ spec:
2222
- name: sharder
2323
image: sharder:latest
2424
args:
25-
- --zap-log-level=info
2625
- --config=/config.yaml
2726
volumeMounts:
2827
- name: config

hack/config/checksum-controller/controller/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ spec:
1313
- name: checksum-controller
1414
image: checksum-controller:latest
1515
args:
16-
- --zap-log-level=debug
16+
- --zap-devel
1717
env:
1818
- name: DISABLE_HTTP2
1919
value: "true"

hack/config/sharder/local/kustomization.yaml renamed to hack/config/sharder/devel/kustomization.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ patches:
1111
name: sharder
1212
namespace: sharding-system
1313
patch: |
14-
- op: test
15-
path: /spec/template/spec/containers/0/args/0
16-
value: --zap-log-level=info
17-
- op: replace
18-
path: /spec/template/spec/containers/0/args/0
19-
value: --zap-log-level=debug
14+
- op: add
15+
path: /spec/template/spec/containers/0/args/-
16+
value: --zap-devel

hack/config/skaffold.yaml

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,6 @@ apiVersion: skaffold/v4beta12
172172
kind: Config
173173
metadata:
174174
name: sharder
175-
requires:
176-
- configs:
177-
- policy
178175
build:
179176
artifacts:
180177
- image: ghcr.io/timebertt/kubernetes-controller-sharding/sharder
@@ -208,21 +205,19 @@ deploy:
208205
- --force-conflicts
209206
defaultNamespace: ""
210207
profiles:
211-
- name: kind
208+
- name: devel
212209
activation:
213210
- kubeContext: kind-.*
211+
- env: DEVEL=true
214212
patches:
215213
- op: replace
216214
path: /manifests/kustomize/paths/0
217-
value: hack/config/sharder/local
215+
value: hack/config/sharder/devel
218216
---
219217
apiVersion: skaffold/v4beta12
220218
kind: Config
221219
metadata:
222220
name: checksum-controller
223-
requires:
224-
- configs:
225-
- policy
226221
build:
227222
artifacts:
228223
- image: ghcr.io/timebertt/kubernetes-controller-sharding/checksum-controller
@@ -342,10 +337,6 @@ apiVersion: skaffold/v4beta12
342337
kind: Config
343338
metadata:
344339
name: webhosting-operator
345-
requires:
346-
- configs:
347-
- policy
348-
- monitoring-crds
349340
build:
350341
artifacts:
351342
- image: ghcr.io/timebertt/kubernetes-controller-sharding/webhosting-operator
@@ -382,6 +373,14 @@ deploy:
382373
- make
383374
- generate-fast-webhosting
384375
profiles:
376+
- name: devel
377+
activation:
378+
- kubeContext: kind-.*
379+
- env: DEVEL=true
380+
patches:
381+
- op: replace
382+
path: /manifests/kustomize/paths/0
383+
value: webhosting-operator/config/manager/overlays/devel
385384
- name: debug
386385
activation:
387386
- command: debug
@@ -403,26 +402,47 @@ profiles:
403402
patches:
404403
- op: replace
405404
path: /manifests/kustomize/paths/0
406-
# default configuration: only run operator shards and use external sharding implementation via ControllerRing
405+
# default configuration: run sharded operator and use external sharding implementation via ControllerRing
407406
value: webhosting-operator/config/manager/overlays/shoot/default
408407
- op: add
409408
path: /manifests/kustomize/paths/-
410409
value: webhosting-operator/config/policy
410+
- name: shoot-devel
411+
requiresAllActivations: true
412+
activation:
413+
- kubeContext: .*--sharding.*
414+
- env: DEVEL=true
415+
patches:
416+
- op: replace
417+
path: /manifests/kustomize/paths/0
418+
# default configuration + devel mode
419+
value: webhosting-operator/config/manager/overlays/shoot/devel
411420
- name: shoot-non-sharded
421+
requiresAllActivations: true
422+
activation:
423+
- kubeContext: .*--sharding.*
424+
- env: ENABLE_SHARDING=false
412425
patches:
413426
- op: replace
414427
path: /manifests/kustomize/paths/0
415428
# singleton controller without sharding for comparison
416429
value: webhosting-operator/config/manager/overlays/shoot/non-sharded
430+
- name: shoot-non-sharded-devel
431+
requiresAllActivations: true
432+
activation:
433+
- kubeContext: .*--sharding.*
434+
- env: ENABLE_SHARDING=false
435+
- env: DEVEL=true
436+
patches:
437+
- op: replace
438+
path: /manifests/kustomize/paths/0
439+
# non-sharded configuration + devel mode
440+
value: webhosting-operator/config/manager/overlays/shoot/non-sharded-devel
417441
---
418442
apiVersion: skaffold/v4beta12
419443
kind: Config
420444
metadata:
421445
name: experiment
422-
requires:
423-
- configs:
424-
- policy
425-
- monitoring-crds
426446
profiles:
427447
- name: expirement
428448
activation:

0 commit comments

Comments
 (0)