HealthScope controller is used to periodically check the health of all the components and update health scope custom resources.
Use helm to install:
helm install healthscope ./charts/healthscope
After HealthScope controller is installed by helm charts, setup an endpoint to it. By default the charts will use ClusterPort, we can use port-forward to access HealthScope controller.
export POD_NAME=$(kubectl get pods -l "app.kubernetes.io/name=healthscope,app.kubernetes.io/instance=health" -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward $POD_NAME 8080:80
Then we'll be able to visit http://127.0.0.1:8080 to query status of health scope resource.
If you want to use health scope, you should create a health scope instance first, using Application Configuration.
A health scope instance is like below:
apiVersion: core.oam.dev/v1alpha1
kind: ApplicationConfiguration
metadata:
name: my-health-scope
spec:
scopes:
- name: health
type: core.oam.dev/v1alpha1.HealthScope
properties:
- name: probe-method
value: "kube-get"
- name: probe-endpoint
value: ".status"
- name: probe-timeout
value: 30
- name: probe-interval
value: 60
- name: failure-rate-threshold
value: 0
- name: healthy-rate-threshold
value: 100.0
- name: healthThresholdPercentage
value: 100.0
You can also find this example here: examples/health-scope-config.yaml.
Apply this yaml:
$ kubectl apply -f examples/health-scope-config.yaml
applicationconfiguration.core.oam.dev/my-health-scope created
Then you will find a health scope instance was created:
$ kubectl get health
NAME AGE
my-health-scope 31s
You could get more details from:
$ kubectl get health my-health-scope -o yaml
apiVersion: core.oam.dev/v1alpha1
kind: HealthScope
metadata:
creationTimestamp: "2019-10-20T09:42:30Z"
generation: 3
name: my-health-scope
namespace: default
ownerReferences:
- apiVersion: core.oam.dev/v1alpha1
blockOwnerDeletion: true
controller: true
kind: ApplicationConfiguration
name: my-health-scope
uid: 1c113398-16f2-4aa1-9dc0-cd05a686d17d
resourceVersion: "2465881"
selfLink: /apis/core.oam.dev/v1alpha1/namespaces/default/healthscopes/my-health-scope
uid: ba3fd01c-9ba6-4e1a-93c0-b96d102700af
spec:
failureRateThreshold: 0
healthyRateThreshold: 100
probeEndpoint: .status
probeInterval: 60
probeMethod: kube-get
probeTimeout: 30
status:
lastAggregateTimestamp: "2019-10-20T09:43:31.541142387+00:00"
Then we could use this health scope in other Application Configuration.
We add application scopes to our first-app-config.yaml
.
apiVersion: core.oam.dev/v1alpha1
kind: ApplicationConfiguration
metadata:
name: first-app
spec:
components:
- componentName: helloworld-python-v1
instanceName: first-app-helloworld-python-v1
parameterValues:
- name: target
value: Rudr
- name: port
value: "9999"
traits:
- name: ingress
properties:
hostname: example.com
path: /
servicePort: 9999
+ applicationScopes:
+ - my-health-scope
Apply the config file:
$ kubectl apply -f examples/first-app-config.yaml
applicationconfiguration.core.oam.dev/first-app created
You could check the scope like below:
$ kubectl get health -o yaml my-health-scope
apiVersion: core.oam.dev/v1alpha1
kind: HealthScope
metadata:
creationTimestamp: "2019-10-20T09:42:30Z"
generation: 10
name: my-health-scope
namespace: default
ownerReferences:
- apiVersion: core.oam.dev/v1alpha1
blockOwnerDeletion: true
controller: true
kind: ApplicationConfiguration
name: my-health-scope
uid: 1c113398-16f2-4aa1-9dc0-cd05a686d17d
resourceVersion: "2466413"
selfLink: /apis/core.oam.dev/v1alpha1/namespaces/default/healthscopes/my-health-scope
uid: ba3fd01c-9ba6-4e1a-93c0-b96d102700af
spec:
failureRateThreshold: 0
healthyRateThreshold: 100
probeEndpoint: .status
probeInterval: 60
probeMethod: kube-get
probeTimeout: 30
status:
components:
- instanceName: first-app-helloworld-python-v1
componentName: helloworld-python-v1
status: healthy
lastAggregateTimestamp: "2019-10-20T09:49:22.820141484+00:00"
The status indicates that we have successfully added our component to this scope.
Do you still remember our port mapping in the first step? Visit that url with our health scope instance:
$ curl 127.0.0.1:8080/my-health-scope
healthy
Then you will find it's healthy now。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。