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我们会尽快确认并修改。 如果您发现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 path: /usr/share/zoneinfo/Asia/Shanghai
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
@ -84,6 +85,7 @@ spec:
type: NodePort{{if .envIsPreOrPro}} type: NodePort{{if .envIsPreOrPro}}
--- ---
apiVersion: autoscaling/v2beta1 apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler kind: HorizontalPodAutoscaler
metadata: metadata:
@ -105,6 +107,7 @@ spec:
targetAverageUtilization: 80 targetAverageUtilization: 80
--- ---
apiVersion: autoscaling/v2beta1 apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler kind: HorizontalPodAutoscaler
metadata: metadata:
@ -123,4 +126,5 @@ spec:
- type: Resource - type: Resource
resource: resource:
name: memory name: memory
targetAverageUtilization: 80{{end}}` targetAverageUtilization: 80{{end}}
`

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

@ -7,19 +7,15 @@ import (
"text/template" "text/template"
) )
var (
errUnknownServiceType = errors.New("unknown service type")
)
const ( const (
ServiceTypeApi ServiceType = "api" ServiceTypeApi ServiceType = "api"
ServiceTypeRpc ServiceType = "rpc" ServiceTypeRpc ServiceType = "rpc"
ServiceTypeJob ServiceType = "job" ServiceTypeJob ServiceType = "job"
ServiceTypeRmq ServiceType = "rmq" envDev = "dev"
ServiceTypeSync ServiceType = "sync"
envDev = "dev"
) )
var errUnknownServiceType = errors.New("unknown service type")
type ( type (
ServiceType string ServiceType string
K8sRequest struct { K8sRequest struct {
@ -47,8 +43,6 @@ func Gen(req K8sRequest) (string, error) {
return genApiRpc(req) return genApiRpc(req)
case ServiceTypeJob: case ServiceTypeJob:
return genJob(req) return genJob(req)
case ServiceTypeRmq, ServiceTypeSync:
return genRmqSync(req)
default: default:
return "", errUnknownServiceType return "", errUnknownServiceType
} }
@ -83,32 +77,6 @@ func genApiRpc(req K8sRequest) (string, error) {
return buffer.String(), nil 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) { func genJob(req K8sRequest) (string, error) {
t, err := template.New("job").Parse(jobTmeplate) t, err := template.New("job").Parse(jobTmeplate)
if err != nil { 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