otto 6 months ago
commit
795a1b8d47
  1. 42
      .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. 64
      go.mod
  9. 22
      hotspot-clear-job-dev.yaml
  10. 60
      main.go

42
.gitignore vendored

@ -0,0 +1,42 @@
# 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
test
main

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 = 'message-clear'
// 镜像名称,对应K8S_FILE里面Deployment.containers的name
// git路径
// GIT_URL = 'http://git.gz.internal.jumaiyx.cn/job/hotspot-clear.git'
// k8s deployment名称,对应K8S_FILE里面Deployment的name
K8S_DEPLOYMENT = 'message-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="message-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:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBD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cEJsL21SCnRGbFI5aUhnVElYaC9HbHFnSlZxamVDdFBGOUhhNS8vQmlWQXk5T2pqQm1zN2djemV3TmZmRWJFaG5OWTVvL0QKZlc3SnoyZTRKaWhtRkZxZWdUYXBDMjJXaDdEYU9rV2NhbXVjRFJzMDlPdEVyRm8zNVRsdjdRL0RidjNDU1hPcwpHcVp2dlB3Rkt1Y2JhZjAzOFdyT1dmcXlsdTBpT2VFVEN5MkVPaEtYOUxjZ3pHeTRvNnFRNDNaRllNMD0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
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: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJRzFyL0hQZ2VCd3d3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TkRBME1ERXdPVFE0TXpGYUZ3MHlOVEEwTURFd09UUTRNek5hTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQTVydU5Mc0MrVHVZb3lxOFUKdXREVlN6bEpWdzVxZmlncUZvYlF6WjVjUXFMaFlxMU1RSXlRUEhDdjBPVUdVUmh4eWtHS3pZNU1NZWk4cjFxdwo0VUU2RGIxQnhtZVBZNlQ5VUY5Wnh4bzJHajBFYmNIaDlWc3FZZnNGYkVXMFB6dlR4QW16WE1wZkNhVWphOTlLClRmdGZsa1JQY0hVZ2JDN0dXMW4xZjE0NExYa3RHcnIzU3JHaTA5WTVBRzhB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UhnVElYaC9HbHFnSlZxamVDdFBGOUhhNS8vQmlWQXk5T2pqQm1zN2djemV3TmZmRWJFaG5OWTVvL0QKZlc3SnoyZTRKaWhtRkZxZWdUYXBDMjJXaDdEYU9rV2NhbXVjRFJzMDlPdEVyRm8zNVRsdjdRL0RidjNDU1hPcwpHcVp2dlB3Rkt1Y2JhZjAzOFdyT1dmcXlsdTBpT2VFVEN5MkVPaEtYOUxjZ3pHeTRvNnFRNDNaRllNMD0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
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: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJRzFyL0hQZ2VCd3d3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TkRBME1ERXdPVFE0TXpGYUZ3MHlOVEEwTURFd09UUTRNek5hTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQTVydU5Mc0MrVHVZb3lxOFUKdXREVlN6bEpWdzVxZmlncUZvYlF6WjVjUXFMaFlxMU1RSXlRUEhDdjBPVUdVUmh4eWtHS3pZNU1NZWk4cjFxdwo0VUU2RGIxQnhtZVBZNlQ5VUY5Wnh4bzJHajBFYmNIaDlWc3FZZnNGYkVXMFB6dlR4QW16WE1wZkNhVWphOTlLClRmdGZsa1JQY0hVZ2JDN0dXMW4xZjE0NExYa3RHcnIzU3JHaTA5WTVBRzhBdVJSNnNMQUp5cEdB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YXhLU1QwQ2tZT2U0eTZGOGZDTEhOTXJqeDEvYWVQZlpBWVlhbC9QU2gKL0dicEVJVFg4QWFKeDhiM2xURlF2UFZadTFucUJzTitpV3BuMFQ0Tm14Y09IbjNyeWJqa09jdU9GL0p4aVFhUwpTQVFic1l2Q01pQkZXZHRoeDFNSFpBOWRkTHMrSk96bjdzVFZ1Y2RtcU04YkRaNVNJOGhGRGRvU1JhND0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
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: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURERENDQWZTZ0F3SUJBZ0lJV1Y4cjFQQWxPYmt3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TkRBek1URXdNakkyTURsYUZ3MDBOREF6TVRFd01qSTJNRGxhTURZeApFakFRQmdOVkJBb1RDWFJyWlRwMWMyVnljekVnTUI0R0ExVUVBeE1YTVRBd01ESTVOak13TURZMkxURTNNVEF4Ck1qTTVOamt3Z2dFaU1BMEdDU3FHU0liM0RRRUJBUVVBQTRJQkR3QXdnZ0VLQW9JQkFRREtZTmxhT2VPYXZIa04Kbnp6dEwxeG9UQ2trMzMzY2kzS2k4d1dJc0x4aExNa0c5aDhqbFRacy85SC90dXcyRWVteVJ4UEpiTW4vYXNVLwpzTk85OEh3VXNEdjFNNEtwSThSdTBGeVdUQTgxb21oRnNKQW5vS1Z3NlArL0kxcUFnU21qNTRzM3pzdWJOdTVLCkZISkpmQ1RVd1ByMVEzcVBjdVY0Sy9qbktxYittYlZKUHRmSEk5d1JMcGttUFlpSlZTbmx6SHVhRHk4MVJFalUKbWZGZ3QyZFJ1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-3371166bf601
git.gz.internal.jumaiyx.cn/pkg/client v0.0.0-20240515061156-c1741246ef08
git.gz.internal.jumaiyx.cn/pkg/jtime v0.0.0-20240511034446-4ac0f30c3d97
git.gz.internal.jumaiyx.cn/pkg/k8s-client/v2 v2.0.3-0.20240514094846-93f9e5808a5d
git.gz.internal.jumaiyx.cn/pkg/webhook v0.0.0-20240314063906-8db8467590c4
)
require (
git.gz.internal.jumaiyx.cn/pkg/kubediscovery v0.0.0-20240514095004-cb5816f3b6ee // indirect
git.gz.internal.jumaiyx.cn/proto/game-server v0.0.0-20240423100311-c410de6080d6 // indirect
github.com/davecgh/go-spew v1.1.1 // 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.4.1 // 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.4 // 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/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.23.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.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.33.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.9 // indirect
k8s.io/apimachinery v0.28.9 // indirect
k8s.io/client-go v0.28.9 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240322212309-b815d8309940 // indirect
k8s.io/utils v0.0.0-20240310230437-4693a0247e57 // 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
)

22
hotspot-clear-job-dev.yaml

@ -0,0 +1,22 @@
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: message-clear-job
namespace: dev
spec:
# schedule: "*/5 * * * *" # 10分钟
schedule: "0 * * * *" # 一小时
jobTemplate:
spec:
template:
spec:
containers:
- name: message-clear
image: 192.168.1.131:8888/job/dev/message-clear:7d42712db2fa490b8763183fecb1c0e291b80f7a
env:
- name: JM_ENVIRONMENT
value: dev
imagePullPolicy: IfNotPresent
restartPolicy: OnFailure
imagePullSecrets:
- name: local-harbor

60
main.go

@ -0,0 +1,60 @@
package main
import (
"context"
livev1 "git.gz.internal.jumaiyx.cn/jm/jmproto/live/v1"
"git.gz.internal.jumaiyx.cn/pkg/client"
"git.gz.internal.jumaiyx.cn/pkg/jtime"
k8sclient "git.gz.internal.jumaiyx.cn/pkg/k8s-client/v2"
"git.gz.internal.jumaiyx.cn/pkg/webhook/wechat"
"strconv"
"time"
)
func main() {
start := time.Now().Unix()
err := task()
times := time.Now().Unix() - start
if times == 0 {
times = 1
}
wechatHook(times, err)
}
func task() error {
ctx := context.Background()
liveClient, liveClientClose, err := client.GetLiveClient(ctx)
if err != nil {
return err
}
defer func() { _ = liveClientClose() }()
_, err = liveClient.ClearMessage(ctx, &livev1.ClearMessageReq{
LtCreateTimes: jtime.SecondsAgoTime(time.Now(), -(86400 * 7)).Unix(),
})
if err != nil {
return err
}
return nil
}
func wechatHook(times int64, err error) {
if err == nil {
return
}
envi := "测试"
if k8sclient.Environment() == k8sclient.MasterNamespace {
envi = "正式"
}
hook := wechat.NewMarkdown("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=88967358-abc1-4e06-bac6-ec202f18875a").
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()
}
Loading…
Cancel
Save