add customizations for source.toolkit.fluxcd.io/v1beta2/Bucket
Signed-off-by: yike21 <yike21@qq.com>
This commit is contained in:
parent
b841c5493d
commit
729aa562ae
|
@ -0,0 +1,105 @@
|
||||||
|
apiVersion: config.karmada.io/v1alpha1
|
||||||
|
kind: ResourceInterpreterCustomization
|
||||||
|
metadata:
|
||||||
|
name: declarative-configuration-bucket
|
||||||
|
spec:
|
||||||
|
target:
|
||||||
|
apiVersion: source.toolkit.fluxcd.io/v1beta2
|
||||||
|
kind: Bucket
|
||||||
|
customizations:
|
||||||
|
healthInterpretation:
|
||||||
|
luaScript: >
|
||||||
|
function InterpretHealth(observedObj)
|
||||||
|
if observedObj.status ~= nil and observedObj.status.conditions ~= nil then
|
||||||
|
for conditionIndex = 1, #observedObj.status.conditions do
|
||||||
|
if observedObj.status.conditions[conditionIndex].type == 'Ready' and observedObj.status.conditions[conditionIndex].status == 'True' and observedObj.status.conditions[conditionIndex].reason == 'Succeeded' then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
statusAggregation:
|
||||||
|
luaScript: >
|
||||||
|
function AggregateStatus(desiredObj, statusItems)
|
||||||
|
if statusItems == nil then
|
||||||
|
return desiredObj
|
||||||
|
end
|
||||||
|
desiredObj.status = {}
|
||||||
|
desiredObj.status.conditions = {}
|
||||||
|
conditions = {}
|
||||||
|
local conditionsIndex = 1
|
||||||
|
for i = 1, #statusItems do
|
||||||
|
if statusItems[i].status ~= nil and statusItems[i].status.artifact ~= nil then
|
||||||
|
desiredObj.status.artifact = statusItems[i].status.artifact
|
||||||
|
end
|
||||||
|
if statusItems[i].status ~= nil and statusItems[i].status.lastHandledReconcileAt ~= nil and statusItems[i].status.lastHandledReconcileAt ~= '' then
|
||||||
|
desiredObj.status.lastHandledReconcileAt = statusItems[i].status.lastHandledReconcileAt
|
||||||
|
end
|
||||||
|
if statusItems[i].status ~= nil and statusItems[i].status.url ~= nil and statusItems[i].status.url ~= '' then
|
||||||
|
desiredObj.status.url = statusItems[i].status.url
|
||||||
|
end
|
||||||
|
if statusItems[i].status ~= nil and statusItems[i].status.conditions ~= nil then
|
||||||
|
for conditionIndex = 1, #statusItems[i].status.conditions do
|
||||||
|
statusItems[i].status.conditions[conditionIndex].message = statusItems[i].clusterName..'='..statusItems[i].status.conditions[conditionIndex].message
|
||||||
|
hasCondition = false
|
||||||
|
for index = 1, #conditions do
|
||||||
|
if conditions[index].type == statusItems[i].status.conditions[conditionIndex].type and conditions[index].status == statusItems[i].status.conditions[conditionIndex].status and conditions[index].reason == statusItems[i].status.conditions[conditionIndex].reason then
|
||||||
|
conditions[index].message = conditions[index].message..', '..statusItems[i].status.conditions[conditionIndex].message
|
||||||
|
hasCondition = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not hasCondition then
|
||||||
|
conditions[conditionsIndex] = statusItems[i].status.conditions[conditionIndex]
|
||||||
|
conditionsIndex = conditionsIndex + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
desiredObj.status.observedGeneration = desiredObj.metadata.generation
|
||||||
|
desiredObj.status.conditions = conditions
|
||||||
|
return desiredObj
|
||||||
|
end
|
||||||
|
retention:
|
||||||
|
luaScript: >
|
||||||
|
function Retain(desiredObj, observedObj)
|
||||||
|
if observedObj.spec.suspend ~= nil then
|
||||||
|
desiredObj.spec.suspend = observedObj.spec.suspend
|
||||||
|
end
|
||||||
|
return desiredObj
|
||||||
|
end
|
||||||
|
statusReflection:
|
||||||
|
luaScript: >
|
||||||
|
function ReflectStatus (observedObj)
|
||||||
|
status = {}
|
||||||
|
if observedObj == nil or observedObj.status == nil then
|
||||||
|
return status
|
||||||
|
end
|
||||||
|
status.conditions = observedObj.status.conditions
|
||||||
|
status.artifact = observedObj.status.artifact
|
||||||
|
status.observedIgnore = observedObj.status.observedIgnore
|
||||||
|
status.url = observedObj.status.url
|
||||||
|
status.lastHandledReconcileAt = observedObj.status.lastHandledReconcileAt
|
||||||
|
return status
|
||||||
|
end
|
||||||
|
dependencyInterpretation:
|
||||||
|
luaScript: >
|
||||||
|
function GetDependencies(desiredObj)
|
||||||
|
dependentSecrets = {}
|
||||||
|
refs = {}
|
||||||
|
local idx = 1
|
||||||
|
if desiredObj.spec.secretRef ~= nil and desiredObj.spec.secretRef.name ~= '' then
|
||||||
|
dependentSecrets[desiredObj.spec.secretRef.name] = true
|
||||||
|
end
|
||||||
|
for key, value in pairs(dependentSecrets) do
|
||||||
|
dependObj = {}
|
||||||
|
dependObj.apiVersion = 'v1'
|
||||||
|
dependObj.kind = 'Secret'
|
||||||
|
dependObj.name = key
|
||||||
|
dependObj.namespace = desiredObj.metadata.namespace
|
||||||
|
refs[idx] = dependObj
|
||||||
|
idx = idx + 1
|
||||||
|
end
|
||||||
|
return refs
|
||||||
|
end
|
|
@ -0,0 +1,14 @@
|
||||||
|
apiVersion: source.toolkit.fluxcd.io/v1beta2
|
||||||
|
kind: Bucket
|
||||||
|
metadata:
|
||||||
|
name: sample
|
||||||
|
namespace: test-bucket
|
||||||
|
spec:
|
||||||
|
provider: generic
|
||||||
|
interval: 5m0s
|
||||||
|
bucketName: podinfo
|
||||||
|
endpoint: minio.minio.svc.cluster.local:9000
|
||||||
|
timeout: 60s
|
||||||
|
insecure: true
|
||||||
|
secretRef:
|
||||||
|
name: fake-minio-credentials
|
|
@ -0,0 +1,38 @@
|
||||||
|
apiVersion: source.toolkit.fluxcd.io/v1beta2
|
||||||
|
kind: Bucket
|
||||||
|
metadata:
|
||||||
|
name: sample
|
||||||
|
namespace: test-bucket
|
||||||
|
spec:
|
||||||
|
provider: generic
|
||||||
|
interval: 5m0s
|
||||||
|
bucketName: podinfo
|
||||||
|
endpoint: minio.minio.svc.cluster.local:9000
|
||||||
|
timeout: 60s
|
||||||
|
insecure: true
|
||||||
|
secretRef:
|
||||||
|
name: fake-minio-credentials
|
||||||
|
suspend: true
|
||||||
|
status:
|
||||||
|
conditions:
|
||||||
|
- lastTransitionTime: "2023-04-29T14:03:19Z"
|
||||||
|
message: building artifact
|
||||||
|
observedGeneration: 1
|
||||||
|
reason: ProgressingWithRetry
|
||||||
|
status: "True"
|
||||||
|
type: Reconciling
|
||||||
|
- lastTransitionTime: "2023-04-29T14:03:19Z"
|
||||||
|
message: 'invalid ''fake-secret'' secret data: required fields ''accesskey''
|
||||||
|
and ''secretkey'''
|
||||||
|
observedGeneration: 1
|
||||||
|
reason: AuthenticationFailed
|
||||||
|
status: "False"
|
||||||
|
type: Ready
|
||||||
|
- lastTransitionTime: "2023-04-29T14:01:44Z"
|
||||||
|
message: 'invalid ''fake-secret'' secret data: required fields ''accesskey''
|
||||||
|
and ''secretkey'''
|
||||||
|
observedGeneration: 1
|
||||||
|
reason: AuthenticationFailed
|
||||||
|
status: "True"
|
||||||
|
type: FetchFailed
|
||||||
|
observedGeneration: -1
|
|
@ -0,0 +1,51 @@
|
||||||
|
applied: true
|
||||||
|
clusterName: member1
|
||||||
|
health: Unhealthy
|
||||||
|
status:
|
||||||
|
conditions:
|
||||||
|
- lastTransitionTime: "2023-04-29T14:02:31Z"
|
||||||
|
message: building artifact
|
||||||
|
observedGeneration: 1
|
||||||
|
reason: ProgressingWithRetry
|
||||||
|
status: "True"
|
||||||
|
type: Reconciling
|
||||||
|
- lastTransitionTime: "2023-04-29T14:02:31Z"
|
||||||
|
message: 'invalid ''fake-secret'' secret data: required fields ''accesskey''
|
||||||
|
and ''secretkey'''
|
||||||
|
observedGeneration: 1
|
||||||
|
reason: AuthenticationFailed
|
||||||
|
status: "False"
|
||||||
|
type: Ready
|
||||||
|
- lastTransitionTime: "2023-04-29T14:01:44Z"
|
||||||
|
message: 'invalid ''fake-secret'' secret data: required fields ''accesskey''
|
||||||
|
and ''secretkey'''
|
||||||
|
observedGeneration: 1
|
||||||
|
reason: AuthenticationFailed
|
||||||
|
status: "True"
|
||||||
|
type: FetchFailed
|
||||||
|
---
|
||||||
|
applied: true
|
||||||
|
clusterName: member3
|
||||||
|
health: Unhealthy
|
||||||
|
status:
|
||||||
|
conditions:
|
||||||
|
- lastTransitionTime: "2023-04-29T14:02:31Z"
|
||||||
|
message: building artifact
|
||||||
|
observedGeneration: 1
|
||||||
|
reason: ProgressingWithRetry
|
||||||
|
status: "True"
|
||||||
|
type: Reconciling
|
||||||
|
- lastTransitionTime: "2023-04-29T14:02:31Z"
|
||||||
|
message: 'invalid ''fake-secret'' secret data: required fields ''accesskey''
|
||||||
|
and ''secretkey'''
|
||||||
|
observedGeneration: 1
|
||||||
|
reason: AuthenticationFailed
|
||||||
|
status: "False"
|
||||||
|
type: Ready
|
||||||
|
- lastTransitionTime: "2023-04-29T14:01:44Z"
|
||||||
|
message: 'invalid ''fake-secret'' secret data: required fields ''accesskey''
|
||||||
|
and ''secretkey'''
|
||||||
|
observedGeneration: 1
|
||||||
|
reason: AuthenticationFailed
|
||||||
|
status: "True"
|
||||||
|
type: FetchFailed
|
Loading…
Reference in New Issue