Skip to content
This repository was archived by the owner on Sep 4, 2020. It is now read-only.
Closed
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
/.vscode
/.idea/
*.iml

/healthscope/target
35 changes: 28 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@ authors = ["Matt Butcher <matt.butcher@microsoft.com>", "Jianbo Sun <jianbo.sjb@
edition = "2018"

[dependencies]
kube = { version = "0.15.0", features = ["openapi"] }
k8s-openapi = { version = "0.5.0", features = ["v1_15"] }
kube = { version = "0.16.1", features = ["openapi"] }
k8s-openapi = { version = "0.5.1", features = ["v1_15"] }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
failure = "0.1.5"
spectral = "0.6"
reqwest = "0.9"
reqwest = "0.9.17"
log = "0.4"
env_logger = "0.6.1"
hyper = "0.12"
clap = "~2.33"
regex = "1.0"
lazy_static = "1.4.0"

[workspace]
members = [
"healthscope",
]
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ build:
test:
cargo test
cargo clippy
cargo test --package healthscope
cargo clippy --package healthscope

.PHONY: docker-build
docker-build:
Expand All @@ -18,6 +20,9 @@ docker-build:
run:
RUST_LOG="scylla=debug" RUST_BACKTRACE=short cargo run

healthscoperun:
RUST_LOG="healthscope=debug" RUST_BACKTRACE=short cargo run --package healthscope

GIT_VERSION = $(shell git describe --always --abbrev=7 --dirty)
kind-e2e:
make build && \
Expand Down
19 changes: 19 additions & 0 deletions charts/scylla/crds/healthscope.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: healthscopes.core.hydra.io
labels:
app.kubernetes.io/part-of: core.hydra.io
spec:
group: core.hydra.io
versions:
- name: v1alpha1
served: true
storage: true
scope: Namespaced
names:
plural: healthscopes
singular: healthscope
kind: HealthScope
shortNames:
- health
2 changes: 1 addition & 1 deletion charts/scylla/crds/scopes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ spec:
names:
plural: scopes
singular: scope
kind: Scope
kind: ApplicationScope
67 changes: 67 additions & 0 deletions charts/scylla/templates/scopes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
apiVersion: core.hydra.io/v1alpha1
kind: ApplicationScope
metadata:
name: health
annotations:
version: v1.0.0
description: "aggregated health state for a group of components."
spec:
type: core.hydra.io/v1alpha1.HealthScope
allowComponentOverlap: true
parameters:
- name: probe-method
description: The method to probe the components, e.g. 'httpGet'.
type: string
required: true
- name: probe-endpoint
description: The endpoint to probe from the components, e.g. '/v1/health'.
type: string
required: true
- name: probe-timeout
description: The amount of time in seconds to wait when receiving a response before marked failure.
type: integer
required: false
- name: probe-interval
description: The amount of time in seconds between probing tries.
type: integer
required: false
- name: failure-rate-threshold
description: If the rate of failure of total probe results is above this threshold, declared 'failed'.
type: double
required: false
- name: healthy-rate-threshold
description: If the rate of healthy of total probe results is above this threshold, declared 'healthy'.
type: double
required: false
- name: healthThresholdPercentage
description: The % of healthy components required to upgrade scope
type: double
required: false
- name: requiredHealthyComponents
description: Comma-separated list of names of the components required to be healthy for the scope to be health.
type: string
required: false
---
apiVersion: core.hydra.io/v1alpha1
kind: ApplicationScope
metadata:
name: network
annotations:
version: v1.0.0
description: "network boundary that a group components reside in"
spec:
type: core.hydra.io/v1.NetworkScope
allowComponentOverlap: false
parameters:
- name: network-id
description: The id of the network, e.g. vpc-id, VNet name.
type: string
required: Y
- name: subnet-id
description: The id of the subnet within the network.
type: string
required: Y
- name: internet-gateway-type
description: The type of the gateway, options are 'public', 'nat'. Empty string means no gateway.
type: string
required: N
2 changes: 2 additions & 0 deletions examples/first-app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ spec:
value: /
- name: service_port
value: 9999
applicationScopes:
- my-health-scope
23 changes: 23 additions & 0 deletions examples/health-scope-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: core.hydra.io/v1alpha1
kind: ApplicationConfiguration
metadata:
name: my-health-scope
spec:
scopes:
- name: health
type: core.hydra.io/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
24 changes: 24 additions & 0 deletions healthscope/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "healthscope"
version = "0.1.0"
authors = ["天元 <jianbo.sjb@alibaba-inc.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
kube = { version = "0.16.1", features = ["openapi"] }
k8s-openapi = { version = "0.5.1", features = ["v1_15"] }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
failure = "0.1.5"
futures = "0.1.21"
spectral = "0.6"
reqwest = "0.9.17"
log = "0.4"
env_logger = "0.6.1"
hyper = "0.12"
clap = "~2.33"
chrono = "0.4"
scylla = { path = '../' }
12 changes: 12 additions & 0 deletions healthscope/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Health Scope Controller

Health Scope Controller used for periodically check health scope crd and check the health of all the components related.

## What will health scope controller do?

1. periodically check all component health and update the CR status.
2. serve as a http server, to output aggregated health information.

## How to install?

1.
3 changes: 3 additions & 0 deletions healthscope/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extern crate chrono;
extern crate futures;
extern crate scylla;
Loading