otto 9 months ago
commit
5b2710c04a
  1. 41
      .gitignore
  2. 21
      Dockerfile
  3. 143
      Jenkinsfile
  4. 35
      build.sh
  5. 19
      configs/config
  6. 19
      configs/config-dev
  7. 19
      configs/config-master
  8. 70
      go.mod
  9. 7
      hot.go
  10. 22
      hotspot-clear-job-dev.yaml
  11. 85
      task/task.go
  12. 10
      task_test.go

41
.gitignore vendored

@ -0,0 +1,41 @@
# Reference https://github.com/github/gitignore/blob/master/Go.gitignore
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
vendor/
# Go workspace file
go.work
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# OS General
Thumbs.db
.DS_Store
# project
*.cert
*.key
*.log
bin/
# Develop tools
.vscode/
.idea/
*.swp
go.sum
main
hot

21
Dockerfile

@ -0,0 +1,21 @@
FROM 192.168.1.131:8888/library/golang:1.20.5 AS builder
COPY . /src
WORKDIR /src
RUN go mod tidy
RUN go build hot.go
FROM 192.168.1.131:8888/library/alpine:3.13
RUN apk add make
RUN set -eux && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN apk update && apk add tzdata
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo "Asia/Shanghai" > /etc/timezone
WORKDIR /app
COPY --from=builder /src/configs /app/configs
COPY --from=builder /src/hot /app/hot
ENTRYPOINT ["./hot"]

143
Jenkinsfile vendored

@ -0,0 +1,143 @@
// 获取当前的git分支
def branch(){
switch("${env.GIT_BRANCH}") {
case "origin/dev":
return "dev"
case "origin/release":
return "release"
case "origin/beta":
return "beta"
case "origin/master":
return "master"
case "*/dev":
return "dev"
case "*/release":
return "release"
case "*/beta":
return "beta"
case "*/master":
return "master"
}
return ""
}
// 同步yaml部署文件
def yaml(){
switch("${env.Branch}") {
case "dev":
sshPublisher(publishers: [sshPublisherDesc(configName: 'k8s', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '', remoteDirectorySDF: false, removePrefix: '', sourceFiles: "${NAME}-job-${env.BRANCH}.yaml")], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
break
case "release":
break
case "beta":
echo "yaml beta"
break
case "master":
sshPublisher(publishers: [sshPublisherDesc(configName: 'master-k8s', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '', remoteDirectorySDF: false, removePrefix: '', sourceFiles: "${NAME}-job-${env.BRANCH}.yaml")], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
break
}
}
// 执行yaml部署
def apply(){
switch("${env.Branch}") {
case "dev":
sh "ssh root@192.168.1.156 kubectl apply -f /usr/local/k8s/${NAME}-job-${env.BRANCH}.yaml"
break
case "release":
echo "apply release"
break
case "beta":
echo "apply beta"
break
case "master":
sshagent(['test-k8s-login-key']) {
sh "ssh root@193.112.79.170 kubectl apply -f /usr/local/k8s/${NAME}-job-${env.BRANCH}.yaml"
}
break
}
}
def image(){
switch("${env.Branch}") {
case "dev":
sh "ssh root@192.168.1.156 kubectl set image Deployment/${env.K8S_DEPLOYMENT} ${env.NAME}=192.168.1.131:8888/job/${env.BRANCH}/${env.NAME}:${env.VERSION} -n ${env.BRANCH}"
break
case "release":
echo "image release"
break
case "beta":
echo "image beta"
break
case "master":
sshagent(['test-k8s-login-key']) {
sh "ssh root@193.112.79.170 kubectl set image Deployment/${env.K8S_DEPLOYMENT} ${env.NAME}=192.168.0.19:5000/job/${env.BRANCH}/${env.NAME}:${env.VERSION} -n ${env.BRANCH}"
}
break
}
}
pipeline {
agent any
environment {
// 服务名
NAME = 'hotspot-clear'
// 镜像名称,对应K8S_FILE里面Deployment.containers的name
// git路径
GIT_URL = 'http://git.gz.internal.jumaiyx.cn/jm/live.git'
// k8s deployment名称,对应K8S_FILE里面Deployment的name
K8S_DEPLOYMENT = 'hotspot-clear-job'
// 分支
BRANCH = branch()
// 更新的版本
VERSION = "${env.GIT_COMMIT}"
// 自动生成版本号,仅限dev和release使用,master按照tag版本
IMAGE_VERSION = UUID.randomUUID().toString()
}
stages {
// 首次部署需要使用,后期可以直接注释掉此步骤
stage('传入yaml') {
steps {
yaml()
echo '传入yaml 完成'
}
}
// 首次部署需要使用,后期可以直接注释掉此步骤
stage('apply') {
steps {
apply()
echo '执行apply 完成'
}
}
stage('更新image') {
steps {
image()
echo '更新image 完成'
}
}
}
post {
always {
echo 'I will always say Hello again!'
}
success {
// FeiShu(webhook:fei(),proxy:'',msg:'',atAll:false,type:'')
echo '部署完成'
}
failure {
// FeiShu(webhook:fei(),proxy:'',msg:'',atAll:false,type:'')
echo 'I will always say Hello again!'
}
}
}

35
build.sh

@ -0,0 +1,35 @@
#!/bin/bash
#version=git log --format='%H' -n1
project_name="hotspot-clear"
version=$(git log --format='%H' -n1)
environment=$(git rev-parse --abbrev-ref HEAD)
hostname="192.168.1.131:8888"
if [ ! -n "$version" ] ;then
echo "未获取到版本信息"
return
fi
echo "打包的环境:$environment"
echo "打包版本号:$version"
echo "项目名称:$project_name"
if [ $environment == "dev" ] ;then
echo "======登录镜像仓库======"
docker login -u admin -p jumai123 192.168.1.131:8888
fi
if [ $environment == "master" ] ;then
hostname="harbor.homieyy.com"
echo "======登录镜像仓库======"
docker login -u admin -p 1EeFT5qjpM harbor.homieyy.com
fi
echo "======build======"
docker build -t $project_name:latest .
echo "======tag======="
docker tag $project_name:latest $hostname/job/$environment/$project_name:$version
echo "======push======="
docker push $hostname/job/$environment/$project_name:$version
echo "======delete====="
docker rmi $project_name:latest $hostname/job/$environment/$project_name:$version

19
configs/config

@ -0,0 +1,19 @@
apiVersion: v1
clusters:
- c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kzYXd5dXdTdUVTMU0yS1FlYjZsWThzCkR6ZHU3VkdpdDFsUzRFTXhHM2I0UkEybDhzREZGYWpmYklDbURzRG9senlWMmlENS9pZENyN0VIcGZlbjFKOHYKa2FVbW1pWmRXOFFZU2svb016RDN2VmNVdkNUQW5rZWc5NlVkQ0tWVlpMaXkxN3FSUW1Ta1lqMFhhTXE0S0h5WgpvT09MOFhMdUFKNHVnM1dnZ3R5aVVnOW44RzVnVFVVWExIdDM4T1U5Yy9HaE5GUGhPdTdCMEVyb1RIbz0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
server: https://192.168.1.156:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: kubernetes-admin
name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJTWQ1OWc1L241TkF3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TXpBMU1qTXdOek13TkRoYUZ3MHlOREExTWpJd056TXdOVEJhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQTJqMmhCMG5DZytFaE0zejUKNW1RVHVZdmVSblZ5blVRemJwcWtleVNOR005LzRJYXVVNEg4by9VRE5vQ1JZNnBBdWpLUWNkc2ZJMEdGUkxTRAp4ZGtuQkJGYlVMRnptUHkwdEJiQkVkMm1pS3B2NktpaC9qRk0xTWFHY0l2R29nRnFrRDNrU3pMVGRKRnQ1OThMCkI3b21yTzZLRFlLakJXMjlydGdPNnRDWlUrUG12RWRpbStGRDIrb2VYY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3VkdpdDFsUzRFTXhHM2I0UkEybDhzREZGYWpmYklDbURzRG9senlWMmlENS9pZENyN0VIcGZlbjFKOHYKa2FVbW1pWmRXOFFZU2svb016RDN2VmNVdkNUQW5rZWc5NlVkQ0tWVlpMaXkxN3FSUW1Ta1lqMFhhTXE0S0h5WgpvT09MOFhMdUFKNHVnM1dnZ3R5aVVnOW44RzVnVFVVWExIdDM4T1U5Yy9HaE5GUGhPdTdCMEVyb1RIbz0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
server: https://192.168.1.156:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: kubernetes-admin
name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJTWQ1OWc1L241TkF3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TXpBMU1qTXdOek13TkRoYUZ3MHlOREExTWpJd056TXdOVEJhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQTJqMmhCMG5DZytFaE0zejUKNW1RVHVZdmVSblZ5blVRemJwcWtleVNOR005LzRJYXVVNEg4by9VRE5vQ1JZNnBBdWpLUWNkc2ZJMEdGUkxTRAp4ZGtuQkJGYlVMRnptUHkwdEJiQkVkMm1pS3B2NktpaC9qRk0xTWFHY0l2R29nRnFrRDNrU3pMVGRKRnQ1OThMCkI3b21yTzZLRFlLakJXMjlydGdPNnRDWlUrUG12RWRpbStGRDIrb2VYY0kzbktzbE1xQ3FrOFZ0aUxWNFFtWWgKbG1JZ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T2U0eTZGOGZDTEhOTXJqeDEvYWVQZlpBWVlhbC9QU2gKL0dicEVJVFg4QWFKeDhiM2xURlF2UFZadTFucUJzTitpV3BuMFQ0Tm14Y09IbjNyeWJqa09jdU9GL0p4aVFhUwpTQVFic1l2Q01pQkZXZHRoeDFNSFpBOWRkTHMrSk96bjdzVFZ1Y2RtcU04YkRaNVNJOGhGRGRvU1JhND0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
server: https://192.168.0.20
name: cls-1wvehx8c
contexts:
- context:
cluster: cls-1wvehx8c
user: "100029630066"
name: cls-1wvehx8c-100029630066-context-default
current-context: cls-1wvehx8c-100029630066-context-default
kind: Config
preferences: {}
users:
- name: "100029630066"
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURERENDQWZTZ0F3SUJBZ0lJV1Y4cjFQQWxPYmt3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TkRBek1URXdNakkyTURsYUZ3MDBOREF6TVRFd01qSTJNRGxhTURZeApFakFRQmdOVkJBb1RDWFJyWlRwMWMyVnljekVnTUI0R0ExVUVBeE1YTVRBd01ESTVOak13TURZMkxURTNNVEF4Ck1qTTVOamt3Z2dFaU1BMEdDU3FHU0liM0RRRUJBUVVBQTRJQkR3QXdnZ0VLQW9JQkFRREtZTmxhT2VPYXZIa04Kbnp6dEwxeG9UQ2trMzMzY2kzS2k4d1dJc0x4aExNa0c5aDhqbFRacy85SC90dXcyRWVteVJ4UEpiTW4vYXNVLwpzTk85OEh3VXNEdjFNNEtwSThSdTBGeVdUQTgxb21oRnNKQW5vS1Z3NlArL0kxcUFnU21qNTRzM3pzdWJOdTVLCkZISkpmQ1RVd1ByMVEzcVBjdVY0Sy9qbktxYittYlZKUHRmSEk5d1JMcGttUFlpSlZTbmx6SHVhRHk4MVJFalUKbWZGZ3QyZFJ1a1g2ak9oS0NvZ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b71e
git.gz.internal.jumaiyx.cn/pkg/config/v2 v2.0.0-20240312130125-0f8bbcc94011
git.gz.internal.jumaiyx.cn/pkg/k8s-client/v2 v2.0.3-0.20240229083126-a1abe7ddc19f
git.gz.internal.jumaiyx.cn/pkg/webhook v0.0.0-20240314063906-8db8467590c4
github.com/redis/go-redis/v9 v9.5.1
)
require (
git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20231228111035-ab8eeaae2906 // indirect
git.gz.internal.jumaiyx.cn/pkg/client v0.0.0-20231123090823-91017d7a1a1e // indirect
git.gz.internal.jumaiyx.cn/pkg/jtime v0.0.0-20230627153611-5d9e320123cc // indirect
git.gz.internal.jumaiyx.cn/pkg/kubediscovery v0.0.0-20240229083231-fa19d823f204 // indirect
git.gz.internal.jumaiyx.cn/proto/game-server v0.0.0-20231031074443-b9b51900f07a // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/go-kratos/aegis v0.2.0 // indirect
github.com/go-kratos/kratos/v2 v2.7.1 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-playground/form/v4 v4.2.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20231030173426-d783a09b4405 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231030173426-d783a09b4405 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.28.3 // indirect
k8s.io/apimachinery v0.28.3 // indirect
k8s.io/client-go v0.28.3 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

7
hot.go

@ -0,0 +1,7 @@
package main
import "git.gz.internal.jumaiyx.cn/job/hotspot-clear/task"
func main() {
task.NewTask()
}

22
hotspot-clear-job-dev.yaml

@ -0,0 +1,22 @@
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: hotspot-clear-job
namespace: dev
spec:
# schedule: "* 10 * * *" # 10分钟
schedule: "0 * * * *" # 一小时
jobTemplate:
spec:
template:
spec:
containers:
- name: hotspot-clear
image: harbor.homieyy.com/job/dev/hotspot-queue:2cbd86f97b825d22ba0513c75d3485b904cbcafd
env:
- name: JM_ENVIRONMENT
value: dev
imagePullPolicy: IfNotPresent
restartPolicy: OnFailure
imagePullSecrets:
- name: local-harbor

85
task/task.go

@ -0,0 +1,85 @@
package task
import (
"context"
configv2 "git.gz.internal.jumaiyx.cn/pkg/config/v2"
"git.gz.internal.jumaiyx.cn/pkg/config/v2/cproto"
k8sclient "git.gz.internal.jumaiyx.cn/pkg/k8s-client/v2"
"git.gz.internal.jumaiyx.cn/pkg/webhook/wechat"
"github.com/redis/go-redis/v9"
"strconv"
"sync"
"time"
)
const (
hotKey = "room:hot:ranking"
)
var (
redisInstance *redis.Client
once sync.Once
)
func NewRedis() *redis.Client {
once.Do(func() {
redisConfig := &cproto.Redis{}
_ = configv2.Get(configv2.Redis, redisConfig)
redisInstance = redis.NewClient(&redis.Options{
Addr: redisConfig.Addr,
Password: redisConfig.Password,
PoolSize: 10,
ReadTimeout: 100 * time.Second,
WriteTimeout: 100 * time.Second,
})
})
return redisInstance
}
func NewTask() {
start := time.Now().Unix()
err := task()
times := time.Now().Unix() - start
if times == 0 {
times = 1
}
wechatHook(times, err)
}
func task() error {
redisClient := NewRedis()
result, err := redisClient.ZRange(context.Background(), hotKey, 0, -1).Result()
if err != nil {
return err
}
var members []redis.Z
for _, id := range result {
members = append(members, redis.Z{
Member: id,
Score: 0,
})
}
err = redisClient.ZAdd(context.Background(), hotKey, members...).Err()
if err != nil {
return err
}
return nil
}
func wechatHook(times int64, err error) {
envi := "测试"
if k8sclient.Environment() == k8sclient.MasterNamespace {
envi = "正式"
}
hook := wechat.NewMarkdown("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=00dd9216-1f50-42be-8fe1-e66640d7bb27").
Title(1, "直播间热度清理").Br().
Text("环境:" + envi).Br().
Text("耗时:" + strconv.Itoa(int(times)) + "s").Br().Text("状态:")
if err != nil {
hook = hook.FontColor("失败", wechat.Warning).Br().Text("异常:").FontColor(err.Error(), wechat.Warning)
} else {
hook = hook.FontColor("完成", wechat.Info)
}
_ = hook.Send()
}

10
task_test.go

@ -0,0 +1,10 @@
package main
import (
"git.gz.internal.jumaiyx.cn/job/hotspot-clear/task"
"testing"
)
func TestTask(t *testing.T) {
task.NewTask()
}
Loading…
Cancel
Save