metatron 0.11.3 → 0.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.dockerignore +9 -0
- data/.github/workflows/ci.yml +65 -0
- data/.release-please-manifest.json +1 -1
- data/.rubocop.yml +4 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +33 -0
- data/CONTRIBUTING.md +32 -1
- data/Gemfile +5 -0
- data/Gemfile.lock +13 -8
- data/README.md +53 -1
- data/Rakefile +5 -0
- data/integration/Dockerfile +29 -0
- data/integration/controller/Gemfile +8 -0
- data/integration/controller/Gemfile.lock +30 -0
- data/integration/controller/config.ru +21 -0
- data/integration/controller/lib/request_logger.rb +18 -0
- data/integration/controller/lib/widget_controller.rb +84 -0
- data/integration/manifests/composite-controller.yaml +62 -0
- data/integration/manifests/controller.yaml +70 -0
- data/integration/manifests/crd.yaml +46 -0
- data/integration/manifests/namespace.yaml +6 -0
- data/integration/manifests/sample-widget.yaml +9 -0
- data/lib/metatron/composite_controller.rb +4 -1
- data/lib/metatron/controller.rb +49 -7
- data/lib/metatron/middleware/auth.rb +103 -0
- data/lib/metatron/middleware/body_limit.rb +85 -0
- data/lib/metatron/problem.rb +47 -0
- data/lib/metatron/template.rb +4 -0
- data/lib/metatron/templates/horizontal_pod_autoscaler.rb +43 -0
- data/lib/metatron/version.rb +1 -1
- data/lib/metatron.rb +11 -1
- data/metatron.gemspec +4 -3
- data/script/integration +182 -0
- metadata +33 -10
data/script/integration
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# Run Metatron's integration suite against a real Metacontroller installation
|
|
4
|
+
# in a throwaway k3d cluster.
|
|
5
|
+
#
|
|
6
|
+
# Usage:
|
|
7
|
+
# script/integration # create cluster, run specs, delete cluster
|
|
8
|
+
# script/integration --keep # leave the cluster running for debugging
|
|
9
|
+
# script/integration --metacontroller-version v4.17.6
|
|
10
|
+
# script/integration --k3d-version v5.9.0
|
|
11
|
+
#
|
|
12
|
+
# Environment:
|
|
13
|
+
# K3D_CLUSTER_NAME cluster name (default: metatron-integration)
|
|
14
|
+
# K3D_VERSION expected k3d version, verified when set
|
|
15
|
+
# METATRON_IT_NAMESPACE namespace for the fixture controller
|
|
16
|
+
# METATRON_IT_IMAGE fixture image tag (default: metatron-integration:test)
|
|
17
|
+
# METATRON_IT_AUTH_TOKEN bearer token shared with Metacontroller
|
|
18
|
+
# METACONTROLLER_VERSION release tag to install (default: v4.17.6)
|
|
19
|
+
# METACONTROLLER_REPO local Metacontroller clone; used when the tag exists
|
|
20
|
+
set -euo pipefail
|
|
21
|
+
|
|
22
|
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
23
|
+
|
|
24
|
+
CLUSTER="${K3D_CLUSTER_NAME:-metatron-integration}"
|
|
25
|
+
K3D_VERSION="${K3D_VERSION:-}"
|
|
26
|
+
NAMESPACE="${METATRON_IT_NAMESPACE:-metatron-integration}"
|
|
27
|
+
IMAGE="${METATRON_IT_IMAGE:-metatron-integration:test}"
|
|
28
|
+
AUTH_TOKEN="${METATRON_IT_AUTH_TOKEN:-integration-secret-token}"
|
|
29
|
+
METACONTROLLER_VERSION="${METACONTROLLER_VERSION:-v4.17.6}"
|
|
30
|
+
METACONTROLLER_REPO="${METACONTROLLER_REPO:-$HOME/Development/golang/metacontroller}"
|
|
31
|
+
KEEP=0
|
|
32
|
+
|
|
33
|
+
usage() {
|
|
34
|
+
sed -n '2,/^set -euo pipefail$/p' "$0" | sed '$d' | sed 's/^# \{0,1\}//'
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
while [[ $# -gt 0 ]]; do
|
|
38
|
+
case "$1" in
|
|
39
|
+
--keep)
|
|
40
|
+
KEEP=1
|
|
41
|
+
shift
|
|
42
|
+
;;
|
|
43
|
+
--metacontroller-version)
|
|
44
|
+
METACONTROLLER_VERSION="${2:?missing version}"
|
|
45
|
+
shift 2
|
|
46
|
+
;;
|
|
47
|
+
--k3d-version)
|
|
48
|
+
K3D_VERSION="${2:?missing version}"
|
|
49
|
+
shift 2
|
|
50
|
+
;;
|
|
51
|
+
-h|--help)
|
|
52
|
+
usage
|
|
53
|
+
exit 0
|
|
54
|
+
;;
|
|
55
|
+
*)
|
|
56
|
+
echo "unknown argument: $1" >&2
|
|
57
|
+
usage >&2
|
|
58
|
+
exit 1
|
|
59
|
+
;;
|
|
60
|
+
esac
|
|
61
|
+
done
|
|
62
|
+
|
|
63
|
+
for command in docker k3d kubectl; do
|
|
64
|
+
if ! command -v "$command" >/dev/null 2>&1; then
|
|
65
|
+
echo "error: $command is required but not installed" >&2
|
|
66
|
+
exit 1
|
|
67
|
+
fi
|
|
68
|
+
done
|
|
69
|
+
|
|
70
|
+
if ! docker info >/dev/null 2>&1; then
|
|
71
|
+
echo "error: the Docker daemon is not reachable" >&2
|
|
72
|
+
exit 1
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
if [[ -n "$K3D_VERSION" ]]; then
|
|
76
|
+
installed_k3d="$(k3d version | awk '/^k3d version/ {print $3; exit}')"
|
|
77
|
+
if [[ "$installed_k3d" != "$K3D_VERSION" ]]; then
|
|
78
|
+
echo "error: requested k3d $K3D_VERSION but $installed_k3d is installed" >&2
|
|
79
|
+
exit 1
|
|
80
|
+
fi
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
KUBECONFIG_FILE=""
|
|
84
|
+
cleanup() {
|
|
85
|
+
status=$?
|
|
86
|
+
if [[ "$KEEP" -eq 0 ]]; then
|
|
87
|
+
k3d cluster delete "$CLUSTER" >/dev/null 2>&1 || true
|
|
88
|
+
else
|
|
89
|
+
echo
|
|
90
|
+
echo "Cluster '$CLUSTER' left running."
|
|
91
|
+
echo " export KUBECONFIG=$KUBECONFIG_FILE"
|
|
92
|
+
echo " kubectl -n $NAMESPACE get widgets,deployments,services,configmaps,secrets"
|
|
93
|
+
fi
|
|
94
|
+
if [[ "$KEEP" -eq 0 && -n "$KUBECONFIG_FILE" ]]; then
|
|
95
|
+
rm -f "$KUBECONFIG_FILE"
|
|
96
|
+
fi
|
|
97
|
+
exit "$status"
|
|
98
|
+
}
|
|
99
|
+
trap cleanup EXIT INT TERM
|
|
100
|
+
|
|
101
|
+
dump_debug() {
|
|
102
|
+
echo "=== cluster state ===" >&2
|
|
103
|
+
kubectl get pods -A >&2 || true
|
|
104
|
+
echo "=== fixture controller logs ===" >&2
|
|
105
|
+
kubectl -n "$NAMESPACE" logs -l app=widget-controller --tail=200 >&2 || true
|
|
106
|
+
}
|
|
107
|
+
trap dump_debug ERR
|
|
108
|
+
|
|
109
|
+
render_manifest() {
|
|
110
|
+
sed -e "s|__NAMESPACE__|$NAMESPACE|g" \
|
|
111
|
+
-e "s|__IMAGE__|$IMAGE|g" \
|
|
112
|
+
-e "s|__AUTH_TOKEN__|$AUTH_TOKEN|g" \
|
|
113
|
+
"$1"
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
apply_metacontroller_manifest() {
|
|
117
|
+
local file="$1"
|
|
118
|
+
if [[ -n "$LOCAL_MANIFESTS" ]]; then
|
|
119
|
+
git -C "$METACONTROLLER_REPO" show "$METACONTROLLER_VERSION:manifests/production/$file" | kubectl apply -f -
|
|
120
|
+
else
|
|
121
|
+
kubectl apply -f "$REMOTE_MANIFESTS/$file"
|
|
122
|
+
fi
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
# Prefer the local Metacontroller clone when it has the requested tag, so
|
|
126
|
+
# local runs do not depend on GitHub. CI falls back to the pinned release URL.
|
|
127
|
+
LOCAL_MANIFESTS=""
|
|
128
|
+
REMOTE_MANIFESTS=""
|
|
129
|
+
if [[ -d "$METACONTROLLER_REPO/.git" ]] && \
|
|
130
|
+
git -C "$METACONTROLLER_REPO" rev-parse -q --verify "refs/tags/$METACONTROLLER_VERSION" >/dev/null; then
|
|
131
|
+
LOCAL_MANIFESTS=1
|
|
132
|
+
echo "Using Metacontroller $METACONTROLLER_VERSION manifests from $METACONTROLLER_REPO"
|
|
133
|
+
else
|
|
134
|
+
REMOTE_MANIFESTS="https://raw.githubusercontent.com/metacontroller/metacontroller/${METACONTROLLER_VERSION}/manifests/production"
|
|
135
|
+
echo "Using Metacontroller $METACONTROLLER_VERSION manifests from $REMOTE_MANIFESTS"
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
echo "Creating k3d cluster '$CLUSTER'"
|
|
139
|
+
k3d cluster delete "$CLUSTER" >/dev/null 2>&1 || true
|
|
140
|
+
k3d cluster create "$CLUSTER" \
|
|
141
|
+
--agents 1 \
|
|
142
|
+
--wait \
|
|
143
|
+
--timeout 180s \
|
|
144
|
+
--kubeconfig-update-default=false \
|
|
145
|
+
--kubeconfig-switch-context=false
|
|
146
|
+
|
|
147
|
+
KUBECONFIG_FILE="$(mktemp)"
|
|
148
|
+
k3d kubeconfig write "$CLUSTER" --output "$KUBECONFIG_FILE" >/dev/null
|
|
149
|
+
export KUBECONFIG="$KUBECONFIG_FILE"
|
|
150
|
+
|
|
151
|
+
echo "Building fixture controller image '$IMAGE'"
|
|
152
|
+
docker build --file "$ROOT/integration/Dockerfile" --tag "$IMAGE" "$ROOT"
|
|
153
|
+
|
|
154
|
+
echo "Importing '$IMAGE' into '$CLUSTER'"
|
|
155
|
+
k3d image import "$IMAGE" --cluster "$CLUSTER"
|
|
156
|
+
|
|
157
|
+
echo "Installing Metacontroller $METACONTROLLER_VERSION"
|
|
158
|
+
apply_metacontroller_manifest metacontroller-namespace.yaml
|
|
159
|
+
apply_metacontroller_manifest metacontroller-crds-v1.yaml
|
|
160
|
+
apply_metacontroller_manifest metacontroller-rbac.yaml
|
|
161
|
+
apply_metacontroller_manifest metacontroller.yaml
|
|
162
|
+
|
|
163
|
+
kubectl wait --for=condition=Established --timeout=120s \
|
|
164
|
+
crd/compositecontrollers.metacontroller.k8s.io
|
|
165
|
+
kubectl -n metacontroller rollout status statefulset/metacontroller --timeout=180s
|
|
166
|
+
|
|
167
|
+
echo "Deploying fixture controller in namespace '$NAMESPACE'"
|
|
168
|
+
render_manifest "$ROOT/integration/manifests/namespace.yaml" | kubectl apply -f -
|
|
169
|
+
render_manifest "$ROOT/integration/manifests/crd.yaml" | kubectl apply -f -
|
|
170
|
+
kubectl wait --for=condition=Established --timeout=120s \
|
|
171
|
+
crd/widgets.metatron.therubyist.org
|
|
172
|
+
render_manifest "$ROOT/integration/manifests/controller.yaml" | kubectl apply -f -
|
|
173
|
+
kubectl -n "$NAMESPACE" rollout status deployment/widget-controller --timeout=180s
|
|
174
|
+
render_manifest "$ROOT/integration/manifests/composite-controller.yaml" | kubectl apply -f -
|
|
175
|
+
|
|
176
|
+
export RUN_INTEGRATION=1
|
|
177
|
+
export METATRON_IT_NAMESPACE="$NAMESPACE"
|
|
178
|
+
export METATRON_IT_RUN_ID="${METATRON_IT_RUN_ID:-$(date +%s)-$$}"
|
|
179
|
+
export METATRON_IT_AUTH_TOKEN="$AUTH_TOKEN"
|
|
180
|
+
|
|
181
|
+
cd "$ROOT"
|
|
182
|
+
bundle exec rspec spec/integration --format documentation
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metatron
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.11.
|
|
4
|
+
version: 0.11.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Gnagy
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -28,23 +28,29 @@ dependencies:
|
|
|
28
28
|
name: json
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: 2.21.2
|
|
34
|
+
- - "<"
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '3'
|
|
34
37
|
type: :runtime
|
|
35
38
|
prerelease: false
|
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
40
|
requirements:
|
|
38
|
-
- - "
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: 2.21.2
|
|
44
|
+
- - "<"
|
|
39
45
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
46
|
+
version: '3'
|
|
41
47
|
- !ruby/object:Gem::Dependency
|
|
42
48
|
name: rack
|
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
|
44
50
|
requirements:
|
|
45
51
|
- - ">="
|
|
46
52
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 2.2.
|
|
53
|
+
version: 2.2.25
|
|
48
54
|
- - "<"
|
|
49
55
|
- !ruby/object:Gem::Version
|
|
50
56
|
version: '4'
|
|
@@ -54,7 +60,7 @@ dependencies:
|
|
|
54
60
|
requirements:
|
|
55
61
|
- - ">="
|
|
56
62
|
- !ruby/object:Gem::Version
|
|
57
|
-
version: 2.2.
|
|
63
|
+
version: 2.2.25
|
|
58
64
|
- - "<"
|
|
59
65
|
- !ruby/object:Gem::Version
|
|
60
66
|
version: '4'
|
|
@@ -233,6 +239,7 @@ executables: []
|
|
|
233
239
|
extensions: []
|
|
234
240
|
extra_rdoc_files: []
|
|
235
241
|
files:
|
|
242
|
+
- ".dockerignore"
|
|
236
243
|
- ".github/workflows/ci.yml"
|
|
237
244
|
- ".github/workflows/release.yml"
|
|
238
245
|
- ".gitignore"
|
|
@@ -249,10 +256,24 @@ files:
|
|
|
249
256
|
- README.md
|
|
250
257
|
- Rakefile
|
|
251
258
|
- bin/console
|
|
259
|
+
- integration/Dockerfile
|
|
260
|
+
- integration/controller/Gemfile
|
|
261
|
+
- integration/controller/Gemfile.lock
|
|
262
|
+
- integration/controller/config.ru
|
|
263
|
+
- integration/controller/lib/request_logger.rb
|
|
264
|
+
- integration/controller/lib/widget_controller.rb
|
|
265
|
+
- integration/manifests/composite-controller.yaml
|
|
266
|
+
- integration/manifests/controller.yaml
|
|
267
|
+
- integration/manifests/crd.yaml
|
|
268
|
+
- integration/manifests/namespace.yaml
|
|
269
|
+
- integration/manifests/sample-widget.yaml
|
|
252
270
|
- lib/metatron.rb
|
|
253
271
|
- lib/metatron/composite_controller.rb
|
|
254
272
|
- lib/metatron/controller.rb
|
|
255
273
|
- lib/metatron/controllers/ping.rb
|
|
274
|
+
- lib/metatron/middleware/auth.rb
|
|
275
|
+
- lib/metatron/middleware/body_limit.rb
|
|
276
|
+
- lib/metatron/problem.rb
|
|
256
277
|
- lib/metatron/railtie.rb
|
|
257
278
|
- lib/metatron/template.rb
|
|
258
279
|
- lib/metatron/templates/cluster_role.rb
|
|
@@ -271,6 +292,7 @@ files:
|
|
|
271
292
|
- lib/metatron/templates/grpc_route.rb
|
|
272
293
|
- lib/metatron/templates/grpc_route/filter.rb
|
|
273
294
|
- lib/metatron/templates/grpc_route/rule.rb
|
|
295
|
+
- lib/metatron/templates/horizontal_pod_autoscaler.rb
|
|
274
296
|
- lib/metatron/templates/http_route.rb
|
|
275
297
|
- lib/metatron/templates/http_route/filter.rb
|
|
276
298
|
- lib/metatron/templates/http_route/rule.rb
|
|
@@ -301,6 +323,7 @@ files:
|
|
|
301
323
|
- lib/metatron/version.rb
|
|
302
324
|
- metatron.gemspec
|
|
303
325
|
- release-please-config.json
|
|
326
|
+
- script/integration
|
|
304
327
|
homepage: https://github.com/jgnagy/metatron
|
|
305
328
|
licenses:
|
|
306
329
|
- MIT
|
|
@@ -314,9 +337,9 @@ require_paths:
|
|
|
314
337
|
- lib
|
|
315
338
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
316
339
|
requirements:
|
|
317
|
-
- - "
|
|
340
|
+
- - ">="
|
|
318
341
|
- !ruby/object:Gem::Version
|
|
319
|
-
version: '3.
|
|
342
|
+
version: '3.3'
|
|
320
343
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
321
344
|
requirements:
|
|
322
345
|
- - ">="
|