From 3f519c231fdf697b26d81c214a3f7ae98fef6b81 Mon Sep 17 00:00:00 2001 From: rdc_qa <1qaz@WSX> Date: Tue, 22 Mar 2022 22:39:07 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A7=81=E5=BA=93docke?= =?UTF-8?q?r=20hub=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- K8sJenkinsFile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/K8sJenkinsFile b/K8sJenkinsFile index 3eab6e2..00bc971 100644 --- a/K8sJenkinsFile +++ b/K8sJenkinsFile @@ -13,6 +13,9 @@ pipeline { // 直接上k8s,用k8s来管理docker ) } environment { + // 自建镜像仓库地址 + docker_hub = "k8s-harbor:30002" + // 自建harbor仓库的namespace docker_hub_namespace = "tmall" -- Gitee From 9bfb7772afe74d9cc20006cc368ddcae0165e73f Mon Sep 17 00:00:00 2001 From: rdc_qa <1qaz@WSX> Date: Tue, 22 Mar 2022 22:50:30 +0800 Subject: [PATCH 02/13] =?UTF-8?q?Dockerfile=E5=B0=91=E5=8A=A0=E4=BA=86--?= =?UTF-8?q?=EF=BC=8C=E5=AF=BC=E8=87=B4=E6=97=A0=E6=B3=95=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 023aac2..040882c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM openjdk:8-jdk LABEL maintainer=xtaylkss@163.com -ENV PARAMS="--server.port=8080 spring.datasource.url=dbc:mysql://mysql.infrastructure:3306/tmalldemodb?characterEncoding=utf-8&useSSL=false" +ENV PARAMS="--server.port=8080 --spring.datasource.url=dbc:mysql://mysql.infrastructure:3306/tmalldemodb?characterEncoding=utf-8&useSSL=false" RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone COPY target/*.jar /app.jar EXPOSE 8080 -- Gitee From 415833f4e0ce62c76c24c747d16f38e3e0355692 Mon Sep 17 00:00:00 2001 From: rdc_qa <1qaz@WSX> Date: Tue, 22 Mar 2022 22:55:55 +0800 Subject: [PATCH 03/13] =?UTF-8?q?Dockerfile=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 040882c..86b9bd2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM openjdk:8-jdk LABEL maintainer=xtaylkss@163.com -ENV PARAMS="--server.port=8080 --spring.datasource.url=dbc:mysql://mysql.infrastructure:3306/tmalldemodb?characterEncoding=utf-8&useSSL=false" +ENV PARAMS="--server.port=8080 --spring.datasource.url=jdbc:mysql://mysql.infrastructure:3306/tmalldemodb?characterEncoding=utf-8&useSSL=false" RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone COPY target/*.jar /app.jar EXPOSE 8080 -- Gitee From 9d0458dbb8f9bfe3b9a556dda001363a52eda7e3 Mon Sep 17 00:00:00 2001 From: rdc_qa <1qaz@WSX> Date: Tue, 22 Mar 2022 23:23:28 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E8=BF=9E=E6=8E=A5=E7=94=A8=E6=88=B7=E5=90=8D=E5=8F=8A?= =?UTF-8?q?=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 5d8a0cd..e3e9cde 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -5,7 +5,7 @@ server.port=8080 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/tmalldemodb?characterEncoding=utf-8&useSSL=false spring.datasource.username=root -spring.datasource.password=root +spring.datasource.password=123456.h #配置编码 server.servlet.encoding.charset=UTF-8 -- Gitee From 6085e550ce2f5dd1f6d2c945df3815076102671d Mon Sep 17 00:00:00 2001 From: rdc_qa <1qaz@WSX> Date: Wed, 23 Mar 2022 14:22:29 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E4=BD=BF=E7=94=A8param=E6=8E=A7=E5=88=B6?= =?UTF-8?q?application=E9=87=8C=E9=9D=A2=E7=9A=84=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 86b9bd2..4af8909 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM openjdk:8-jdk LABEL maintainer=xtaylkss@163.com -ENV PARAMS="--server.port=8080 --spring.datasource.url=jdbc:mysql://mysql.infrastructure:3306/tmalldemodb?characterEncoding=utf-8&useSSL=false" +ENV PARAMS="--server.port=8080 --spring.datasource.password=123456.h --spring.datasource.url=jdbc:mysql://mysql.infrastructure:3306/tmalldemodb?characterEncoding=utf-8&useSSL=false" RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone COPY target/*.jar /app.jar EXPOSE 8080 -- Gitee From 8f70604c4eaf9cb6ec55e2709dee41a239839cbc Mon Sep 17 00:00:00 2001 From: rdc_qa <1qaz@WSX> Date: Wed, 23 Mar 2022 14:23:38 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E8=BF=98=E5=8E=9Fapplication.propertity?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index e3e9cde..5d8a0cd 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -5,7 +5,7 @@ server.port=8080 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/tmalldemodb?characterEncoding=utf-8&useSSL=false spring.datasource.username=root -spring.datasource.password=123456.h +spring.datasource.password=root #配置编码 server.servlet.encoding.charset=UTF-8 -- Gitee From 3b70cd5e4d3ff4f79b5668007b178c595ed93142 Mon Sep 17 00:00:00 2001 From: rdc_qa <1qaz@WSX> Date: Wed, 23 Mar 2022 15:13:18 +0800 Subject: [PATCH 07/13] =?UTF-8?q?ci:=20=E8=A7=A3=E5=86=B3=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=87=BA=E7=8E=B0=E9=A6=96=E9=A1=B5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pom.xml b/pom.xml index 4278e31..d027d81 100644 --- a/pom.xml +++ b/pom.xml @@ -124,12 +124,16 @@ src/main/webapp META-INF/resources false + + **/** + org.springframework.boot spring-boot-maven-plugin + 1.4.2.RELEASE -- Gitee From 52797a5b98e6d35c54dae1d4e3bbb0d9cf1b8cc2 Mon Sep 17 00:00:00 2001 From: rdc_qa <1qaz@WSX> Date: Wed, 23 Mar 2022 15:30:11 +0800 Subject: [PATCH 08/13] deploy.yaml init --- deploy.yaml | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 deploy.yaml diff --git a/deploy.yaml b/deploy.yaml new file mode 100644 index 0000000..c970b4f --- /dev/null +++ b/deploy.yaml @@ -0,0 +1,101 @@ +#apiVersion: v1 +#kind: PersistentVolumeClaim +#metadata: +# namespace: youlai-mall +# name: tmall-pvc0 +# labels: {} +#spec: +# accessModes: +# - ReadWriteOnce +# resources: +# requests: +# storage: 1Gi # k8s限制,只能扩容,对于pvc,只能扩容,不能缩容,且配置sc.yaml时需要指定allowVolumeExpansion: true #增加该字段表示允许动态扩容 +# storageClassName: nfs-storage +# +#--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: tmall + name: tmall-deployment + namespace: ${k8s_namespace} #一定要写名称空间 +spec: + progressDeadlineSeconds: 600 + replicas: 1 + selector: + matchLabels: + app: tmall + strategy: # 更新策略 + rollingUpdate: + maxSurge: 50% + maxUnavailable: 50% + type: RollingUpdate + template: + metadata: + labels: + app: tmall + spec: + volumes: # 挂载卷 + - name: host-time # 挂载主机上的时区 + hostPath: + path: /etc/localtime + type: '' + # - name: volume-tmall # 挂载日志 + # persistentVolumeClaim: + # claimName: tmall-pvc0 + imagePullSecrets: + - name: ${docker_hub_id} #提前在项目下配置访问阿里云或harbor的账号密码 + containers: + - image: $remote_tag + imagePullPolicy: Always + name: tmall + ports: + - name: http-8080 + containerPort: 8080 + protocol: TCP + resources: # 资源限制 + limits: + cpu: 250m + memory: 512Mi + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - name: host-time + readOnly: true + mountPath: /etc/localtime + # - name: volume-tmall + # mountPath: /logs + + dnsPolicy: ClusterFirst + restartPolicy: Always + terminationGracePeriodSeconds: 30 + affinity: # 节点亲合性,这下面表达的意思是,尽量散到不同的机器上 + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchLabels: + app: tmall + topologyKey: kubernetes.io/hostname + revisionHistoryLimit: 2 #deploy 升级最大记录数由 revisionHistoryLimit 定义,默认值为 10 +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: tmall + name: tmall-svc + namespace: ${k8s_namespace} +spec: + ports: + - name: http + port: 8080 + protocol: TCP + targetPort: 8080 + selector: + app: tmall + sessionAffinity: None + type: NodePort + -- Gitee From 559765b8c8f536a7daed4bffac005284ffee55c1 Mon Sep 17 00:00:00 2001 From: rdc_qa <1qaz@WSX> Date: Wed, 23 Mar 2022 15:34:39 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E6=94=B9=E4=B8=BAjar=E5=8C=85=E9=83=A8?= =?UTF-8?q?=E7=BD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 13a60c5..d027d81 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.xq.tmall tmall 1.0-SNAPSHOT - war + jar tmall Maven Webapp http://maven.aliyun.com/nexus/content/groups/public/ -- Gitee From c851095f171840acdca191c615c989304d90871e Mon Sep 17 00:00:00 2001 From: rdc_qa <1qaz@WSX> Date: Wed, 23 Mar 2022 15:58:17 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E6=B7=BB=E5=8A=A0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 89a21ac..d236fe7 100644 --- a/README.md +++ b/README.md @@ -64,4 +64,13 @@ 支付宝打赏二维码 + ##### 微信 -微信打赏二维码 \ No newline at end of file +微信打赏二维码 + +### 关于拓展 +近期本项目通过改造,将原来war部署方式改成了jar部署,进入到target目录,仅需要java -jar tmall.jar即可完成部署启动。 +另本项目已使用当前较为流利的CICD方式,jenkins+k8s进行持续构建、部署,涉及文件:Dockerfile,K8sJenkinsFile及deploy.yaml +Dockerfile:大概作用是依据基础的jdk镜像,添加上自己本身的jar包,打成镜像包 +K8sJenkinsFile:大概作用是把生成jar包、部署jar包流程自动化 +deploy.yaml:此文件为k8s deployment svc资源模板化文件 +具体情况可联系以下同学(加他时请备注"贤趣CICD"): +CICD同学 -- Gitee From 6f3eb641f88a4a9786042e0318b62dce434108b3 Mon Sep 17 00:00:00 2001 From: rdc_qa <1qaz@WSX> Date: Wed, 23 Mar 2022 16:00:09 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d236fe7..c6beae1 100644 --- a/README.md +++ b/README.md @@ -73,4 +73,5 @@ Dockerfile:大概作用是依据基础的jdk镜像,添加上自己本身的jar K8sJenkinsFile:大概作用是把生成jar包、部署jar包流程自动化 deploy.yaml:此文件为k8s deployment svc资源模板化文件 具体情况可联系以下同学(加他时请备注"贤趣CICD"): ++ ##### 贤趣CICD同学微信 CICD同学 -- Gitee From 15fdf5371dea683d257b481bd251c0ca4eac8422 Mon Sep 17 00:00:00 2001 From: rdc_qa <1qaz@WSX> Date: Wed, 23 Mar 2022 16:01:38 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index c6beae1..76bf8d2 100644 --- a/README.md +++ b/README.md @@ -68,10 +68,15 @@ ### 关于拓展 近期本项目通过改造,将原来war部署方式改成了jar部署,进入到target目录,仅需要java -jar tmall.jar即可完成部署启动。 + 另本项目已使用当前较为流利的CICD方式,jenkins+k8s进行持续构建、部署,涉及文件:Dockerfile,K8sJenkinsFile及deploy.yaml + Dockerfile:大概作用是依据基础的jdk镜像,添加上自己本身的jar包,打成镜像包 + K8sJenkinsFile:大概作用是把生成jar包、部署jar包流程自动化 + deploy.yaml:此文件为k8s deployment svc资源模板化文件 + 具体情况可联系以下同学(加他时请备注"贤趣CICD"): + ##### 贤趣CICD同学微信 CICD同学 -- Gitee From fbfc5626a70ce2fbfb4a74d15ed22ba5ed7c304d Mon Sep 17 00:00:00 2001 From: rdc_qa <1qaz@WSX> Date: Wed, 23 Mar 2022 16:04:30 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 76bf8d2..93f56b2 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,11 @@ K8sJenkinsFile:大概作用是把生成jar包、部署jar包流程自动化 deploy.yaml:此文件为k8s deployment svc资源模板化文件 +k8s部署的项目访问网址: + ++ 前台地址:http://tmall.howlaisi.com:31253/tmall ++ 后台地址:http://tmall.howlaisi.com:31253/tmall/admin + 具体情况可联系以下同学(加他时请备注"贤趣CICD"): + ##### 贤趣CICD同学微信 CICD同学 -- Gitee