Status Write Back

    This documentation will explain how to achieve status write back by using CUE templates in definition objects.

    The spec of health check is , they are the same for both Workload Type and Trait.

    If not defined, the health result will always be true.

    The keyword in CUE is isHealth, the result of CUE expression must be bool type. KubeVela runtime will evaluate the CUE expression periodically until it becomes healthy. Every time the controller will get all the Kubernetes resources and fill them into the context field.

    Trait will not have the context.output, other fields are the same.

    The example of health check likes below:

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: ComponentDefinition
    3. spec:
    4. status:
    5. healthPolicy: |
    6. isHealth: (context.output.status.readyReplicas > 0) && (context.output.status.readyReplicas == context.output.status.replicas)
    7. ...

    The health check result will be recorded into the Application resource.

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. spec:
    4. components:
    5. - name: myweb
    6. type: worker
    7. cmd:
    8. - sleep
    9. - "1000"
    10. enemies: alien
    11. image: busybox
    12. lives: "3"
    13. traits:
    14. - type: ingress
    15. properties:
    16. domain: www.example.com
    17. http:
    18. /: 80
    19. status:
    20. ...
    21. - healthy: true
    22. message: "type: busybox,\t enemies:alien"
    23. name: myweb
    24. traits:
    25. - healthy: true
    26. message: 'Visiting URL: www.example.com, IP: 47.111.233.220'
    27. type: ingress
    28. status: running

    Custom Status

    The keyword in CUE is message, the result of CUE expression must be string type.

    The custom status has the same mechanism with health check. Application CRD controller will evaluate the CUE expression after the health check succeed.

    The context will contain following information:

    Trait will not have the context.output, other fields are the same.

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: ComponentDefinition
    3. spec:
    4. status:
    5. customStatus: |-
    6. message: "type: " + context.output.spec.template.spec.containers[0].image + ",\t enemies:" + context.outputs.gameconfig.data.enemies