Skip to content

Commit

Permalink
update wechat info
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Oct 21, 2020
1 parent 9c8f31c commit efffb40
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 111 deletions.
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,6 @@ GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/

如果您发现bug请及时提issue,我们会尽快确认并修改。

扫码后请加群主,便于我邀请您进讨论群,并请退出扫码网关群,谢谢!
<!-- 扫码后请加群主,便于我邀请您进讨论群,并请退出扫码网关群,谢谢!-->

<img src="https://raw.githubusercontent.com/tal-tech/zero-doc/main/doc/images/wechat.jpg" alt="wechat" width="300" />
<img src="https://raw.githubusercontent.com/tal-tech/zero-doc/main/doc/images/wechat.jpg" alt="wechat" width="300" />
6 changes: 5 additions & 1 deletion tools/goctl/k8s/apirpc.go → tools/goctl/k8s/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ spec:
path: /usr/share/zoneinfo/Asia/Shanghai
---
apiVersion: v1
kind: Service
metadata:
Expand All @@ -84,6 +85,7 @@ spec:
type: NodePort{{if .envIsPreOrPro}}
---
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
Expand All @@ -105,6 +107,7 @@ spec:
targetAverageUtilization: 80
---
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
Expand All @@ -123,4 +126,5 @@ spec:
- type: Resource
resource:
name: memory
targetAverageUtilization: 80{{end}}`
targetAverageUtilization: 80{{end}}
`
4 changes: 2 additions & 2 deletions tools/goctl/k8s/job.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package k8s

// 无环境区分
var jobTmeplate = `apiVersion: batch/v1beta1
kind: CronJob
metadata:
Expand Down Expand Up @@ -43,4 +42,5 @@ spec:
volumes:
- name: timezone
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai`
path: /usr/share/zoneinfo/Asia/Shanghai
`
44 changes: 6 additions & 38 deletions tools/goctl/k8s/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@ import (
"text/template"
)

var (
errUnknownServiceType = errors.New("unknown service type")
)

const (
ServiceTypeApi ServiceType = "api"
ServiceTypeRpc ServiceType = "rpc"
ServiceTypeJob ServiceType = "job"
ServiceTypeRmq ServiceType = "rmq"
ServiceTypeSync ServiceType = "sync"
envDev = "dev"
ServiceTypeApi ServiceType = "api"
ServiceTypeRpc ServiceType = "rpc"
ServiceTypeJob ServiceType = "job"
envDev = "dev"
)

var errUnknownServiceType = errors.New("unknown service type")

type (
ServiceType string
K8sRequest struct {
Expand Down Expand Up @@ -47,8 +43,6 @@ func Gen(req K8sRequest) (string, error) {
return genApiRpc(req)
case ServiceTypeJob:
return genJob(req)
case ServiceTypeRmq, ServiceTypeSync:
return genRmqSync(req)
default:
return "", errUnknownServiceType
}
Expand Down Expand Up @@ -83,32 +77,6 @@ func genApiRpc(req K8sRequest) (string, error) {
return buffer.String(), nil
}

func genRmqSync(req K8sRequest) (string, error) {
t, err := template.New("rmq_sync").Parse(rmqSyncTmeplate)
if err != nil {
return "", err
}
buffer := new(bytes.Buffer)
err = t.Execute(buffer, map[string]interface{}{
"name": fmt.Sprintf("%s-%s", req.ServiceName, req.ServiceType),
"namespace": req.Namespace,
"replicas": req.Replicas,
"revisionHistoryLimit": req.RevisionHistoryLimit,
"limitCpu": req.LimitCpu,
"limitMem": req.LimitMem,
"requestCpu": req.RequestCpu,
"requestMem": req.RequestMem,
"serviceName": req.ServiceName,
"env": req.Env,
"envIsPreOrPro": req.Env != envDev,
"envIsDev": req.Env == envDev,
})
if err != nil {
return "", nil
}
return buffer.String(), nil
}

func genJob(req K8sRequest) (string, error) {
t, err := template.New("job").Parse(jobTmeplate)
if err != nil {
Expand Down
68 changes: 0 additions & 68 deletions tools/goctl/k8s/rmqsync.go

This file was deleted.

0 comments on commit efffb40

Please sign in to comment.