chore(git): code staging

Signed-off-by: zhenyus <zhenyus@mathmast.com>
This commit is contained in:
zhenyus 2025-02-20 17:28:45 +08:00
parent 9923bc1ada
commit 4949fd40b0
55 changed files with 2723 additions and 111 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
*.tgz filter=lfs diff=lfs merge=lfs -text

View File

@ -47,6 +47,25 @@ def generateComponentStages(component, configurations) {
{stage("${component.name} :: Dependencies Resolving") {
podTemplate(
label: "dep-resolver-${component.name}",
yaml: """
apiVersion: v1
kind: Pod
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "node-role.kubernetes.io/devops"
operator: In
values: ["true"]
tolerations:
- key: "node-role.kubernetes.io/devops"
operator: Equal
value: "true"
effect: "NoSchedule"
""",
yamlMergeStrategy: "merge",
containers: [
containerTemplate(
name: 'dep-resolver',
@ -122,6 +141,25 @@ def generateComponentStages(component, configurations) {
{stage("${component.name} :: Code Linting") {
podTemplate(
label: "code-linter-${component.name}",
yaml: """
apiVersion: v1
kind: Pod
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "node-role.kubernetes.io/devops"
operator: In
values: ["true"]
tolerations:
- key: "node-role.kubernetes.io/devops"
operator: Equal
value: "true"
effect: "NoSchedule"
""",
yamlMergeStrategy: "merge",
containers: [
containerTemplate(
name: 'code-linter',
@ -207,6 +245,25 @@ def generateComponentStages(component, configurations) {
}
podTemplate(
label: "sast-scanner-${component.name}",
yaml: """
apiVersion: v1
kind: Pod
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "node-role.kubernetes.io/devops"
operator: In
values: ["true"]
tolerations:
- key: "node-role.kubernetes.io/devops"
operator: Equal
value: "true"
effect: "NoSchedule"
""",
yamlMergeStrategy: "merge",
containers: [
containerTemplate(
name: 'sast-scanner',
@ -247,6 +304,25 @@ def generateComponentStages(component, configurations) {
{stage("${component.name} :: Semantic Releasing") {
podTemplate(
label: "semantic-releasing-${component.name}",
yaml: """
apiVersion: v1
kind: Pod
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "node-role.kubernetes.io/devops"
operator: In
values: ["true"]
tolerations:
- key: "node-role.kubernetes.io/devops"
operator: Equal
value: "true"
effect: "NoSchedule"
""",
yamlMergeStrategy: "merge",
containers: [
containerTemplate(
name: 'semantic-releasing',
@ -289,6 +365,25 @@ def generateComponentStages(component, configurations) {
{stage("${component.name} :: Compilation & Packaging") {
podTemplate(
label: "build-agent-${component.name}",
yaml: """
apiVersion: v1
kind: Pod
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "node-role.kubernetes.io/devops"
operator: In
values: ["true"]
tolerations:
- key: "node-role.kubernetes.io/devops"
operator: Equal
value: "true"
effect: "NoSchedule"
""",
yamlMergeStrategy: "merge",
containers: [
containerTemplate(
name: 'build-agent',
@ -387,6 +482,25 @@ def generateComponentStages(component, configurations) {
{stage("${component.name} :: Image Building & Publishing") {
podTemplate(
label: "image-builder-${component.name}",
yaml: """
apiVersion: v1
kind: Pod
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "node-role.kubernetes.io/devops"
operator: In
values: ["true"]
tolerations:
- key: "node-role.kubernetes.io/devops"
operator: Equal
value: "true"
effect: "NoSchedule"
""",
yamlMergeStrategy: "merge",
containers: [
containerTemplate(
name: 'image-builder',
@ -457,6 +571,25 @@ def generateComponentStages(component, configurations) {
{stage("${component.name} :: Argo Application Version Updating") {
podTemplate(
label: "argo-app-version-updater-${component.name}",
yaml: """
apiVersion: v1
kind: Pod
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "node-role.kubernetes.io/devops"
operator: In
values: ["true"]
tolerations:
- key: "node-role.kubernetes.io/devops"
operator: Equal
value: "true"
effect: "NoSchedule"
""",
yamlMergeStrategy: "merge",
containers: [
containerTemplate(
name: "argo-app-version-updater",
@ -518,6 +651,19 @@ metadata:
labels:
freeleaps-devops-system/milestone: commit-message-linting
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "node-role.kubernetes.io/devops"
operator: In
values: ["true"]
tolerations:
- key: "node-role.kubernetes.io/devops"
operator: Equal
value: "true"
effect: "NoSchedule"
containers:
- name: commit-message-linter
image: docker.io/commitlint/commitlint:master

0
freeleaps/README.md Normal file
View File

View File

@ -0,0 +1,109 @@
library 'first-class-pipeline'
executeFreeleapsPipeline {
serviceName = 'freeleaps',
environmentSlug = 'alpha'
serviceGitBranch = 'develop'
serviceGitRepo = "https://freeleaps@dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub"
serviceGitRepoType = 'monorepo'
serviceGitCredentialsId = 'freeleaps-azure-devops-credentials'
executeMode = 'on-demand'
commitMessageLintEnabled = true
components = [
[
name: 'authentication',
root: 'apps/authentication',
language: 'python',
buildCacheEnabled: true,
buildAgentImage: 'python:3.10-slim-buster',
buildArtifacts: ['.'],
lintEnabled: false,
sastEnabled: false,
imageRegistry: 'docker.io',
imageRepository: 'freeleaps',
imageName: 'authentication',
imageBuilder: 'dind',
dockerfilePath: 'Dockerfile',
imageBuildRoot: '.',
imageReleaseArchitectures: ['linux/amd64', 'linux/arm64/v8'],
registryCredentialsId: 'freeleaps-devops-docker-hub-credentials',
semanticReleaseEnabled: true
],
[
name: 'central-storage',
root: 'apps/central_storage',
language: 'python',
buildAgentImage: 'python:3.10-slim-buster',
buildArtifacts: ['.'],
buildCacheEnabled: true,
lintEnabled: false,
sastEnabled: false,
imageRegistry: 'docker.io',
imageRepository: 'freeleaps',
imageName: 'central_storage',
imageBuilder: 'dind',
dockerfilePath: 'Dockerfile',
imageBuildRoot: '.',
imageReleaseArchitectures: ['linux/amd64', 'linux/arm64/v8'],
registryCredentialsId: 'freeleaps-devops-docker-hub-credentials',
semanticReleaseEnabled: true
],
[
name: 'content',
root: 'apps/content',
language: 'python',
buildAgentImage: 'python:3.10-slim-buster',
buildArtifacts: ['.'],
buildCacheEnabled: true,
lintEnabled: false,
sastEnabled: false,
imageRegistry: 'docker.io',
imageRepository: 'freeleaps',
imageName: 'content',
imageBuilder: 'dind',
dockerfilePath: 'Dockerfile',
imageBuildRoot: '.',
imageReleaseArchitectures: ['linux/amd64', 'linux/arm64/v8'],
registryCredentialsId: 'freeleaps-devops-docker-hub-credentials',
semanticReleaseEnabled: true
],
[
name: 'notification',
root: 'apps/notification',
language: 'python',
buildAgentImage: 'python:3.10-slim-buster',
buildArtifacts: ['.'],
buildCacheEnabled: true,
lintEnabled: false,
sastEnabled: false,
imageRegistry: 'docker.io',
imageRepository: 'freeleaps',
imageName: 'notification',
imageBuilder: 'dind',
dockerfilePath: 'Dockerfile',
imageBuildRoot: '.',
imageReleaseArchitectures: ['linux/amd64', 'linux/arm64/v8'],
registryCredentialsId: 'freeleaps-devops-docker-hub-credentials',
semanticReleaseEnabled: true
],
[
name: 'payment',
root: 'apps/payment',
language: 'python',
buildAgentImage: 'python:3.10-slim-buster',
buildArtifacts: ['.'],
buildCacheEnabled: true,
lintEnabled: false,
sastEnabled: false,
imageRegistry: 'docker.io',
imageRepository: 'freeleaps',
imageName: 'payment',
imageBuilder: 'dind',
dockerfilePath: 'Dockerfile',
imageBuildRoot: '.',
imageReleaseArchitectures: ['linux/amd64', 'linux/arm64/v8'],
registryCredentialsId: 'freeleaps-devops-docker-hub-credentials',
semanticReleaseEnabled: true
]
]
}

View File

View File

View File

@ -1 +0,0 @@
helm chart

View File

@ -1 +0,0 @@
helm chart

View File

@ -1 +0,0 @@
namespace should be freeleaps-service-hub-alpha

View File

@ -1,5 +0,0 @@
# Exclude Helm-specific files
.DS_Store
*.swp
*.bak
*.tmp

View File

@ -1,5 +0,0 @@
apiVersion: v2
name: mongodb-chart
description: A Helm chart for deploying MongoDB
version: 0.1.0
appVersion: "latest"

View File

@ -1,31 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongodb
namespace: {{ .Values.namespace }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: mongodb
template:
metadata:
labels:
app: mongodb
spec:
containers:
- name: mongodb
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
ports:
- containerPort: {{ .Values.containerPort }}
resources:
limits:
cpu: {{ .Values.resources.limits.cpu }}
memory: {{ .Values.resources.limits.memory }}
volumeMounts:
- mountPath: /data/db
name: mongodb-storage
volumes:
- name: mongodb-storage
persistentVolumeClaim:
claimName: mongodb-pvc

View File

@ -1,14 +0,0 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: mongodb-pv
namespace: {{ .Values.namespace }}
spec:
capacity:
storage: {{ .Values.persistence.size }}
accessModes:
- {{ .Values.persistence.accessMode }}
persistentVolumeReclaimPolicy: Retain
storageClassName: {{ .Values.persistence.storageClass }}
hostPath:
path: {{ .Values.persistence.hostPath }}

View File

@ -1,13 +0,0 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mongodb-pvc
namespace: {{ .Values.namespace }}
spec:
accessModes:
- {{ .Values.persistence.accessMode }}
resources:
requests:
storage: {{ .Values.persistence.size }}
storageClassName: {{ .Values.persistence.storageClass }}

View File

@ -1,12 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: mongodb-service
namespace: {{ .Values.namespace }}
spec:
selector:
app: mongodb
ports:
- protocol: TCP
port: {{ .Values.service.port }}
targetPort: {{ .Values.containerPort }}

View File

@ -1,18 +0,0 @@
namespace: freeleaps-alpha
replicaCount: 1
resources:
limits:
cpu: "1000m"
memory: "1Gi"
image:
repository: mongo
tag: latest
service:
port: 27017
containerPort: 27017
persistence:
enabled: true
storageClass: "local-storage"
accessMode: ReadWriteOnce
size: 10Gi
hostPath: "/mnt/mongodb-data" # Path on the nodes local disk

View File

@ -1 +0,0 @@
Alpha environment uses self-hosted dependencies such as mongodb, kafka, rabbitMQ etc. So we will have a one-off deployment for these components.

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c5509b91449bf47da80d01ea289bb62ad562fb5126fb32f116a3788819fdeef7
size 101425

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
apiVersion: v2
name: authentication
description: A Helm Chart of authentication, which part of Freeleaps Platgorm, powered by Freeleaps.
type: application
version: 0.0.1
appVersion: "0.0.1"

View File

@ -0,0 +1,72 @@
global:
registry: docker.io
repository: freeleaps
nodeSelector: {}
authentication:
replicas: 1
image:
registry:
repository: freeleaps
name: authentication
tag: 1.0.0
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8004
protocol: TCP
resources:
requests:
cpu: "0.5"
memory: "512Mi"
limits:
cpu: "1"
memory: "1Gi"
# FIXME: Wait until the developers implements the probes APIs
probes: {}
services:
- name: authentication-service
type: ClusterIP
port: 8004
targetPort: 8004
# Defaults to {}, which means doesn't have any ingress
ingresses:
- name: authentication-ingress
host: alpha.authentication.freeleaps.mathmast.com
class: nginx
rules:
- path: "/*"
pathType: ImplementationSpecific
backend:
service:
name: authentication-service
port:
number: 8004
tls:
exists: false
issuerRef:
name: mathmast-dot-com
kind: ClusterIssuer
name: alpha.authentication.freeleaps.mathmast.com-cert
configs:
# TZ
tz: "America/Settle"
# APP_NAME
appName: "authentication"
# DEVSVC_WEBAPI_URL_BASE
devsvcWebapiUrlBase: "http://devsvc.freeleaps-alpha.svc.freeleaps.cluster:8007/api/devsvc"
# NOTIFICATION_WEBAPI_URL_BASE
notificationWebapiUrlBase: "http://notification.svc.freeleaps-alpha.freeleaps.cluster:8003/api/notification"
# JWT_SECRET_KEY
jwtSecretKey: ""
# JWT_ALGORITHM
jwtAlgorithm: "HS256"
# SERVICE_API_ACCESS_HOST
serviceApiAccessHost: "0.0.0.0"
# SERVICE_API_ACCESS_PORT
serviceApiAccessPort: "8004"
# MONGODB_NAME
mongodbName: ""
# MONGODB_PORT
mongodbPort: "27017"
# MONGODB_URL
mongodbUrl: ""

View File

@ -0,0 +1,55 @@
global:
registry: docker.io
repository: freeleaps
nodeSelector: {}
authentication:
replicas: 1
image:
registry:
repository: freeleaps
name: authentication
tag: 1.0.0
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8004
protocol: TCP
resources:
requests:
cpu: "0.5"
memory: "512Mi"
limits:
cpu: "1"
memory: "1Gi"
# FIXME: Wait until the developers implements the probes APIs
probes: {}
services:
- name: authentication-service
type: ClusterIP
port: 8004
targetPort: 8004
# Defaults to {}, which means doesn't have any ingress
ingresses: {}
configs:
# TZ
tz: "America/Settle"
# APP_NAME
appName: "authentication"
# DEVSVC_WEBAPI_URL_BASE
devsvcWebapiUrlBase: "http://devsvc.<namespace>.svc.freeleaps.cluster:<service-port>/api/devsvc"
# NOTIFICATION_WEBAPI_URL_BASE
notificationWebapiUrlBase: "http://notification.svc.<namespace>.freeleaps.cluster:<service-port>/api/notification"
# JWT_SECRET_KEY
jwtSecretKey: ""
# JWT_ALGORITHM
jwtAlgorithm: "HS256"
# SERVICE_API_ACCESS_HOST
serviceApiAccessHost: "0.0.0.0"
# SERVICE_API_ACCESS_PORT
serviceApiAccessPort: "8004"
# MONGODB_NAME
mongodbName: ""
# MONGODB_PORT
mongodbPort: "27017"
# MONGODB_URL
mongodbUrl: ""

View File

56
freeleaps/layout Normal file
View File

@ -0,0 +1,56 @@
.
├── alpha
│   └── ci
│   ├── freeleaps2-devsvc
│   │   └── Jenkinsfile
│   ├── freeleaps2-frontend
│   │   └── Jenkinsfile
│   └── freeleaps-service-hub
│   └── Jenkinsfile
├── helm-pkg
│   ├── 3rd
│   │   ├── gitea
│   │   │   └── values.alpha.yaml
│   │   ├── kafka
│   │   │   └── values.alpha.yaml
│   │   ├── mongo
│   │   │   └── values.alpha.yaml
│   │   └── rabbitmq
│   │   └── values.alpha.yaml
│   ├── authentication
│   │   ├── values.alpha.yaml
│   │   └── values.prod.yaml
│   ├── central-storage
│   │   ├── values.alpha.yaml
│   │   └── values.prod.yaml
│   ├── chat
│   │   ├── values.alpha.yaml
│   │   └── values.prod.yaml
│   ├── content
│   │   ├── values.alpha.yaml
│   │   └── values.prod.yaml
│   ├── devsvc
│   │   ├── values.alpha.yaml
│   │   └── values.prod.yaml
│   ├── freeleaps
│   │   ├── values.alpha.yaml
│   │   └── values.prod.yaml
│   ├── frontend
│   │   ├── values.alpha.yaml
│   │   └── values.prod.yaml
│   ├── notification
│   │   ├── values.alpha.yaml
│   │   └── values.prod.yaml
│   └── payment
│   ├── values.alpha.yaml
│   └── values.prod.yaml
└── prod
└── ci
├── freeleaps2-devsvc
│   └── Jenkinsfile
├── freeleaps2-frontend
│   └── Jenkinsfile
└── freeleaps-service-hub
└── Jenkinsfile
26 directories, 30 files

View File

@ -0,0 +1,109 @@
library 'first-class-pipeline'
executeFreeleapsPipeline {
serviceName = 'freeleaps',
environmentSlug = 'prod'
serviceGitBranch = 'master'
serviceGitRepo = "https://freeleaps@dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub"
serviceGitRepoType = 'monorepo'
serviceGitCredentialsId = 'freeleaps-azure-devops-credentials'
executeMode = 'on-demand'
commitMessageLintEnabled = true
components = [
[
name: 'authentication',
root: 'apps/authentication',
language: 'python',
buildCacheEnabled: true,
buildAgentImage: 'python:3.10-slim-buster',
buildArtifacts: ['.'],
lintEnabled: false,
sastEnabled: false,
imageRegistry: 'docker.io',
imageRepository: 'freeleaps',
imageName: 'authentication',
imageBuilder: 'dind',
dockerfilePath: 'Dockerfile',
imageBuildRoot: '.',
imageReleaseArchitectures: ['linux/amd64', 'linux/arm64/v8'],
registryCredentialsId: 'freeleaps-devops-docker-hub-credentials',
semanticReleaseEnabled: true
],
[
name: 'central-storage',
root: 'apps/central_storage',
language: 'python',
buildAgentImage: 'python:3.10-slim-buster',
buildArtifacts: ['.'],
buildCacheEnabled: true,
lintEnabled: false,
sastEnabled: false,
imageRegistry: 'docker.io',
imageRepository: 'freeleaps',
imageName: 'central_storage',
imageBuilder: 'dind',
dockerfilePath: 'Dockerfile',
imageBuildRoot: '.',
imageReleaseArchitectures: ['linux/amd64', 'linux/arm64/v8'],
registryCredentialsId: 'freeleaps-devops-docker-hub-credentials',
semanticReleaseEnabled: true
],
[
name: 'content',
root: 'apps/content',
language: 'python',
buildAgentImage: 'python:3.10-slim-buster',
buildArtifacts: ['.'],
buildCacheEnabled: true,
lintEnabled: false,
sastEnabled: false,
imageRegistry: 'docker.io',
imageRepository: 'freeleaps',
imageName: 'content',
imageBuilder: 'dind',
dockerfilePath: 'Dockerfile',
imageBuildRoot: '.',
imageReleaseArchitectures: ['linux/amd64', 'linux/arm64/v8'],
registryCredentialsId: 'freeleaps-devops-docker-hub-credentials',
semanticReleaseEnabled: true
],
[
name: 'notification',
root: 'apps/notification',
language: 'python',
buildAgentImage: 'python:3.10-slim-buster',
buildArtifacts: ['.'],
buildCacheEnabled: true,
lintEnabled: false,
sastEnabled: false,
imageRegistry: 'docker.io',
imageRepository: 'freeleaps',
imageName: 'notification',
imageBuilder: 'dind',
dockerfilePath: 'Dockerfile',
imageBuildRoot: '.',
imageReleaseArchitectures: ['linux/amd64', 'linux/arm64/v8'],
registryCredentialsId: 'freeleaps-devops-docker-hub-credentials',
semanticReleaseEnabled: true
],
[
name: 'payment',
root: 'apps/payment',
language: 'python',
buildAgentImage: 'python:3.10-slim-buster',
buildArtifacts: ['.'],
buildCacheEnabled: true,
lintEnabled: false,
sastEnabled: false,
imageRegistry: 'docker.io',
imageRepository: 'freeleaps',
imageName: 'payment',
imageBuilder: 'dind',
dockerfilePath: 'Dockerfile',
imageBuildRoot: '.',
imageReleaseArchitectures: ['linux/amd64', 'linux/arm64/v8'],
registryCredentialsId: 'freeleaps-devops-docker-hub-credentials',
semanticReleaseEnabled: true
]
]
}

View File

View File

View File

@ -1 +0,0 @@
helm chart

View File

@ -1 +0,0 @@
helm chart

View File

@ -1 +0,0 @@
namespace should be freeleaps-service-hub-prod