Version: v1.0

Define Application Health Probe

In this documentation, we will show how to define health probe for application

1.Create health scope instance.

  1. apiVersion: core.oam.dev/v1alpha2
  2. kind: HealthScope
  3. metadata:
  4. name: health-check
  5. namespace: default
  6. spec:
  7. probe-interval: 60
  8. workloadRefs:
  9. - apiVersion: apps/v1
  10. kind: Deployment
  11. name: express-server
  1. Create an application with the health scope
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: vela-app
  5. spec:
  6. components:
  7. - name: express-server
  8. type: webservice
  9. properties:
  10. image: crccheck/hello-world
  11. port: 8080 # change port
  12. cpu: 0.5 # add requests cpu units
  13. scopes:
  14. healthscopes.core.oam.dev: health-check
  1. Check app status, will see health scope in status.service.scopes
  1. $ kubectl get app vela-app -o yaml
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: vela-app
  5. ...
  6. status:
  7. ...
  8. services:
  9. - healthy: true
  10. name: express-server
  11. scopes:
  12. - apiVersion: core.oam.dev/v1alpha2
  13. kind: HealthScope
  14. name: health-check

4.Check health scope status

  1. $ kubectl get healthscope health-check -o yaml
  1. apiVersion: core.oam.dev/v1alpha2
  2. kind: HealthScope
  3. metadata:
  4. name: health-check
  5. ...
  6. spec:
  7. probe-interval: 60
  8. workloadRefs:
  9. - apiVersion: apps/v1
  10. kind: Deployment
  11. name: express-server
  12. status:
  13. healthConditions:
  14. - componentName: express-server
  15. diagnosis: 'Ready:1/1 '
  16. healthStatus: HEALTHY
  17. targetWorkload:
  18. apiVersion: apps/v1
  19. kind: Deployment
  20. name: express-server
  21. scopeHealthCondition:
  22. healthStatus: HEALTHY
  23. healthyWorkloads: 1
  24. total: 1