Handle k8s in healthcheck.go

pull/2083/head
Louis Lam 1 year ago
parent 18ae6fa6c1
commit 4fb43034cd

@ -11,12 +11,17 @@ import (
"net/http" "net/http"
"os" "os"
"runtime" "runtime"
"strings"
"time" "time"
) )
func main() { func main() {
isFreeBSD := runtime.GOOS == "freebsd" isFreeBSD := runtime.GOOS == "freebsd"
// Is K8S + uptime-kuma as the container name
// See #2083
isK8s := strings.HasPrefix(os.Getenv("UPTIME_KUMA_PORT"), "tcp://")
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; // process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{ http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{
InsecureSkipVerify: true, InsecureSkipVerify: true,
@ -44,7 +49,11 @@ func main() {
hostname = "127.0.0.1" hostname = "127.0.0.1"
} }
port := os.Getenv("UPTIME_KUMA_PORT") port := ""
// UPTIME_KUMA_PORT is override by K8S unexpectedly,
if !isK8s {
port = os.Getenv("UPTIME_KUMA_PORT")
}
if len(port) == 0 { if len(port) == 0 {
port = os.Getenv("PORT") port = os.Getenv("PORT")
} }

Loading…
Cancel
Save