v1.1.11
This commit is contained in:
parent
d0e8846e24
commit
c7c657fe39
|
|
@ -1,5 +1,5 @@
|
||||||
build:
|
build:
|
||||||
image: docker:23.0.1-dind
|
image: docker.educg.net/container-mirrors/docker:23.0.1-dind
|
||||||
stage: build
|
stage: build
|
||||||
tags:
|
tags:
|
||||||
- dind-runner
|
- dind-runner
|
||||||
|
|
@ -12,7 +12,7 @@ build:
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
image:
|
image:
|
||||||
name: bitnami/kubectl:1.26.2
|
name: docker.educg.net/container-mirrors/bitnami/kubectl:1.26.2
|
||||||
entrypoint: [""]
|
entrypoint: [""]
|
||||||
stage: deploy
|
stage: deploy
|
||||||
only:
|
only:
|
||||||
|
|
|
||||||
10
Makefile
10
Makefile
|
|
@ -1,4 +1,4 @@
|
||||||
TAG ?= v1.1.10
|
TAG ?= v1.1.11
|
||||||
IMAGE_TAG ?= docker.educg.net/cg/k8s-manager:$(TAG)
|
IMAGE_TAG ?= docker.educg.net/cg/k8s-manager:$(TAG)
|
||||||
|
|
||||||
build: export CGO_ENABLED=0
|
build: export CGO_ENABLED=0
|
||||||
|
|
@ -11,14 +11,14 @@ docker:
|
||||||
docker build --rm -t $(IMAGE_TAG) .
|
docker build --rm -t $(IMAGE_TAG) .
|
||||||
|
|
||||||
install: docker
|
install: docker
|
||||||
kubectl apply -f install.yaml
|
sed 's/DOCKER_TAG_NAME/$(TAG)/' install.yaml | kubectl apply -f -
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
kubectl delete -f install.yaml
|
sed 's/DOCKER_TAG_NAME/$(TAG)/' install.yaml | kubectl delete -f -
|
||||||
|
|
||||||
restart: docker
|
restart: docker
|
||||||
kubectl delete -f install.yaml
|
sed 's/DOCKER_TAG_NAME/$(TAG)/' install.yaml | kubectl delete -f -
|
||||||
kubectl apply -f install.yaml
|
sed 's/DOCKER_TAG_NAME/$(TAG)/' install.yaml | kubectl apply -f -
|
||||||
|
|
||||||
push: docker
|
push: docker
|
||||||
docker push $(IMAGE_TAG)
|
docker push $(IMAGE_TAG)
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,3 @@ EOF
|
||||||
|
|
||||||
kubectl get secret dev-secret -o yaml
|
kubectl get secret dev-secret -o yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
## 安装Traefik
|
|
||||||
```bash
|
|
||||||
helm repo add traefik https://traefik.github.io/charts
|
|
||||||
helm repo update
|
|
||||||
helm install -f traefik-conf.yaml traefik traefik/traefik
|
|
||||||
helm uninstall traefik
|
|
||||||
helm install traefik traefik/traefik --set expose.dashboard=true
|
|
||||||
```
|
|
||||||
|
|
@ -21,6 +21,8 @@ spec:
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
env:
|
env:
|
||||||
|
- name: GIN_MODE
|
||||||
|
value: release
|
||||||
- name: URL_PREFIX
|
- name: URL_PREFIX
|
||||||
value: admin
|
value: admin
|
||||||
- name: DB_HOST
|
- name: DB_HOST
|
||||||
|
|
|
||||||
22
main.go
22
main.go
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-contrib/cors"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/golang-jwt/jwt/v4"
|
"github.com/golang-jwt/jwt/v4"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
@ -21,12 +20,31 @@ import (
|
||||||
//go:embed template/* static/*
|
//go:embed template/* static/*
|
||||||
var f embed.FS
|
var f embed.FS
|
||||||
|
|
||||||
|
func Cors() gin.HandlerFunc {
|
||||||
|
return func(c *gin.Context) {
|
||||||
|
method := c.Request.Method
|
||||||
|
origin := c.Request.Header.Get("Origin")
|
||||||
|
if origin != "" {
|
||||||
|
c.Header("Access-Control-Allow-Origin", "*")
|
||||||
|
c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, UPDATE")
|
||||||
|
c.Header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization")
|
||||||
|
c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Cache-Control, Content-Language, Content-Type")
|
||||||
|
c.Header("Access-Control-Allow-Credentials", "true")
|
||||||
|
}
|
||||||
|
if method == "OPTIONS" {
|
||||||
|
c.AbortWithStatus(http.StatusNoContent)
|
||||||
|
}
|
||||||
|
c.Next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
m.InitConfig()
|
m.InitConfig()
|
||||||
m.InitClient()
|
m.InitClient()
|
||||||
|
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
r.Use(cors.Default())
|
// r.Use(cors.Default())
|
||||||
|
r.Use(Cors())
|
||||||
|
|
||||||
fp, _ := fs.Sub(f, "static")
|
fp, _ := fs.Sub(f, "static")
|
||||||
r.StaticFS("/static", http.FS(fp))
|
r.StaticFS("/static", http.FS(fp))
|
||||||
|
|
|
||||||
|
|
@ -52,10 +52,10 @@ func JWTAuthMiddleware(c *gin.Context) {
|
||||||
authHeader = ""
|
authHeader = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if authHeader == "debug_special_key:83bsiablwtxv13" {
|
//if authHeader == "debug_special_key:83bsiablwtxv13" {
|
||||||
c.Set("username", "cg_wmj")
|
// c.Set("username", "cg_wmj")
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
if authHeader == "" {
|
if authHeader == "" {
|
||||||
c.JSON(http.StatusUnauthorized, gin.H{
|
c.JSON(http.StatusUnauthorized, gin.H{
|
||||||
"code": http.StatusUnauthorized,
|
"code": http.StatusUnauthorized,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue