Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Addon]: add fluxcd kustomize healthcheck #681

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion addons/fluxcd/definitions/kustomize.cue
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
kustomize: {
attributes: workload: type: "autodetects.core.oam.dev"
attributes:{
workload: type: "autodetects.core.oam.dev"
status: {
healthPolicy: #"""
isHealth: len(context.output.status.conditions) != 0 && context.output.status.conditions[0]["reason"]=="ReconciliationSucceeded" && context.output.status.conditions[0]["type"]=="Ready" && context.output.status.conditions[0]["status"] == "True"
"""#
customStatus: #"""
repoMessage: *"" | string
kustMessage: *"Wating repository ready" | string
if context.outputs.repo == _|_ {
repoMessage: "Use existed repository"
}
if context.outputs.repo != _|_ && context.outputs.repo.status == _|_ {
repoMessage: "Fetching repository"
}
if context.outputs.repo != _|_ && context.outputs.repo.status != _|_ && context.outputs.repo.status.conditions != _|_ {
repoStatus: context.outputs.repo.status
if len(repoStatus.conditions) != 0 && repoStatus.conditions[0]["reason"] != "Succeeded" {
lastMessage: repoStatus.conditions[0].message
if len(repoStatus.conditions)>1{
repoMessage : repoStatus.conditions[1].message + ", " + lastMessage
}
}
if len(repoStatus.conditions) != 0 && repoStatus.conditions[0]["reason"] == "Succeeded" {
repoMessage: repoStatus.conditions[0].message
}
}
if context.output.status == _|_ {
kustMessage: "Creating git repo"
}
if context.output.status != _|_ {
kustStatus: context.output.status
if kustStatus.conditions != _|_ {
if len(kustStatus.conditions) > 0 {
if kustStatus.conditions[0]["type"] != _|_ && kustStatus.conditions[0]["reason"] != _|_ {
if kustStatus.conditions[0]["reason"] != "ReconciliationSucceeded" {
kustBasicMessage: "Delivery git kustomize in progress, message: " + kustStatus.conditions[0]["message"]
if len(kustStatus.conditions) == 1 {
kustMessage: kustBasicMessage
}
if len(kustStatus.conditions) > 1 {
if kustStatus.conditions[1]["message"] != _|_ {
kustMessage: kustBasicMessage + ", " + kustStatus.conditions[1]["message"]
}
}
}
if kustStatus.conditions[0]["reason"] == "ReconciliationSucceeded"{
kustMessage: "Create kustomize successfully"
}
}
}
}
}
message: repoMessage + ", " + kustMessage
"""#
}
}
description: "kustomize can fetching, building, updating and applying Kustomize manifests from Git repo or Bucket or OCI repo."
type: "component"
annotations: {
Expand Down
2 changes: 1 addition & 1 deletion addons/fluxcd/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: fluxcd
version: 2.3.4
version: 2.3.5
description: Extended workload to do continuous and progressive delivery
icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/flux/horizontal/color/flux-horizontal-color.png
url: https://fluxcd.io
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: demo-kust-fluxcd-new
namespace: default
spec:
components:
- name: demo-kust-fluxcd-new
properties:
force: false
path: ./
prune: true
pullInterval: 5m
repoType: git
suspend: false
targetNamespace: default
url: https://github.com/workman-Lu/kubernetes-demo.git
type: kustomize