-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
4,778 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# See GitHub's documentation for more information on this file: | ||
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
|
||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
schedule: | ||
- cron: "17 23 * * 5" | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: ["go"] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v3 | ||
with: | ||
languages: ${{ matrix.language }} | ||
|
||
- name: Build | ||
run: | | ||
go build ./cmd/client | ||
go build ./cmd/server | ||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v3 | ||
with: | ||
category: "/language:${{matrix.language}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Publish Image | ||
|
||
on: | ||
push: | ||
tags: ["*"] | ||
workflow_dispatch: {} | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
publish-image: | ||
name: Publish Image | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
check-latest: true | ||
|
||
- name: Setup Ko | ||
uses: ko-build/[email protected] | ||
|
||
- name: Run Ko | ||
run: | | ||
go generate ./... | ||
ko build --bare --tags "latest,${GITHUB_REF#refs/*/}" ./cmd/server | ||
env: | ||
GITHUB_REF: ${{ github.ref }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: ["*"] | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
check-latest: true | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
version: latest | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Test | ||
|
||
on: | ||
push: {} | ||
workflow_dispatch: {} | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
|
||
- name: Generate code | ||
run: go generate ./... | ||
|
||
- name: Run Tests | ||
run: go test -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
**/*~ | ||
/dist | ||
/phc | ||
/phs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
before: | ||
hooks: | ||
- go generate ./... | ||
- go mod tidy | ||
builds: | ||
- &standardBuild | ||
id: client | ||
main: ./cmd/client | ||
binary: phc | ||
env: | ||
- CGO_ENABLED=0 | ||
mod_timestamp: "{{ .CommitTimestamp }}" | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- "-s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}}" | ||
goos: | ||
- freebsd | ||
- windows | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
- <<: *standardBuild | ||
id: server | ||
main: ./cmd/server | ||
binary: phs | ||
archives: | ||
- format: zip | ||
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" | ||
snapshot: | ||
name_template: "{{ .Tag }}-next" | ||
checksum: | ||
name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS" | ||
algorithm: sha256 | ||
release: | ||
draft: false | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" | ||
brews: | ||
- repository: | ||
owner: isometry | ||
name: homebrew-tap | ||
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}" | ||
folder: Formula | ||
description: Platform health monitoring system | ||
homepage: https://just.breathe.io/project/platform-health/ | ||
install: | | ||
bin.install "phc" | ||
bin.install "phs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defaultPlatforms: | ||
- linux/arm64 | ||
- linux/amd64 | ||
|
||
builds: | ||
- id: platform-health-server | ||
main: ./cmd/server | ||
env: | ||
- CGO_ENABLED=0 | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- -s -w |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
MODULE ?= github.com/isometry/platform-health | ||
export KO_DOCKER_REPO ?= ghcr.io/isometry/platform-health | ||
|
||
.PHONY: build | ||
build: protoc | ||
goreleaser build --clean --single-target --snapshot --skip=post-hooks | ||
|
||
.PHONY: ko-build | ||
ko-build: protoc generate | ||
ko build --bare ./cmd/server | ||
|
||
.PHONY: generate | ||
generate: | ||
go generate ./... | ||
|
||
protoc: pkg/platform/platform.pb.go pkg/platform/platform_grpc.pb.go pkg/details/tls.pb.go | ||
|
||
pkg/platform/platform.pb.go: proto/platform.proto | ||
protoc --go_out=. --go_opt=module=$(MODULE) $< | ||
pkg/platform/platform_grpc.pb.go: proto/platform.proto | ||
protoc --go-grpc_out=. --go-grpc_opt=module=$(MODULE) $< | ||
pkg/details/tls.pb.go: proto/detail_tls.proto | ||
protoc --go_out=. --go_opt=module=$(MODULE) $< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,103 @@ | ||
# platform-health | ||
# Platform Health | ||
|
||
Lightweight & extensible platform health monitoring. | ||
|
||
## Overview | ||
|
||
Platform Health is a simple client/server system for lightweight health monitoring of platform components and systems. | ||
|
||
The Platform Health client (`phc`) sends a gRPC health check request to a Platform Health server which is configured to probe a set of network services. Probes run asynchronously on the server (subject to configurable timeouts), with the accumulated response returned to the client. | ||
|
||
## Providers | ||
|
||
Probes use a compile-time [provider plugin system](pkg/provider) that supports extension to monitoring of arbitrary services. Integrated providers include: | ||
|
||
* [`satellite`](pkg/provider/satellite): A separate satellite instance of the Platform Health server | ||
* [`tcp`](pkg/provider/tcp): TCP connectivity checks | ||
* [`tls`](pkg/provider/tls): TLS handshake and certificate verification | ||
* [`http`](pkg/provider/http): HTTP(S) queries with status code and certificate verification | ||
* [`grpc`](pkg/provider/grpc): gRPC Health v1 service status checks | ||
* [`kubernetes`](pkg/provider/kubernetes): Kubernetes resource existence and readiness | ||
* [`helm`](pkg/provider/helm): Helm release existence and deployment status | ||
|
||
Each provider implements the `Instance` interface, with the health of each instance obtained asynchronously, and contributing to the overall response. | ||
|
||
## Installation | ||
|
||
### macOS/Linux | ||
|
||
```bash | ||
brew install isometry/tap/platform-health | ||
``` | ||
|
||
```console | ||
$ phs & sleep 1 && phc && kill %1 | ||
{"status":"HEALTHY", "duration":"0.000004833s"} | ||
``` | ||
|
||
### Kubernetes | ||
|
||
TODO: Helm chart :-) | ||
|
||
```bash | ||
kubectl create configmap platform-health --from-file=platform-health.yaml=/dev/stdin <<-EOF | ||
tcp: | ||
- name: ssh@localhost | ||
host: localhost | ||
port: 22 | ||
tls: | ||
- name: gmail | ||
host: smtp.gmail.com | ||
port: 465 | ||
http: | ||
- name: google | ||
url: https://google.com | ||
EOF | ||
|
||
kubectl create deployment platform-health --image ghcr.io/isometry/platform-health:latest --port=8080 | ||
|
||
kubectl patch deployment platform-health --patch-file=/dev/stdin <<-EOF | ||
spec: | ||
template: | ||
spec: | ||
volumes: | ||
- name: config | ||
configMap: | ||
name: platform-health | ||
containers: | ||
- name: platform-health | ||
args: | ||
- -vv | ||
volumeMounts: | ||
- name: config | ||
mountPath: /config | ||
EOF | ||
|
||
kubectl create service loadbalancer platform-health --tcp=8080:8080 | ||
``` | ||
|
||
## Configuration | ||
|
||
The Platform Health server reads a simple configuration file, defaulting to `platform-health.yaml` with the following structure: | ||
|
||
```yaml | ||
<provider>: [<instance>, …] | ||
``` | ||
### Example | ||
The following configuration will monitor that /something/ is listening on `tcp/22` of localhost; validate connectivity and TLS handshake to the Gmail SSL mail-submission port; and validate that Google is accessible and returning a 200 status code: | ||
|
||
```yaml | ||
tcp: | ||
- name: ssh@localhost | ||
host: localhost | ||
port: 22 | ||
tls: | ||
- name: gmail | ||
host: smtp.gmail.com | ||
port: 465 | ||
http: | ||
- name: google | ||
url: https://google.com | ||
``` |
Oops, something went wrong.