6 Star 6 Fork 1

Gitee 极速下载/rudr

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.devcontainer
.github
charts
docs
examples
healthscope
src
Cargo.toml
README.md
src
.dockerignore
.gitignore
CODEOWNERS
CONTRIBUTING.md
Cargo.lock
Cargo.toml
Dockerfile
Dockerfile.e2e
LICENSE.txt
Makefile
README-old.md
README.md
governance.md
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/oam-dev/rudr/
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Health Scope Controller

HealthScope controller is used to periodically check the health of all the components and update health scope custom resources.

What will health scope controller do?

  1. periodically check health status of components and update the HealthScope resource status.
  2. serve as a http server, to output aggregated health information.

How to install?

Use helm to install:

helm install healthscope ./charts/healthscope

How to use?

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.

Create health scope instance using application configuration

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.

Add Component to health scope

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.

Visit health scope instance to check health

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。

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Rust
1
https://gitee.com/mirrors/rudr.git
git@gitee.com:mirrors/rudr.git
mirrors
rudr
rudr
master

搜索帮助