mirror of
				https://github.com/tailscale/tailscale.git
				synced 2025-10-31 08:11:32 +01:00 
			
		
		
		
	Updates k8s-proxy's config so its auth mode config matches that we set in kube-apiserver ProxyGroups for consistency. Updates #13358 Change-Id: I95e29cec6ded2dc7c6d2d03f968a25c822bc0e01 Signed-off-by: Tom Proctor <tomhjp@users.noreply.github.com>
		
			
				
	
	
		
			44 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright (c) Tailscale Inc & AUTHORS
 | |
| // SPDX-License-Identifier: BSD-3-Clause
 | |
| 
 | |
| //go:build !plan9
 | |
| 
 | |
| package main
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 	"log"
 | |
| 	"os"
 | |
| 
 | |
| 	"tailscale.com/kube/kubetypes"
 | |
| 	"tailscale.com/types/ptr"
 | |
| )
 | |
| 
 | |
| func parseAPIProxyMode() *kubetypes.APIServerProxyMode {
 | |
| 	haveAuthProxyEnv := os.Getenv("AUTH_PROXY") != ""
 | |
| 	haveAPIProxyEnv := os.Getenv("APISERVER_PROXY") != ""
 | |
| 	switch {
 | |
| 	case haveAPIProxyEnv && haveAuthProxyEnv:
 | |
| 		log.Fatal("AUTH_PROXY (deprecated) and APISERVER_PROXY are mutually exclusive, please unset AUTH_PROXY")
 | |
| 	case haveAuthProxyEnv:
 | |
| 		var authProxyEnv = defaultBool("AUTH_PROXY", false) // deprecated
 | |
| 		if authProxyEnv {
 | |
| 			return ptr.To(kubetypes.APIServerProxyModeAuth)
 | |
| 		}
 | |
| 		return nil
 | |
| 	case haveAPIProxyEnv:
 | |
| 		var apiProxyEnv = defaultEnv("APISERVER_PROXY", "") // true, false or "noauth"
 | |
| 		switch apiProxyEnv {
 | |
| 		case "true":
 | |
| 			return ptr.To(kubetypes.APIServerProxyModeAuth)
 | |
| 		case "false", "":
 | |
| 			return nil
 | |
| 		case "noauth":
 | |
| 			return ptr.To(kubetypes.APIServerProxyModeNoAuth)
 | |
| 		default:
 | |
| 			panic(fmt.Sprintf("unknown APISERVER_PROXY value %q", apiProxyEnv))
 | |
| 		}
 | |
| 	}
 | |
| 	return nil
 | |
| }
 |