mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
cmd/k8s-operator: set hostinfo.Package
This allows identifying the operator. Updates #5055 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
parent
7e65a11df5
commit
06a10125fc
@ -39,10 +39,12 @@
|
|||||||
"sigs.k8s.io/controller-runtime/pkg/source"
|
"sigs.k8s.io/controller-runtime/pkg/source"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
"tailscale.com/client/tailscale"
|
"tailscale.com/client/tailscale"
|
||||||
|
"tailscale.com/hostinfo"
|
||||||
"tailscale.com/ipn"
|
"tailscale.com/ipn"
|
||||||
"tailscale.com/ipn/store/kubestore"
|
"tailscale.com/ipn/store/kubestore"
|
||||||
"tailscale.com/tsnet"
|
"tailscale.com/tsnet"
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
|
"tailscale.com/types/opt"
|
||||||
"tailscale.com/util/dnsname"
|
"tailscale.com/util/dnsname"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,7 +63,7 @@ func main() {
|
|||||||
clientSecretPath = defaultEnv("CLIENT_SECRET_FILE", "")
|
clientSecretPath = defaultEnv("CLIENT_SECRET_FILE", "")
|
||||||
image = defaultEnv("PROXY_IMAGE", "tailscale/tailscale:latest")
|
image = defaultEnv("PROXY_IMAGE", "tailscale/tailscale:latest")
|
||||||
tags = defaultEnv("PROXY_TAGS", "tag:k8s")
|
tags = defaultEnv("PROXY_TAGS", "tag:k8s")
|
||||||
shouldRunAuthProxy = defaultEnv("AUTH_PROXY", "false")
|
shouldRunAuthProxy = defaultBool("AUTH_PROXY", false)
|
||||||
)
|
)
|
||||||
|
|
||||||
var opts []kzap.Opts
|
var opts []kzap.Opts
|
||||||
@ -95,6 +97,13 @@ func main() {
|
|||||||
}
|
}
|
||||||
tsClient := tailscale.NewClient("-", nil)
|
tsClient := tailscale.NewClient("-", nil)
|
||||||
tsClient.HTTPClient = credentials.Client(context.Background())
|
tsClient.HTTPClient = credentials.Client(context.Background())
|
||||||
|
|
||||||
|
if shouldRunAuthProxy {
|
||||||
|
hostinfo.SetPackage("k8s-operator-proxy")
|
||||||
|
} else {
|
||||||
|
hostinfo.SetPackage("k8s-operator")
|
||||||
|
}
|
||||||
|
|
||||||
s := &tsnet.Server{
|
s := &tsnet.Server{
|
||||||
Hostname: hostname,
|
Hostname: hostname,
|
||||||
Logf: zlog.Named("tailscaled").Debugf,
|
Logf: zlog.Named("tailscaled").Debugf,
|
||||||
@ -225,7 +234,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startlog.Infof("Startup complete, operator running")
|
startlog.Infof("Startup complete, operator running")
|
||||||
if shouldRunAuthProxy == "true" {
|
if shouldRunAuthProxy {
|
||||||
rc, err := rest.TransportFor(restConfig)
|
rc, err := rest.TransportFor(restConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
startlog.Fatalf("could not get rest transport: %v", err)
|
startlog.Fatalf("could not get rest transport: %v", err)
|
||||||
@ -696,6 +705,15 @@ func getSingleObject[T any, O ptrObject[T]](ctx context.Context, c client.Client
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func defaultBool(envName string, defVal bool) bool {
|
||||||
|
vs := os.Getenv(envName)
|
||||||
|
if vs == "" {
|
||||||
|
return defVal
|
||||||
|
}
|
||||||
|
v, _ := opt.Bool(vs).Get()
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
func defaultEnv(envName, defVal string) string {
|
func defaultEnv(envName, defVal string) string {
|
||||||
v := os.Getenv(envName)
|
v := os.Getenv(envName)
|
||||||
if v == "" {
|
if v == "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user