| | |
| | | "strings" |
| | | |
| | | "basic.com/aps/aps_deploy.git/src/util" |
| | | "basic.com/aps/aps_deploy.git/src/rancher" |
| | | ) |
| | | |
| | | type Cluster struct { |
| | |
| | | SSHPort int `json:"sshPort"` |
| | | } |
| | | |
| | | type RancherConfig struct { |
| | | RancherURL string `json:"rancherURL"` |
| | | BearerToken string `json:"bearerToken"` |
| | | } |
| | | |
| | | type ClusterCreateRequest struct { |
| | | Name string `json:"name"` |
| | |
| | | return true, nil |
| | | } |
| | | |
| | | func CreateCluster(rancherConfig RancherConfig, clusterName string) error { |
| | | func CreateCluster(rancherConfig rancher.RancherConfig, clusterName string) error { |
| | | requestBody := createClusterData(clusterName) |
| | | |
| | | url := fmt.Sprintf("%s/v3/clusters", rancherConfig.RancherURL) |
| | |
| | | usedNodePorts = make(map[int32]bool) |
| | | ) |
| | | |
| | | func main() { |
| | | func create_test() { |
| | | // 配置 Kubernetes 集群的 kubeconfig 路径 |
| | | kubeconfig := flag.String("kubeconfig", filepath.Join(util.HomeDir(), ".kube", "config"), "kubeconfig file") |
| | | flag.Parse() |
| | |
| | | "k8s.io/client-go/tools/clientcmd" |
| | | ) |
| | | |
| | | var ( |
| | | replicas int32 = 3 |
| | | port int32 = 9081 |
| | | namespaces = []string{"guangsheng", "geruimi", "tongsheng"} |
| | | usedNodePorts = make(map[int32]bool) |
| | | ) |
| | | |
| | | func main() { |
| | | func delete_test() { |
| | | var ( |
| | | namespaces = []string{"guangsheng", "geruimi", "tongsheng"} |
| | | ) |
| | | |
| | | // 配置 Kubernetes 集群的 kubeconfig 路径 |
| | | kubeconfig := flag.String("kubeconfig", filepath.Join(util.HomeDir(), ".kube", "config"), "kubeconfig file") |
| | | flag.Parse() |
| | |
| | | if err != nil { |
| | | log.Printf("\033[97;41mFailed to create resources in namespace %s: %v\033[0m\n", ns, err) |
| | | } else { |
| | | nodeport, err := create.GetServiceNodePort(clientset, ns, ns) |
| | | nodeport, err := k8s.GetServiceNodePort(clientset, ns, ns) |
| | | if err != nil { |
| | | panic(err) |
| | | } |