fix registry address
This commit is contained in:
Submodule application updated: 587a331bbe...eba337fb68
@@ -29,8 +29,8 @@ var (
|
|||||||
|
|
||||||
func InitializeClient() {
|
func InitializeClient() {
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
argocdServer := "192.168.1.10:31946"
|
argocdServer := "192.168.2.172:32200"
|
||||||
argocdToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhcmdvY2QiLCJzdWIiOiJhZG1pbjphcGlLZXkiLCJuYmYiOjE3Mzc5NzA4MTksImlhdCI6MTczNzk3MDgxOSwianRpIjoiYjgzODAxZDQtNWNjOC00NTNiLWE0NTYtNTBjNzZjODkyMzcwIn0.9QXrnVeeTnH18YXb9rE7UTWIk16O63a9O03au35SEwk"
|
argocdToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhcmdvY2QiLCJzdWIiOiJhZG1pbjphcGlLZXkiLCJuYmYiOjE3NDM4NTAwNzIsImlhdCI6MTc0Mzg1MDA3MiwianRpIjoiNWZhNmQ5MDgtMzljNi00ZWQ4LWE5YzgtMzI4YzMzYjkyNzk4In0.ZvhJk4L5vBQldtJyReKYXCQCWF8j8gHLZlY8PninSFA"
|
||||||
|
|
||||||
config := apiclient.ClientOptions{
|
config := apiclient.ClientOptions{
|
||||||
ServerAddr: argocdServer,
|
ServerAddr: argocdServer,
|
||||||
@@ -46,7 +46,7 @@ func InitializeClient() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateApp() {
|
func CreateApp(clustername string) {
|
||||||
|
|
||||||
InitializeClient()
|
InitializeClient()
|
||||||
|
|
||||||
@@ -57,12 +57,12 @@ func CreateApp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app := ApplicationValues{
|
app := ApplicationValues{
|
||||||
Name: "vc-bhrz-n",
|
Name: clustername,
|
||||||
Namespace: "vc-bhrz-n",
|
Namespace: "vc-bhrz-n",
|
||||||
Path: "vcluster-0.21.1",
|
Path: "vcluster-0.21.1",
|
||||||
Cluster: "in-cluster",
|
Cluster: "in-cluster",
|
||||||
Server: "https://kubernetes.default.svc",
|
Server: "https://kubernetes.default.svc",
|
||||||
RepoURL: "http://192.168.1.10:3000/admin/applications",
|
RepoURL: "http://192.168.2.20:8015/root/application.git",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the ArgoCD application
|
// Define the ArgoCD application
|
||||||
|
|||||||
1
db/db.go
1
db/db.go
@@ -21,4 +21,5 @@ func InitDB() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
UserCollection = client.Database("vcluster").Collection("users")
|
UserCollection = client.Database("vcluster").Collection("users")
|
||||||
|
Vclusters_details = client.Database("vcluster").Collection("vclusters_details")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,35 +19,4 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
ME_CONFIG_MONGODB_ADMINUSERNAME: root
|
ME_CONFIG_MONGODB_ADMINUSERNAME: root
|
||||||
ME_CONFIG_MONGODB_ADMINPASSWORD: example
|
ME_CONFIG_MONGODB_ADMINPASSWORD: example
|
||||||
ME_CONFIG_MONGODB_URL: mongodb://root:example@192.168.1.10:27017/
|
ME_CONFIG_MONGODB_URL: mongodb://root:example@192.168.1.10:27017/
|
||||||
|
|
||||||
gitea:
|
|
||||||
image: gitea/gitea:latest
|
|
||||||
container_name: gitea
|
|
||||||
environment:
|
|
||||||
- USER_UID=1000
|
|
||||||
- USER_GID=1000
|
|
||||||
- DB_TYPE=postgres
|
|
||||||
- DB_HOST=db:5432
|
|
||||||
- DB_NAME=gitea
|
|
||||||
- DB_USER=gitea
|
|
||||||
- DB_PASSWD=gitea_password
|
|
||||||
restart: always
|
|
||||||
volumes:
|
|
||||||
- ./gitea/data:/data
|
|
||||||
ports:
|
|
||||||
- "3000:3000"
|
|
||||||
- "222:22"
|
|
||||||
depends_on:
|
|
||||||
- db
|
|
||||||
|
|
||||||
db:
|
|
||||||
image: postgres:15
|
|
||||||
container_name: gitea_db
|
|
||||||
environment:
|
|
||||||
- POSTGRES_USER=gitea
|
|
||||||
- POSTGRES_PASSWORD=gitea_password
|
|
||||||
- POSTGRES_DB=gitea
|
|
||||||
restart: always
|
|
||||||
volumes:
|
|
||||||
- ./postgres/data:/var/lib/postgresql/data
|
|
||||||
1
go.mod
1
go.mod
@@ -6,6 +6,7 @@ require (
|
|||||||
github.com/argoproj/argo-cd/v2 v2.13.3
|
github.com/argoproj/argo-cd/v2 v2.13.3
|
||||||
github.com/golang-jwt/jwt/v4 v4.5.1
|
github.com/golang-jwt/jwt/v4 v4.5.1
|
||||||
github.com/gorilla/mux v1.7.3
|
github.com/gorilla/mux v1.7.3
|
||||||
|
github.com/rs/cors v1.11.0
|
||||||
golang.org/x/crypto v0.32.0
|
golang.org/x/crypto v0.32.0
|
||||||
k8s.io/apimachinery v0.31.0
|
k8s.io/apimachinery v0.31.0
|
||||||
)
|
)
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -413,6 +413,8 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f
|
|||||||
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
|
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
|
||||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||||
|
github.com/rs/cors v1.11.0 h1:0B9GE/r9Bc2UxRMMtymBkHTenPkHDv0CW4Y98GBY+po=
|
||||||
|
github.com/rs/cors v1.11.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
|
||||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package handler
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"main/argohandler"
|
||||||
"main/db"
|
"main/db"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@@ -25,24 +26,31 @@ type Cluster struct {
|
|||||||
|
|
||||||
func createClusterHandler(w http.ResponseWriter, r *http.Request) {
|
func createClusterHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
vclusterCollection := db.Client.Database("vcluster").Collection("vclusters_details")
|
|
||||||
|
|
||||||
var cluster Cluster
|
var cluster Cluster
|
||||||
_ = json.NewDecoder(r.Body).Decode(&cluster)
|
_ = json.NewDecoder(r.Body).Decode(&cluster)
|
||||||
|
|
||||||
|
// vclusterCollection := db.Vclusters_details.FindOne(context.TODO(), bson.M{"name": Cluster.Name}).Decode(&existsCluster)
|
||||||
|
|
||||||
if cluster.Name == "" || cluster.ControlPlane == "" || cluster.PlatformVersion == "" || cluster.Cpu == "" || cluster.Memory == "" {
|
if cluster.Name == "" || cluster.ControlPlane == "" || cluster.PlatformVersion == "" || cluster.Cpu == "" || cluster.Memory == "" {
|
||||||
http.Error(w, "Invalid input", http.StatusBadRequest)
|
http.Error(w, "Invalid input", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var existsCluster Cluster
|
var existsCluster Cluster
|
||||||
_ = vclusterCollection.FindOne(context.TODO(), bson.M{"name": cluster.Name}).Decode(&existsCluster)
|
_ = db.Vclusters_details.FindOne(context.TODO(), bson.M{"name": cluster.Name}).Decode(&existsCluster)
|
||||||
|
|
||||||
if existsCluster.Name == cluster.Name {
|
if existsCluster.Name == cluster.Name {
|
||||||
http.Error(w, "Cluster name is duplicated", http.StatusBadRequest)
|
http.Error(w, "Cluster name is duplicated", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err := db.Vclusters_details.InsertOne(context.TODO(), cluster)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, `{"message": "Could not create cluster"}`, http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
|
argohandler.CreateApp(cluster.Name)
|
||||||
|
|
||||||
response := map[string]string{"message": "Cluster created"}
|
response := map[string]string{"message": "Cluster created"}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|||||||
Reference in New Issue
Block a user