Skip to content

Commit

Permalink
Merge pull request #4 from rzrbld/feature/next-release
Browse files Browse the repository at this point in the history
- add k8s probes
  • Loading branch information
rzrbld authored Mar 22, 2020
2 parents 32c3a5f + e7d62d3 commit 937a536
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
.DS_Store
main
run.sh
runc.sh
rung.sh
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,23 @@ it will bring up:
after that you can go to `` http://localhost `` and try out

### Run with docker
`` docker run rzrbld/adminio-api:0.2 ``
```
docker run -d \
-p 8080:8080 \
-e ADMINIO_HOST_PORT=":8080" \
-e MINIO_HOST_PORT="localhost:9000" \
-e MINIO_ACCESS="test" \
-e MINIO_SECRET="testtest123" \
rzrbld/adminio-api:latest
```

### Run manually
- [start](https://docs.min.io/) minio server
- set env variables
- run ./main form `dist` folder
- compile and run ./main form `src` folder

### Env variables
### Config Env variables
| Variable | Description | Default |
|--------------|:-----------------------:|-----------:|
| `ADMINIO_HOST_PORT` | which host and port API should listening. This is Iris based API, so you will need to provide 0.0.0.0:8080 for listening on all interfaces | localhost:8080 |
Expand All @@ -48,6 +57,7 @@ after that you can go to `` http://localhost `` and try out
| `ADMINIO_COOKIE_NAME` | name for the session cookie | adminiosessionid |
| `ADMINIO_AUDIT_LOG_ENABLE` | enable audit log, mae sense if oauth is enabled, othervise set to false | false |
| `ADMINIO_METRICS_ENABLE` | enable default iris\golang metrics and bucket sizes metric on /metric/ uri path | false |
| `ADMINIO_PROBES_ENABLE` | enable liveness and readiness probes for k8s installations | false |

### Supported oauth providers

Expand All @@ -66,5 +76,5 @@ after that you can go to `` http://localhost `` and try out
- wso2

### example config
prometheus config: `examples/prometheus.yml`
bucket policy: `examples/policy.xml`
- prometheus config for adminio metrics: `examples/prometheus.yml`
- bucket policy: `examples/policy.xml`
1 change: 1 addition & 0 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var (
OauthEnable, _ = strconv.ParseBool(getEnv("ADMINIO_OAUTH_ENABLE", "false"))
AuditLogEnable, _ = strconv.ParseBool(getEnv("ADMINIO_AUDIT_LOG_ENABLE", "false"))
MetricsEnable, _ = strconv.ParseBool(getEnv("ADMINIO_METRICS_ENABLE", "false"))
ProbesEnable, _ = strconv.ParseBool(getEnv("ADMINIO_PROBES_ENABLE", "false"))
OauthProvider = getEnv("ADMINIO_OAUTH_PROVIDER", "github")
OauthClientId = getEnv("ADMINIO_OAUTH_CLIENT_ID", "my-github-oauth-app-client-id")
OauthClientSecret = getEnv("ADMINIO_OAUTH_CLIENT_SECRET", "my-github-oauth-app-secret")
Expand Down
16 changes: 16 additions & 0 deletions src/handlers/probes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package handlers

import (
iris "github.com/kataras/iris/v12"
resph "github.com/rzrbld/adminio-api/response"
)

var Readiness = func(ctx iris.Context) {
var res = resph.DefaultResConstructor(ctx, nil)
ctx.JSON(res)
}

var Liveness = func(ctx iris.Context) {
var res = resph.DefaultResConstructor(ctx, nil)
ctx.JSON(res)
}
5 changes: 5 additions & 0 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func main() {
app.Get("/metrics", iris.FromStd(promhttp.Handler()))
}

if cnf.ProbesEnable {
app.Get("/read", hdl.Readiness)
app.Get("/live", hdl.Liveness)
}

v1auth := app.Party("/auth/", crs).AllowMethods(iris.MethodOptions)
{
v1auth.Get("/logout/", hdl.AuthLogout)
Expand Down

0 comments on commit 937a536

Please sign in to comment.