@ -43,6 +43,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"tailscale.com/client/local"
"tailscale.com/client/local"
"tailscale.com/client/tailscale"
"tailscale.com/client/tailscale"
"tailscale.com/hostinfo"
"tailscale.com/hostinfo"
@ -144,18 +145,20 @@ func initTSNet(zlog *zap.SugaredLogger) (*tsnet.Server, tsClient) {
hostname = defaultEnv ( "OPERATOR_HOSTNAME" , "tailscale-operator" )
hostname = defaultEnv ( "OPERATOR_HOSTNAME" , "tailscale-operator" )
kubeSecret = defaultEnv ( "OPERATOR_SECRET" , "" )
kubeSecret = defaultEnv ( "OPERATOR_SECRET" , "" )
operatorTags = defaultEnv ( "OPERATOR_INITIAL_TAGS" , "tag:k8s-operator" )
operatorTags = defaultEnv ( "OPERATOR_INITIAL_TAGS" , "tag:k8s-operator" )
loginServer = strings . TrimSuffix ( defaultEnv ( "OPERATOR_LOGIN_SERVER" , "" ) , "/" )
)
)
startlog := zlog . Named ( "startup" )
startlog := zlog . Named ( "startup" )
if clientIDPath == "" || clientSecretPath == "" {
if clientIDPath == "" || clientSecretPath == "" {
startlog . Fatalf ( "CLIENT_ID_FILE and CLIENT_SECRET_FILE must be set" )
startlog . Fatalf ( "CLIENT_ID_FILE and CLIENT_SECRET_FILE must be set" )
}
}
tsc , err := newTSClient ( context . Background ( ) , clientIDPath , clientSecretPath )
tsc , err := newTSClient ( context . Background ( ) , clientIDPath , clientSecretPath , loginServer )
if err != nil {
if err != nil {
startlog . Fatalf ( "error creating Tailscale client: %v" , err )
startlog . Fatalf ( "error creating Tailscale client: %v" , err )
}
}
s := & tsnet . Server {
s := & tsnet . Server {
Hostname : hostname ,
Hostname : hostname ,
Logf : zlog . Named ( "tailscaled" ) . Debugf ,
Logf : zlog . Named ( "tailscaled" ) . Debugf ,
ControlURL : loginServer ,
}
}
if p := os . Getenv ( "TS_PORT" ) ; p != "" {
if p := os . Getenv ( "TS_PORT" ) ; p != "" {
port , err := strconv . ParseUint ( p , 10 , 16 )
port , err := strconv . ParseUint ( p , 10 , 16 )
@ -307,6 +310,7 @@ func runReconcilers(opts reconcilerOpts) {
proxyImage : opts . proxyImage ,
proxyImage : opts . proxyImage ,
proxyPriorityClassName : opts . proxyPriorityClassName ,
proxyPriorityClassName : opts . proxyPriorityClassName ,
tsFirewallMode : opts . proxyFirewallMode ,
tsFirewallMode : opts . proxyFirewallMode ,
loginServer : opts . tsServer . ControlURL ,
}
}
err = builder .
err = builder .
@ -639,6 +643,7 @@ func runReconcilers(opts reconcilerOpts) {
defaultTags : strings . Split ( opts . proxyTags , "," ) ,
defaultTags : strings . Split ( opts . proxyTags , "," ) ,
tsFirewallMode : opts . proxyFirewallMode ,
tsFirewallMode : opts . proxyFirewallMode ,
defaultProxyClass : opts . defaultProxyClass ,
defaultProxyClass : opts . defaultProxyClass ,
loginServer : opts . tsServer . ControlURL ,
} )
} )
if err != nil {
if err != nil {
startlog . Fatalf ( "could not create ProxyGroup reconciler: %v" , err )
startlog . Fatalf ( "could not create ProxyGroup reconciler: %v" , err )