Skip to content

Commit 6112462

Browse files
author
xavier
committed
async dots working
1 parent fa78b93 commit 6112462

File tree

12 files changed

+344
-111
lines changed

12 files changed

+344
-111
lines changed

platform-kama/Pipfile.lock

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platform-kama/configs/misc/inspections/resources-in-sync-inspections.yaml

Lines changed: 94 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,104 @@
1-
kind: MultiPredicate
1+
2+
kind: HealthScout
3+
model_matcher:
4+
kind: ManifestVariable
5+
id: variable.template.ingress_route_path
6+
optimistic_predicates:
7+
- predicate.ingress_enabled_resource_in_sync
8+
pessimistic_predicates:
9+
- bar
10+
11+
---
12+
13+
kind: HealthScout
14+
model_match:
15+
kind: Concern
16+
identity:
17+
res_kind: Pod
18+
pessimistic_predicates:
19+
- maybe get alerts from prometheus?
20+
- check that restarts < N
21+
- check that events with "warning" < N
22+
- check that ternary_status = positive
23+
24+
---
25+
26+
kind: Predicate
227
id: predicate.ingress_enabled_resource_in_sync
328
title: Ingress enabled variable/resource in Sync?
29+
info: "Ensure resource exists if and only if variable set to true"
430
reason: "The variable 'ingress.enabled' and the Kubernetes resource
531
are out of sync: the variable is set to 'false' but the resource
632
exists. This is a normal occurrence when you change the 'ingress.enabled'
733
variable directly instead of running the operation."
8-
operator: and
34+
35+
challenge:
36+
kind: ResourcesSupplier
37+
selector: {res_kind: Ingress}
38+
output: ". | length"
39+
40+
check_against:
41+
kind: IfThenElse
42+
source:
43+
kind: Predicate
44+
challenge: get::kind::MergedVariablesSupplier->.ingress.enabled
45+
operator: truthy
46+
if_true: 1
47+
if_false: 0
48+
49+
---
50+
51+
kind: Predicate
52+
id: predicate.publisher_frontend_enabled_resource_in_sync
53+
title: Publisher Frontend enabled variable/resource in Sync?
54+
info: "Ensure resources exists if and only if variable set to true"
55+
reason: "The variable 'publisher_frontend.enabled' and the Kubernetes resource
56+
are out of sync: the variable is set to 'false' but the resource
57+
exists. This is a normal occurrence when you change the 'publisher_frontend.enabled'
58+
variable directly instead of running the operation."
59+
60+
challenge:
61+
kind: ResourcesSupplier
62+
selector:
63+
res_kind: Deployment
64+
name: publisher-frontend
65+
output: ". | length"
66+
67+
check_against:
68+
kind: IfThenElse
69+
source:
70+
kind: Predicate
71+
challenge: get::kind::MergedVariablesSupplier->.publisher_frontend.enabled
72+
operator: truthy
73+
if_true: 1
74+
if_false: 0
75+
76+
---
77+
78+
kind: MultiPredicate
79+
id: predicate.publisher_frontend.redundant_exposure
80+
title: Service type matches Ingress config
81+
info: "Ensure ingress does not make service type redundant"
82+
reason: "The service type is made redundant by your ingress configuration.
83+
If you wish to expose your service via Ingress, the service type should
84+
be trivial, that is 'ClusterIP', otherwise, you might be unintentionally
85+
double-serving this service."
86+
87+
ingress_enabled: get::kind::MergedVariablesSupplier->.ingress.enabled
88+
routed: get::kind::MergedVariablesSupplier->.ingress.routes.publisher_frontend.host
89+
svc_type: get::kind::MergedVariablesSupplier->.publisher_frontend.service_type
90+
has_ingress_intent:
91+
kind: MultiPredicate
92+
predicates: [get::self>>ingress_enabled, get::self>>routed]
93+
is_external_svc:
94+
kind: Predicate
95+
operator: in
96+
challenge: get::self>>svc_type
97+
check_against: [NodePort, LoadBalancer]
98+
predicates:
99+
- get::self>>has_ingress_intent
100+
- get::self>>is_external_svc
9101
negate: true
10-
source:
11-
- kind: Predicate
12-
challenge: get::kind::ConfigVarsSupplier->.ingress.enabled
13-
operator: falsy
14-
- kind: ResourceCountPredicate
15-
res_kind: Ingress
16-
operator: greater-than
17-
check_against: 0
18102

19103
---
20104

platform-kama/configs/misc/predicates.yaml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
kind: Predicate
2+
id: predicate.status-computer
3+
info: Just checks whether all pods are running
4+
labels:
5+
role: status-computer
6+
challenge:
7+
kind: ResourcesSupplier
8+
selector:
9+
res_kind: Pod
10+
label_selector: {app: nmachine}
11+
output: ternary_status
12+
serializer: legacy
13+
operator: contains-only
14+
check_against: ['positive', 'pending']
15+
16+
---
17+
118
kind: ResourceCountPredicate
219
id: predicate.db-creds-exists
320
title: Database credentials secret exists
@@ -36,14 +53,3 @@ cached:
3653
many: false
3754
serializer: legacy
3855
source: get::self>>res=>decoded_data
39-
40-
---
41-
#
42-
#kind: Predicate
43-
#res:
44-
# kind: ResourcesSupplier
45-
# selector:
46-
# res_kind: Secret
47-
# name: db-creds
48-
# many: false
49-
#challenge: get::self>>res=>data->.db_user=>__count__

platform-kama/configs/variables/ingress_vars.yaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ title: Application Ingress Toggle
3939
info: "If enabled, Ingress resource is provisioned to route out-of-cluster
4040
traffic to the application's various services. Note that you must have
4141
a DNS solution"
42-
input:
43-
kind: OnOffInput
44-
correctness_predicates:
42+
input: {kind: OnOffInput}
43+
health_predicates:
4544
- id::predicate.ingress_enabled_resource_in_sync
4645

4746
---
@@ -50,8 +49,8 @@ kind: ManifestVariable
5049
id: ingress.routes.publisher_frontend.host
5150
inherit: variable.template.ingress_route_host
5251
casual_name: Publisher Dashboard
53-
correctness_predicates:
54-
- kind::FalsePredicate
52+
health_predicates:
53+
- id::predicate.publisher_frontend.redundant_exposure
5554

5655
---
5756

@@ -74,6 +73,13 @@ id: ingress.routes.backend.host
7473
inherit: variable.template.ingress_route_host
7574
casual_name: Backend
7675

76+
---
77+
78+
kind: ManifestVariable
79+
id: ingress.class
80+
title: Ingress controller class
81+
info: "Name of Ingress controller for consuming ingress resources. It
82+
must exist in your Kubernetes cluster; it will not be created otherwise"
7783

7884

7985
################## DEPENDENCIES ###################
@@ -85,8 +91,7 @@ kind: ManifestVariableDependency
8591
id: variable-dependency.when-ingress-is-disabled
8692
title: Value ignored when ingress.enabled is false
8793
from: [id::ingress.enabled]
88-
to:
89-
id: [ingress.class, ingress.routes.*]
94+
to: {id: [ingress.class, ingress.routes.*]}
9095
active:
9196
kind: Predicate
9297
challenge: get::self>>from_variable>>current_value
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
kind: ConfigurationPreset
22
id: provider.presets.default
3-
title: Absolute Default
4-
info: Bare minimum defaults set by the publisher.
3+
title: Base Configuration Only
4+
info: "Ships with an INSECURE database, no authentication provider,
5+
no automation."
56
default: true
6-
variables:
7-
kind: ConfigSupplier
8-
field_key: default_vars
7+
variables: get::kind::DefaultVariablesSupplier
98

109
---
1110

1211
kind: ConfigurationPreset
1312
id: provider.presets.high-limits
1413
title: Starter pack
15-
info: Insecure database, no authentication provider.
14+
info: "Insecure database, no authentication provider."
15+
requires_further_config: true
1616
variables:
1717
kind: PresetAssignmentsSupplier
1818
source: unsafe-database
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
kind: ManifestVariable
2+
id: publisher_frontend.enabled
3+
title: Publisher Frontend Enabled?
4+
info: "Toggle for enabling/disabling the publisher frontend web app."
5+
input: {kind: OnOffInput}
6+
health_predicates:
7+
- "id::predicate.publisher_frontend_enabled_resource_in_sync"
8+
9+
---
10+
11+
kind: ManifestVariable
12+
id: publisher_frontend.replicas
13+
title: Publisher Frontend Replicas
14+
info: "Fixed replica count for the publisher frontend web application"
15+
input:
16+
kind: SliderIpnut
17+
18+
---
19+
20+
kind: ManifestVariable
21+
id: publisher_frontend.image
22+
title: Publisher frontend application image
23+
info: "Fully qualified image name for the web app. Should never be
24+
set manually."
25+
owner: publisher
26+
27+
---
28+
29+
kind: ManifestVariable
30+
id: publisher_frontend.hpa.enabled
31+
title: Publisher frontend HPA enabled?
32+
info: "Desired state of the Horizontal Pod Auto-scaling for the
33+
publisher frontend"
34+
input: {kind: OnOffInput}
35+
36+
---
37+
38+
kind: ManifestVariable
39+
id: publisher_frontend.hpa.min
40+
title: Minimum publisher frontend HPA replicas
41+
info: "Never let the replica count fall below this amount for
42+
the publisher frontend web app. "
43+
input:
44+
kind: SliderInput
45+
46+
---
47+
48+
kind: ManifestVariable
49+
id: publisher_frontend.service_type
50+
title: Publisher frontend networking service type
51+
info: "Kubernetes service type for deciding how microservice
52+
is exposed inside and outside the cluster."
53+
health_predicates:
54+
- id::predicate.publisher_frontend.redundant_exposure
55+
input:
56+
kind: SelectInput
57+
options: [ClusterIP, NodePort, LoadBalancer]
58+
owner: publisher
59+
60+
61+
---
62+
63+
kind: ManifestVariableDependency
64+
id: variable-dependency.when-hpa-is-enabled
65+
title: Value ignored when publisher_frontend.hpa.enabled is true
66+
from: [id::publisher_frontend.hpa.enabled]
67+
to: {id: [publisher_frontend.replicas]}
68+
active:
69+
kind: Predicate
70+
challenge: get::self>>from_variable>>current_value
71+
operator: truthy
72+
73+
---
74+
75+
kind: ManifestVariableDependency
76+
id: variable-dependency.when-hpa-is-disabled
77+
title: Value ignored when publisher_frontend.hpa.enabled is false
78+
from: [id::publisher_frontend.hpa.enabled]
79+
to: {id: [publisher_frontend.hpa.min, publisher_frontend.hpa.max]}
80+
active:
81+
kind: Predicate
82+
challenge: get::self>>from_variable>>current_value
83+
operator: falsy

0 commit comments

Comments
 (0)