mirror of
				https://github.com/1Panel-dev/KubePi.git
				synced 2025-10-31 18:42:41 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			24 lines
		
	
	
		
			396 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			396 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package kubernetes
 | |
| 
 | |
| import (
 | |
| 	"k8s.io/client-go/kubernetes"
 | |
| 	"k8s.io/client-go/rest"
 | |
| )
 | |
| 
 | |
| type Config struct {
 | |
| 	Host  string
 | |
| 	Token string
 | |
| }
 | |
| 
 | |
| func NewKubernetesClient(c *Config) (*kubernetes.Clientset, error) {
 | |
| 	kubeConf := &rest.Config{
 | |
| 		Host:        c.Host,
 | |
| 		BearerToken: c.Token,
 | |
| 		TLSClientConfig: rest.TLSClientConfig{
 | |
| 			Insecure: true,
 | |
| 		},
 | |
| 	}
 | |
| 	return kubernetes.NewForConfig(kubeConf)
 | |
| 
 | |
| }
 | 
