Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议修改一些内容,比如可以指定apiserver的url #98

Open
homelanmder opened this issue May 2, 2024 · 0 comments
Open

建议修改一些内容,比如可以指定apiserver的url #98

homelanmder opened this issue May 2, 2024 · 0 comments

Comments

@homelanmder
Copy link
Contributor

homelanmder commented May 2, 2024

在最近的项目中,发现一个kubenets未授权访问的端口,但是目标url不在pods环境变量中,所以导致后续很多功能无法使用。

func ApiServerAddr() (string, error) {
	protocol := ""
	host, port := os.Getenv("KUBERNETES_SERVICE_HOST"), os.Getenv("KUBERNETES_SERVICE_PORT")
	if len(host) == 0 || len(port) == 0 {
		text := "err: cannot find kubernetes api host in ENV"
		return "", errors.New(text)
	}
	if port == "8080" || port == "8001" {
		protocol = "http://"
	} else {
		protocol = "https://"
	}

	return protocol + net.JoinHostPort(host, port), nil
}

建议将这里改的更灵活一点

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant