mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
feat(health): support BackendTLSPolicy.gateway.networking.k8s.io (#27385)
Signed-off-by: Norwin Schnyder <[email protected]>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
local hs = {}
|
||||
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Waiting for BackendTLSPolicy status"
|
||||
|
||||
if obj.status ~= nil and obj.status.ancestors ~= nil then
|
||||
if obj.metadata.generation ~= nil then
|
||||
for i, ancestor in ipairs(obj.status.ancestors) do
|
||||
for _, condition in ipairs(ancestor.conditions) do
|
||||
if condition.observedGeneration ~= nil then
|
||||
if condition.observedGeneration ~= obj.metadata.generation then
|
||||
hs.message = "Waiting for Ancestor " .. (ancestor.ancestorRef.name or "") .. " to update BackendTLSPolicy status"
|
||||
return hs
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for i, ancestor in ipairs(obj.status.ancestors) do
|
||||
for j, condition in ipairs(ancestor.conditions) do
|
||||
if condition.type == "Accepted" then
|
||||
if condition.status ~= "True" then
|
||||
hs.status = "Degraded"
|
||||
hs.message = "Ancestor " .. (ancestor.ancestorRef.name or "") .. ": " .. condition.message
|
||||
return hs
|
||||
else
|
||||
hs.status = "Healthy"
|
||||
hs.message = "BackendTLSPolicy is healthy"
|
||||
end
|
||||
end
|
||||
|
||||
if condition.type == "ResolvedRefs" then
|
||||
if condition.status ~= "True" then
|
||||
hs.status = "Degraded"
|
||||
hs.message = "Ancestor " .. (ancestor.ancestorRef.name or "") .. ": " .. condition.message
|
||||
return hs
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return hs
|
||||
@@ -0,0 +1,21 @@
|
||||
tests:
|
||||
- healthStatus:
|
||||
status: Healthy
|
||||
message: "BackendTLSPolicy is healthy"
|
||||
inputPath: testdata/healthy.yaml
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: "Ancestor example-gateway: Referenced CA certificate ConfigMap 'default/example-ca' does not exist"
|
||||
inputPath: testdata/degraded_resolved_refs.yaml
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: "Ancestor example-gateway: BackendTLSPolicy has invalid wellKnownCACertificates value, must be 'System'"
|
||||
inputPath: testdata/degraded_accepted.yaml
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: "Waiting for BackendTLSPolicy status"
|
||||
inputPath: testdata/progressing.yaml
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: "Waiting for Ancestor example-gateway to update BackendTLSPolicy status"
|
||||
inputPath: testdata/progressing_observed_generation.yaml
|
||||
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: BackendTLSPolicy
|
||||
metadata:
|
||||
name: example-backendtlspolicy
|
||||
namespace: default
|
||||
spec:
|
||||
targetRefs:
|
||||
- group: ''
|
||||
kind: Service
|
||||
name: example-service
|
||||
namespace: default
|
||||
validation:
|
||||
caCertificateRefs:
|
||||
- group: ''
|
||||
kind: ConfigMap
|
||||
name: example-ca
|
||||
hostname: www.example.com
|
||||
status:
|
||||
ancestors:
|
||||
- ancestorRef:
|
||||
group: gateway.networking.k8s.io
|
||||
kind: Gateway
|
||||
name: example-gateway
|
||||
conditions:
|
||||
- lastTransitionTime: '2026-04-16T12:30:30Z'
|
||||
message: All references are resolved
|
||||
observedGeneration: 3
|
||||
reason: ResolvedRefs
|
||||
status: 'True'
|
||||
type: ResolvedRefs
|
||||
- lastTransitionTime: '2026-04-16T14:40:30Z'
|
||||
message: >-
|
||||
BackendTLSPolicy has invalid wellKnownCACertificates value, must be
|
||||
'System'
|
||||
observedGeneration: 3
|
||||
reason: NoValidCACertificate
|
||||
status: 'False'
|
||||
type: Accepted
|
||||
controllerName: example.com/gatewayclass-controller
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: BackendTLSPolicy
|
||||
metadata:
|
||||
name: example-backendtlspolicy
|
||||
namespace: default
|
||||
spec:
|
||||
targetRefs:
|
||||
- group: ''
|
||||
kind: Service
|
||||
name: example-service
|
||||
namespace: default
|
||||
validation:
|
||||
caCertificateRefs:
|
||||
- group: ''
|
||||
kind: ConfigMap
|
||||
name: example-ca
|
||||
hostname: www.example.com
|
||||
status:
|
||||
ancestors:
|
||||
- ancestorRef:
|
||||
group: gateway.networking.k8s.io
|
||||
kind: Gateway
|
||||
name: other-gateway
|
||||
conditions:
|
||||
- lastTransitionTime: '2026-04-16T12:30:30Z'
|
||||
message: All references are resolved
|
||||
observedGeneration: 3
|
||||
reason: ResolvedRefs
|
||||
status: 'True'
|
||||
type: ResolvedRefs
|
||||
- lastTransitionTime: '2026-04-16T12:20:11Z'
|
||||
message: BackendTLSPolicy is accepted
|
||||
observedGeneration: 3
|
||||
reason: Accepted
|
||||
status: 'True'
|
||||
type: Accepted
|
||||
controllerName: other.com/gatewayclass-controller
|
||||
- ancestorRef:
|
||||
group: gateway.networking.k8s.io
|
||||
kind: Gateway
|
||||
name: example-gateway
|
||||
conditions:
|
||||
- lastTransitionTime: '2026-04-16T14:21:38Z'
|
||||
message: >-
|
||||
Referenced CA certificate ConfigMap 'default/example-ca' does not
|
||||
exist
|
||||
observedGeneration: 3
|
||||
reason: InvalidCACertificateRef
|
||||
status: 'False'
|
||||
type: ResolvedRefs
|
||||
- lastTransitionTime: '2026-04-16T12:20:11Z'
|
||||
message: BackendTLSPolicy is accepted
|
||||
observedGeneration: 3
|
||||
reason: Accepted
|
||||
status: 'True'
|
||||
type: Accepted
|
||||
controllerName: example.com/gatewayclass-controlle
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: BackendTLSPolicy
|
||||
metadata:
|
||||
name: example-backendtlspolicy
|
||||
namespace: default
|
||||
generation: 3
|
||||
spec:
|
||||
targetRefs:
|
||||
- group: ''
|
||||
kind: Service
|
||||
name: example-service
|
||||
namespace: default
|
||||
validation:
|
||||
caCertificateRefs:
|
||||
- group: ''
|
||||
kind: ConfigMap
|
||||
name: example-ca
|
||||
hostname: www.example.com
|
||||
status:
|
||||
ancestors:
|
||||
- ancestorRef:
|
||||
group: gateway.networking.k8s.io
|
||||
kind: Gateway
|
||||
name: example-gateway
|
||||
conditions:
|
||||
- lastTransitionTime: '2026-04-16T12:30:30Z'
|
||||
message: All references are resolved
|
||||
observedGeneration: 3
|
||||
reason: ResolvedRefs
|
||||
status: 'True'
|
||||
type: ResolvedRefs
|
||||
- lastTransitionTime: '2026-04-16T12:20:11Z'
|
||||
message: BackendTLSPolicy is accepted
|
||||
observedGeneration: 3
|
||||
reason: Accepted
|
||||
status: 'True'
|
||||
type: Accepted
|
||||
controllerName: example.com/gatewayclass-controller
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: BackendTLSPolicy
|
||||
metadata:
|
||||
name: example-backendtlspolicy
|
||||
namespace: default
|
||||
spec:
|
||||
targetRefs:
|
||||
- group: ''
|
||||
kind: Service
|
||||
name: example-service
|
||||
namespace: default
|
||||
validation:
|
||||
caCertificateRefs:
|
||||
- group: ''
|
||||
kind: ConfigMap
|
||||
name: example-ca
|
||||
hostname: www.example.com
|
||||
status:
|
||||
ancestors:
|
||||
- ancestorRef:
|
||||
group: gateway.networking.k8s.io
|
||||
kind: Gateway
|
||||
name: example-gateway
|
||||
conditions: []
|
||||
controllerName: example.com/gatewayclass-controller
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: BackendTLSPolicy
|
||||
metadata:
|
||||
name: example-backendtlspolicy
|
||||
namespace: default
|
||||
generation: 3
|
||||
spec:
|
||||
targetRefs:
|
||||
- group: ''
|
||||
kind: Service
|
||||
name: example-service
|
||||
namespace: default
|
||||
validation:
|
||||
caCertificateRefs:
|
||||
- group: ''
|
||||
kind: ConfigMap
|
||||
name: example-ca
|
||||
hostname: www.example.com
|
||||
status:
|
||||
ancestors:
|
||||
- ancestorRef:
|
||||
group: gateway.networking.k8s.io
|
||||
kind: Gateway
|
||||
name: other-gateway
|
||||
conditions:
|
||||
- lastTransitionTime: '2026-04-16T12:30:30Z'
|
||||
message: All references are resolved
|
||||
observedGeneration: 3
|
||||
reason: ResolvedRefs
|
||||
status: 'True'
|
||||
type: ResolvedRefs
|
||||
- lastTransitionTime: '2026-04-16T12:20:11Z'
|
||||
message: BackendTLSPolicy is accepted
|
||||
observedGeneration: 3
|
||||
reason: Accepted
|
||||
status: 'True'
|
||||
type: Accepted
|
||||
controllerName: other.com/gatewayclass-controller
|
||||
- ancestorRef:
|
||||
group: gateway.networking.k8s.io
|
||||
kind: Gateway
|
||||
name: example-gateway
|
||||
conditions:
|
||||
- lastTransitionTime: '2026-04-16T12:30:30Z'
|
||||
message: All references are resolved
|
||||
observedGeneration: 1
|
||||
reason: ResolvedRefs
|
||||
status: 'True'
|
||||
type: ResolvedRefs
|
||||
- lastTransitionTime: '2026-04-16T12:20:11Z'
|
||||
message: BackendTLSPolicy is accepted
|
||||
observedGeneration: 1
|
||||
reason: Accepted
|
||||
status: 'True'
|
||||
type: Accepted
|
||||
controllerName: example.com/gatewayclass-controller
|
||||
Reference in New Issue
Block a user