diff --git a/.gitignore b/.gitignore index 6c01878..069d925 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,7 @@ out/ ### VS Code ### .vscode/ + +### MAC File ### +.DS_Store + diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 08a9463..2b9799a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,6 +23,210 @@ include: file: '.gitlab-ci-template.yml' ref: 'master' -code_quality: - artifacts: - paths: [gl-code-quality-report.json] +#k8s部署脚本模板 +.k8s-deploy-template: &k8s_deploy_definition + image: lachlanevenson/k8s-kubectl:latest + script: | + if [[ "${BUILD_ENV}" != "node" && "${BUILD_ENV}" != "package" ]]; then export port=8080; else export port=80; fi + + cat >> deployment.yaml <> deployment.yaml <> deployment.yaml << EOF + spec: + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: hanlin.arch/enviroment + operator: Exists + - key: hanlin.arch/enviroment-scope.st + operator: Exists + EOF + else + cat >> deployment.yaml << EOF + spec: + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: hanlin.arch/enviroment + operator: Exists + - key: hanlin.arch/enviroment-scope.test + operator: Exists + - matchExpressions: + - key: hanlin.arch/enviroment + operator: Exists + - key: hanlin.arch/enviroment-scope.review + operator: Exists + EOF + fi + + cat >> deployment.yaml <> deployment.yaml << EOF + resources: + limits: + memory: "4Gi" + cpu: "2000m" + requests: + memory: "1Gi" + cpu: "500m" + EOF + else + cat >> deployment.yaml << EOF + resources: + limits: + memory: "2Gi" + cpu: "1000m" + requests: + memory: "512Mi" + cpu: "50m" + EOF + fi + + if [[ $(echo "${CI_ENVIRONMENT_SLUG%%-*}") != "st" && "${BUILD_ENV}" != "node" && "${BUILD_ENV}" != "package" ]]; then + cat >> deployment.yaml <> deployment.yaml <> deployment.yaml <> deployment.sh <