update wechat info

master
kevin 4 years ago
parent 9c8f31cf83
commit efffb40fa3

@ -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" />

@ -67,6 +67,7 @@ spec:
path: /usr/share/zoneinfo/Asia/Shanghai
---
apiVersion: v1
kind: Service
metadata:
@ -84,6 +85,7 @@ spec:
type: NodePort{{if .envIsPreOrPro}}
---
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
@ -105,6 +107,7 @@ spec:
targetAverageUtilization: 80
---
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
@ -123,4 +126,5 @@ spec:
- type: Resource
resource:
name: memory
targetAverageUtilization: 80{{end}}`
targetAverageUtilization: 80{{end}}
`

@ -1,6 +1,5 @@
package k8s
// 无环境区分
var jobTmeplate = `apiVersion: batch/v1beta1
kind: CronJob
metadata:
@ -43,4 +42,5 @@ spec:
volumes:
- name: timezone
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai`
path: /usr/share/zoneinfo/Asia/Shanghai
`

@ -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 {
@ -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
}
@ -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 {

@ -1,68 +0,0 @@
package k8s
var rmqSyncTmeplate = `apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{.name}}
namespace: {{.namespace}}
labels:
app: {{.name}}
spec:
replicas: {{.replicas}}
revisionHistoryLimit: {{.revisionHistoryLimit}}
selector:
matchLabels:
app: {{.name}}
template:
metadata:
labels:
app: {{.name}}
spec:{{if .envIsDev}}
terminationGracePeriodSeconds: 60{{end}}
containers:
- name: {{.name}}
image: registry-vpc.cn-hangzhou.aliyuncs.com/{{.namespace}}/
lifecycle:
preStop:
exec:
command: ["sh","-c","sleep 5"]
env:
- name: aliyun_logs_k8slog
value: "stdout"
- name: aliyun_logs_k8slog_tags
value: "stage={{.env}}"
- name: aliyun_logs_k8slog_format
value: "json"
resources:
limits:
cpu: {{.limitCpu}}m
memory: {{.limitMem}}Mi
requests:
cpu: {{.requestCpu}}m
memory: {{.requestMem}}Mi
command:
- ./{{.serviceName}}
- -f
- ./{{.name}}.json
volumeMounts:
- name: timezone
mountPath: /etc/localtime
imagePullSecrets:
- name: {{.namespace}}
volumes:
- name: timezone
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai{{if .envIsPreOrPro}}
---
apiVersion: v1
kind: Service
metadata:
name: {{.name}}-svc
namespace: {{.namespace}}
spec:
selector:
app: {{.name}}
sessionAffinity: None
type: ClusterIP
clusterIP: None{{end}}`
Loading…
Cancel
Save