Skip to content

Commit a8dc73a

Browse files
authored
[chore] architecture refactor (#863)
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
1 parent 50e0d1c commit a8dc73a

26 files changed

+960
-238
lines changed

cmd/shell-operator/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func start(logger *log.Logger) func(_ *kingpin.ParseContext) error {
3535
metrics.InitMetrics(app.PrometheusMetricsPrefix)
3636

3737
// Init logging and initialize a ShellOperator instance.
38-
operator, err := shell_operator.Init(logger.Named("shell-operator"))
38+
operator, err := shell_operator.Init(ctx, logger.Named("shell-operator"))
3939
if err != nil {
4040
return fmt.Errorf("init failed: %w", err)
4141
}

docs/src/BINDING_CONVERSION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ kubernetesCustomResourceConversion:
2121
# A CRD name.
2222
crdName: crontabs.stable.example.com
2323
# An array of conversions supported by this hook.
24-
conversion:
24+
conversions:
2525
- fromVersion: stable.example.com/v1alpha1
2626
toVersion: stable.example.com/v1alpha2
2727
```

docs/src/BINDING_VALIDATING.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ See example [204-validating-webhook](./examples/204-validating-webhook).
104104
105105
> Note that the `group` parameter is only for including snapshots. `kubernetesValidating` hook is never executed on `schedule` or `kubernetes` events with binding context with `"type":"Group"`.
106106
107-
The hook receives a binding context and should return response in `$VALIDATING_RESPONSE_PATH`.
107+
The hook receives a binding context and should return response in `$VALIDATING_RESPONSE_PATH` (also available as `$ADMISSION_RESPONSE_PATH`).
108108
109109
$BINDING_CONTEXT_PATH file example:
110110
@@ -242,8 +242,17 @@ Command line options:
242242
A path to a ca certificate for ValidatingWebhookConfiguration. Can be set
243243
with $VALIDATING_WEBHOOK_CA.
244244
--validating-webhook-client-ca=VALIDATING-WEBHOOK-CLIENT-CA ...
245-
A path to a server certificate for ValidatingWebhookConfiguration. Can be
246-
set with $VALIDATING_WEBHOOK_CLIENT_CA.
245+
A path to a client CA certificate for ValidatingWebhookConfiguration (can
246+
be set multiple times). Can be set with $VALIDATING_WEBHOOK_CLIENT_CA.
247+
--validating-webhook-failure-policy="Fail"
248+
Default failure policy for ValidatingWebhookConfiguration (Fail or
249+
Ignore). Can be set with $VALIDATING_WEBHOOK_FAILURE_POLICY.
250+
--validating-webhook-listen-port="9680"
251+
Port for the validating webhook HTTPS server. Can be set with
252+
$VALIDATING_WEBHOOK_LISTEN_PORT.
253+
--validating-webhook-listen-address="0.0.0.0"
254+
Address for the validating webhook HTTPS server. Can be set with
255+
$VALIDATING_WEBHOOK_LISTEN_ADDRESS.
247256
```
248257

249258
[admission-request]: https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#request

docs/src/HOOKS.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ kubernetes:
5151
kubernetesValidating:
5252
- {VALIDATING_PARAMETERS}
5353
- {VALIDATING_PARAMETERS}
54+
kubernetesCustomResourceConversion:
55+
- {CONVERSION_PARAMETERS}
56+
- {CONVERSION_PARAMETERS}
5457
settings:
5558
SETTINGS_PARAMETERS
5659
```
@@ -73,6 +76,14 @@ or in JSON format:
7376
{VALIDATING_PARAMETERS},
7477
{VALIDATING_PARAMETERS}
7578
],
79+
"kubernetesMutating": [
80+
{MUTATING_PARAMETERS},
81+
{MUTATING_PARAMETERS}
82+
],
83+
"kubernetesCustomResourceConversion": [
84+
{CONVERSION_PARAMETERS},
85+
{CONVERSION_PARAMETERS}
86+
],
7687
"settings": {SETTINGS_PARAMETERS}
7788
}
7889
```
@@ -155,7 +166,9 @@ kubernetes:
155166
kind: Pod # required
156167
executeHookOnEvent: [ "Added", "Modified", "Deleted" ]
157168
executeHookOnSynchronization: true|false # default is true
169+
waitForSynchronization: true|false # default is true
158170
keepFullObjectsInMemory: true|false # default is true
171+
resynchronizationPeriod: "1h"
159172
nameSelector:
160173
matchNames:
161174
- pod-0
@@ -244,6 +257,10 @@ kubernetes:
244257

245258
- `keepFullObjectsInMemory` — if not set or `true`, dumps of Kubernetes resources are cached for this binding, and the snapshot includes them as `object` fields. Set to `false` if the hook does not rely on full objects to reduce the memory footprint.
246259

260+
- `waitForSynchronization` — if `false`, Shell-operator will not wait for a hook's Synchronization to complete before processing further events for named queues. Default is `true`. Can only be set to `false` when `queue` is also explicitly specified.
261+
262+
- `resynchronizationPeriod` — a period in Go duration format (e.g. `1h`, `30m`) after which a full resynchronization (re-list + re-watch) of Kubernetes objects is issued for this binding. Useful to recover from missed watch events.
263+
247264
- `group` — a key that define a group of `schedule` and `kubernetes` bindings. See [grouping](#binding-context-of-grouped-bindings).
248265

249266
#### Example
@@ -353,7 +370,7 @@ Objects should match all expressions defined in `fieldSelector` and `labelSelect
353370

354371
### kubernetesValidating
355372

356-
Use a hook as handler for [ValidationWebhookConfiguration][admission-controllers].
373+
Use a hook as handler for [ValidatingWebhookConfiguration][admission-controllers].
357374

358375
See syntax and parameters in [BINDING_VALIDATING.md](BINDING_VALIDATING.md)
359376

@@ -369,7 +386,7 @@ When an event associated with a hook is triggered, Shell-operator executes the h
369386

370387
Temporary files have unique names to prevent collisions between queues and are deleted after the hook run.
371388

372-
Binging context is a JSON-array of structures with the following fields:
389+
Binding context is a JSON-array of structures with the following fields:
373390

374391
- `binding` — a string from the `name` parameter. If this parameter has not been set in the binding configuration, then strings "schedule" or "kubernetes" are used. For a hook executed at startup, this value is always "onStartup".
375392
- `type` — "Schedule" for `schedule` bindings. "Synchronization" or "Event" for `kubernetes` bindings. "Group" if `group` is defined.

0 commit comments

Comments
 (0)