├── .gitignore ├── .s2i └── environment ├── Dockerfile-online ├── Jenkinsfile-online ├── LICENSE ├── OWNERS ├── README.md ├── README_zh.md ├── deploy ├── all-in-one │ └── devops-sample.yaml ├── dev-all-in-one │ └── devops-sample.yaml ├── dev-ol │ ├── devops-sample-svc.yaml │ └── devops-sample.yaml ├── dev │ ├── devops-sample-svc.yaml │ └── devops-sample.yaml ├── no-branch-dev │ ├── devops-sample-svc.yaml │ └── devops-sample.yaml ├── prod-all-in-one │ └── devops-sample.yaml ├── prod-ol │ ├── devops-sample-svc.yaml │ └── devops-sample.yaml └── prod │ ├── devops-sample-svc.yaml │ └── devops-sample.yaml ├── pom.xml └── src ├── main └── java │ └── io │ └── kubesphere │ └── devops │ ├── Application.java │ └── HelloWorldController.java └── test └── java └── io └── kubesphere └── devops └── HelloWorldControllerTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | .project 3 | .settings/* 4 | .classpath 5 | target/* 6 | 7 | *.iml -------------------------------------------------------------------------------- /.s2i/environment: -------------------------------------------------------------------------------- 1 | S2I_DESTINATION=/tmp 2 | DISABLE_ARTIFACTS=true 3 | -------------------------------------------------------------------------------- /Dockerfile-online: -------------------------------------------------------------------------------- 1 | FROM java:8u92-jre-alpine 2 | 3 | WORKDIR /home 4 | 5 | COPY target/*.jar /home 6 | 7 | ENTRYPOINT java -jar *.jar 8 | -------------------------------------------------------------------------------- /Jenkinsfile-online: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | node { 4 | label 'maven' 5 | } 6 | } 7 | 8 | parameters { 9 | string(name:'TAG_NAME',defaultValue: '',description:'') 10 | } 11 | 12 | environment { 13 | DOCKER_CREDENTIAL_ID = 'dockerhub-id' 14 | GITHUB_CREDENTIAL_ID = 'github-id' 15 | KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig' 16 | REGISTRY = 'docker.io' 17 | DOCKERHUB_NAMESPACE = 'docker_username' 18 | GITHUB_ACCOUNT = 'kubesphere' 19 | APP_NAME = 'devops-maven-sample' 20 | } 21 | 22 | stages { 23 | stage ('checkout scm') { 24 | steps { 25 | checkout(scm) 26 | } 27 | } 28 | 29 | stage ('unit test') { 30 | steps { 31 | container ('maven') { 32 | sh 'mvn clean test' 33 | } 34 | } 35 | } 36 | 37 | stage ('build & push') { 38 | steps { 39 | container ('maven') { 40 | sh 'mvn clean package -DskipTests' 41 | sh 'docker build -f Dockerfile-online -t $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER .' 42 | withCredentials([usernamePassword(passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,credentialsId : "$DOCKER_CREDENTIAL_ID" ,)]) { 43 | sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin' 44 | sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER' 45 | } 46 | } 47 | } 48 | } 49 | 50 | stage('push latest'){ 51 | when{ 52 | branch 'master' 53 | } 54 | steps{ 55 | container ('maven') { 56 | sh 'docker tag $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest ' 57 | sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest ' 58 | } 59 | } 60 | } 61 | 62 | stage('deploy to dev') { 63 | when{ 64 | branch 'master' 65 | } 66 | steps { 67 | input(id: 'deploy-to-dev', message: 'deploy to dev?') 68 | container ('maven') { 69 | withCredentials([ 70 | kubeconfigFile( 71 | credentialsId: env.KUBECONFIG_CREDENTIAL_ID, 72 | variable: 'KUBECONFIG') 73 | ]) { 74 | sh 'envsubst < deploy/dev-all-in-one/devops-sample.yaml | kubectl apply -f -' 75 | } 76 | } 77 | } 78 | } 79 | stage('push with tag'){ 80 | when{ 81 | expression{ 82 | return params.TAG_NAME =~ /v.*/ 83 | } 84 | } 85 | steps { 86 | container ('maven') { 87 | input(id: 'release-image-with-tag', message: 'release image with tag?') 88 | withCredentials([usernamePassword(credentialsId: "$GITHUB_CREDENTIAL_ID", passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) { 89 | sh 'git config --global user.email "kubesphere@yunify.com" ' 90 | sh 'git config --global user.name "kubesphere" ' 91 | sh 'git tag -a $TAG_NAME -m "$TAG_NAME" ' 92 | sh 'git push http://$GIT_USERNAME:$GIT_PASSWORD@github.com/$GITHUB_ACCOUNT/devops-maven-sample.git --tags --ipv4' 93 | } 94 | sh 'docker tag $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME ' 95 | sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME ' 96 | } 97 | } 98 | } 99 | stage('deploy to production') { 100 | when{ 101 | expression{ 102 | return params.TAG_NAME =~ /v.*/ 103 | } 104 | } 105 | steps { 106 | input(id: 'deploy-to-production', message: 'deploy to production?') 107 | container ('maven') { 108 | withCredentials([ 109 | kubeconfigFile( 110 | credentialsId: env.KUBECONFIG_CREDENTIAL_ID, 111 | variable: 'KUBECONFIG') 112 | ]) { 113 | sh 'envsubst < deploy/prod-all-in-one/devops-sample.yaml | kubectl apply -f -' 114 | } 115 | } 116 | } 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | approvers: 2 | - zheng1 3 | - yudong2015 4 | - stoneshi-yunify 5 | 6 | reviewers: 7 | - zheng1 8 | - yudong2015 9 | - stoneshi-yunify 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Repo Introduction 2 | 3 | > English | [中文](README_zh.md) 4 | 5 | KubeSphere provides a Jenkins-based DevOps system [with various features](https://kubesphere.io/docs/devops-user-guide/understand-and-manage-devops-projects/overview/#features). This repository is used for a SpringBoot demo for DevOps on KubeSphere. For example, you can find a file of `Jenkinsfile-online` in the root directory, and you can use it to create a pipeline through the **Jenkinsfile in SCM** method. 6 | 7 | For more information about how to use the KubeSphere DevOps system, you can refer to the following list of KubeSphere official documents. 8 | 9 | ## Document List 10 | 11 | - [Create a Pipeline Using a Jenkinsfile](https://kubesphere.io/docs/devops-user-guide/how-to-use/create-a-pipeline-using-jenkinsfile/) 12 | - [Create a Pipeline Using Graphical Editing Panels](https://kubesphere.io/docs/devops-user-guide/how-to-use/create-a-pipeline-using-graphical-editing-panel/) 13 | - [Build and Deploy a Maven Project](https://kubesphere.io/docs/devops-user-guide/examples/a-maven-project/) 14 | - [Source to Image: Publish an App without a Dockerfile](https://kubesphere.io/docs/project-user-guide/image-builder/source-to-image/) 15 | 16 | -------------------------------------------------------------------------------- /README_zh.md: -------------------------------------------------------------------------------- 1 | ## 仓库简介 2 | 3 | > [English](README.md) | 中文 4 | 5 | KubeSphere 基于 Jenkins 提供的 DevOps 系统可以实现[多种功能](https://kubesphere.io/zh/docs/devops-user-guide/understand-and-manage-devops-projects/overview/#功能)。本仓库用来演示基于 SpringBoot 的 KubeSphere DevOps 功能。例如,您可以在根目录中找到 `Jenkinsfile-online` 文件,并将该文件用作 **SCM 中的 Jenkinsfile** 来创建流水线。 6 | 7 | 有关如何使用 KubeSphere DevOps 系统的更多信息,您可以参考下方的 KubeSphere 官方文档清单。 8 | 9 | ## 文档清单 10 | 11 | - [使用 Jenkinsfile 创建流水线](https://kubesphere.io/zh/docs/devops-user-guide/how-to-use/create-a-pipeline-using-jenkinsfile/) 12 | - [使用图形编辑面板创建流水线](https://kubesphere.io/zh/docs/devops-user-guide/how-to-use/create-a-pipeline-using-graphical-editing-panel/) 13 | - [构建和部署 Maven 工程](https://kubesphere.io/zh/docs/devops-user-guide/examples/a-maven-project/) 14 | - [Source to Image:无需 Dockerfile 发布应用](https://kubesphere.io/zh/docs/project-user-guide/image-builder/source-to-image/) 15 | 16 | -------------------------------------------------------------------------------- /deploy/all-in-one/devops-sample.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | labels: 6 | app: kubesphere 7 | component: ks-sample-dev 8 | tier: backend 9 | name: ks-sample-dev 10 | namespace: $PROJECT_NAME 11 | spec: 12 | progressDeadlineSeconds: 600 13 | replicas: 1 14 | selector: 15 | matchLabels: 16 | app: kubesphere 17 | component: ks-sample-dev 18 | tier: backend 19 | template: 20 | metadata: 21 | labels: 22 | app: kubesphere 23 | component: ks-sample-dev 24 | tier: backend 25 | spec: 26 | containers: 27 | - env: 28 | - name: CACHE_IGNORE 29 | value: js|html 30 | - name: CACHE_PUBLIC_EXPIRATION 31 | value: 3d 32 | image: $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER 33 | readinessProbe: 34 | httpGet: 35 | path: / 36 | port: 8080 37 | timeoutSeconds: 10 38 | failureThreshold: 30 39 | periodSeconds: 5 40 | imagePullPolicy: Always 41 | name: ks-sample 42 | ports: 43 | - containerPort: 8080 44 | protocol: TCP 45 | resources: 46 | limits: 47 | cpu: 300m 48 | memory: 600Mi 49 | requests: 50 | cpu: 100m 51 | memory: 100Mi 52 | terminationMessagePath: /dev/termination-log 53 | terminationMessagePolicy: File 54 | dnsPolicy: ClusterFirst 55 | restartPolicy: Always 56 | terminationGracePeriodSeconds: 30 57 | 58 | --- 59 | apiVersion: v1 60 | kind: Service 61 | metadata: 62 | labels: 63 | app: kubesphere 64 | component: ks-sample-dev 65 | name: ks-sample-dev 66 | namespace: $PROJECT_NAME 67 | spec: 68 | ports: 69 | - name: http 70 | port: 8080 71 | protocol: TCP 72 | targetPort: 8080 73 | nodePort: 30861 74 | selector: 75 | app: kubesphere 76 | component: ks-sample-dev 77 | tier: backend 78 | sessionAffinity: None 79 | type: NodePort 80 | -------------------------------------------------------------------------------- /deploy/dev-all-in-one/devops-sample.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | labels: 6 | app: kubesphere 7 | component: ks-sample-dev 8 | tier: backend 9 | name: ks-sample-dev 10 | namespace: kubesphere-sample-dev 11 | spec: 12 | progressDeadlineSeconds: 600 13 | replicas: 1 14 | selector: 15 | matchLabels: 16 | app: kubesphere 17 | component: ks-sample-dev 18 | tier: backend 19 | template: 20 | metadata: 21 | labels: 22 | app: kubesphere 23 | component: ks-sample-dev 24 | tier: backend 25 | spec: 26 | containers: 27 | - env: 28 | - name: CACHE_IGNORE 29 | value: js|html 30 | - name: CACHE_PUBLIC_EXPIRATION 31 | value: 3d 32 | image: $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER 33 | readinessProbe: 34 | httpGet: 35 | path: / 36 | port: 8080 37 | timeoutSeconds: 10 38 | failureThreshold: 30 39 | periodSeconds: 5 40 | imagePullPolicy: Always 41 | name: ks-sample 42 | ports: 43 | - containerPort: 8080 44 | protocol: TCP 45 | resources: 46 | limits: 47 | cpu: 300m 48 | memory: 600Mi 49 | requests: 50 | cpu: 100m 51 | memory: 100Mi 52 | terminationMessagePath: /dev/termination-log 53 | terminationMessagePolicy: File 54 | dnsPolicy: ClusterFirst 55 | restartPolicy: Always 56 | terminationGracePeriodSeconds: 30 57 | --- 58 | apiVersion: v1 59 | kind: Service 60 | metadata: 61 | labels: 62 | app: kubesphere 63 | component: ks-sample-dev 64 | name: ks-sample-dev 65 | namespace: kubesphere-sample-dev 66 | spec: 67 | ports: 68 | - name: http 69 | port: 8080 70 | protocol: TCP 71 | targetPort: 8080 72 | nodePort: 30861 73 | selector: 74 | app: kubesphere 75 | component: ks-sample-dev 76 | tier: backend 77 | sessionAffinity: None 78 | type: NodePort 79 | -------------------------------------------------------------------------------- /deploy/dev-ol/devops-sample-svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | app: kubesphere 6 | component: ks-sample-dev 7 | name: ks-sample-dev 8 | namespace: kubesphere-sample-dev 9 | spec: 10 | ports: 11 | - name: http 12 | port: 8080 13 | protocol: TCP 14 | targetPort: 8080 15 | nodePort: 30861 16 | selector: 17 | app: kubesphere 18 | component: ks-sample-dev 19 | tier: backend 20 | sessionAffinity: None 21 | type: NodePort -------------------------------------------------------------------------------- /deploy/dev-ol/devops-sample.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | labels: 5 | app: kubesphere 6 | component: ks-sample-dev 7 | tier: backend 8 | name: ks-sample-dev 9 | namespace: kubesphere-sample-dev 10 | spec: 11 | progressDeadlineSeconds: 600 12 | replicas: 1 13 | selector: 14 | matchLabels: 15 | app: kubesphere 16 | component: ks-sample-dev 17 | tier: backend 18 | template: 19 | metadata: 20 | labels: 21 | app: kubesphere 22 | component: ks-sample-dev 23 | tier: backend 24 | spec: 25 | containers: 26 | - env: 27 | - name: CACHE_IGNORE 28 | value: js|html 29 | - name: CACHE_PUBLIC_EXPIRATION 30 | value: 3d 31 | image: $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER 32 | readinessProbe: 33 | httpGet: 34 | path: / 35 | port: 8080 36 | timeoutSeconds: 10 37 | failureThreshold: 30 38 | periodSeconds: 5 39 | imagePullPolicy: Always 40 | name: ks-sample 41 | ports: 42 | - containerPort: 8080 43 | protocol: TCP 44 | resources: 45 | limits: 46 | cpu: 300m 47 | memory: 600Mi 48 | requests: 49 | cpu: 100m 50 | memory: 100Mi 51 | terminationMessagePath: /dev/termination-log 52 | terminationMessagePolicy: File 53 | dnsPolicy: ClusterFirst 54 | restartPolicy: Always 55 | terminationGracePeriodSeconds: 30 56 | -------------------------------------------------------------------------------- /deploy/dev/devops-sample-svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | app: kubesphere 6 | component: ks-sample-dev 7 | name: ks-sample-dev 8 | namespace: kubesphere-sample-dev 9 | spec: 10 | ports: 11 | - name: http 12 | port: 8080 13 | protocol: TCP 14 | targetPort: 8080 15 | nodePort: 30861 16 | selector: 17 | app: kubesphere 18 | component: ks-sample-dev 19 | tier: backend 20 | sessionAffinity: None 21 | type: NodePort -------------------------------------------------------------------------------- /deploy/dev/devops-sample.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | labels: 5 | app: kubesphere 6 | component: ks-sample-dev 7 | tier: backend 8 | name: ks-sample-dev 9 | namespace: kubesphere-sample-dev 10 | spec: 11 | progressDeadlineSeconds: 600 12 | replicas: 1 13 | selector: 14 | matchLabels: 15 | app: kubesphere 16 | component: ks-sample-dev 17 | tier: backend 18 | template: 19 | metadata: 20 | labels: 21 | app: kubesphere 22 | component: ks-sample-dev 23 | tier: backend 24 | spec: 25 | containers: 26 | - env: 27 | - name: CACHE_IGNORE 28 | value: js|html 29 | - name: CACHE_PUBLIC_EXPIRATION 30 | value: 3d 31 | image: $REGISTRY/$HARBOR_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER 32 | readinessProbe: 33 | httpGet: 34 | path: / 35 | port: 8080 36 | timeoutSeconds: 10 37 | failureThreshold: 30 38 | periodSeconds: 5 39 | imagePullPolicy: Always 40 | name: ks-sample 41 | ports: 42 | - containerPort: 8080 43 | protocol: TCP 44 | resources: 45 | limits: 46 | cpu: 300m 47 | memory: 600Mi 48 | requests: 49 | cpu: 100m 50 | memory: 100Mi 51 | terminationMessagePath: /dev/termination-log 52 | terminationMessagePolicy: File 53 | dnsPolicy: ClusterFirst 54 | restartPolicy: Always 55 | terminationGracePeriodSeconds: 30 -------------------------------------------------------------------------------- /deploy/no-branch-dev/devops-sample-svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | app: kubesphere 6 | component: ks-sample-dev 7 | name: ks-sample-dev 8 | namespace: kubesphere-sample-dev 9 | spec: 10 | ports: 11 | - name: http 12 | port: 8080 13 | protocol: TCP 14 | targetPort: 8080 15 | nodePort: 30861 16 | selector: 17 | app: kubesphere 18 | component: ks-sample-dev 19 | tier: backend 20 | sessionAffinity: None 21 | type: NodePort -------------------------------------------------------------------------------- /deploy/no-branch-dev/devops-sample.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | labels: 5 | app: kubesphere 6 | component: ks-sample-dev 7 | tier: backend 8 | name: ks-sample-dev 9 | namespace: kubesphere-sample-dev 10 | spec: 11 | progressDeadlineSeconds: 600 12 | replicas: 1 13 | selector: 14 | matchLabels: 15 | app: kubesphere 16 | component: ks-sample-dev 17 | tier: backend 18 | template: 19 | metadata: 20 | labels: 21 | app: kubesphere 22 | component: ks-sample-dev 23 | tier: backend 24 | spec: 25 | containers: 26 | - image: $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BUILD_NUMBER 27 | imagePullPolicy: Always 28 | name: ks-sample 29 | readinessProbe: 30 | httpGet: 31 | path: / 32 | port: 8080 33 | timeoutSeconds: 10 34 | failureThreshold: 30 35 | periodSeconds: 5 36 | ports: 37 | - containerPort: 8080 38 | protocol: TCP 39 | resources: 40 | limits: 41 | cpu: 300m 42 | memory: 600Mi 43 | requests: 44 | cpu: 100m 45 | memory: 100Mi 46 | terminationMessagePath: /dev/termination-log 47 | terminationMessagePolicy: File 48 | dnsPolicy: ClusterFirst 49 | restartPolicy: Always 50 | terminationGracePeriodSeconds: 30 51 | -------------------------------------------------------------------------------- /deploy/prod-all-in-one/devops-sample.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | labels: 6 | app: kubesphere 7 | component: ks-sample 8 | tier: backend 9 | name: ks-sample 10 | namespace: kubesphere-sample-prod 11 | spec: 12 | progressDeadlineSeconds: 600 13 | replicas: 2 14 | selector: 15 | matchLabels: 16 | app: kubesphere 17 | component: ks-sample 18 | tier: backend 19 | strategy: 20 | rollingUpdate: 21 | maxSurge: 100% 22 | maxUnavailable: 100% 23 | type: RollingUpdate 24 | template: 25 | metadata: 26 | labels: 27 | app: kubesphere 28 | component: ks-sample 29 | tier: backend 30 | spec: 31 | containers: 32 | - env: 33 | - name: CACHE_IGNORE 34 | value: js|html 35 | - name: CACHE_PUBLIC_EXPIRATION 36 | value: 3d 37 | image: $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME 38 | readinessProbe: 39 | httpGet: 40 | path: / 41 | port: 8080 42 | timeoutSeconds: 10 43 | failureThreshold: 30 44 | periodSeconds: 5 45 | imagePullPolicy: Always 46 | name: ks 47 | ports: 48 | - containerPort: 8080 49 | protocol: TCP 50 | resources: 51 | limits: 52 | cpu: 300m 53 | memory: 600Mi 54 | requests: 55 | cpu: 100m 56 | memory: 100Mi 57 | terminationMessagePath: /dev/termination-log 58 | terminationMessagePolicy: File 59 | dnsPolicy: ClusterFirst 60 | restartPolicy: Always 61 | terminationGracePeriodSeconds: 30 62 | --- 63 | apiVersion: v1 64 | kind: Service 65 | metadata: 66 | labels: 67 | app: kubesphere 68 | component: ks-sample 69 | name: ks-sample 70 | namespace: kubesphere-sample-prod 71 | spec: 72 | ports: 73 | - name: http 74 | port: 8080 75 | protocol: TCP 76 | targetPort: 8080 77 | nodePort: 30961 78 | selector: 79 | app: kubesphere 80 | component: ks-sample 81 | tier: backend 82 | sessionAffinity: None 83 | type: NodePort 84 | -------------------------------------------------------------------------------- /deploy/prod-ol/devops-sample-svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | app: kubesphere 6 | component: ks-sample 7 | name: ks-sample 8 | namespace: kubesphere-sample-prod 9 | spec: 10 | ports: 11 | - name: http 12 | port: 8080 13 | protocol: TCP 14 | targetPort: 8080 15 | nodePort: 30961 16 | selector: 17 | app: kubesphere 18 | component: ks-sample 19 | tier: backend 20 | sessionAffinity: None 21 | type: NodePort -------------------------------------------------------------------------------- /deploy/prod-ol/devops-sample.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | labels: 5 | app: kubesphere 6 | component: ks-sample 7 | tier: backend 8 | name: ks-sample 9 | namespace: kubesphere-sample-prod 10 | spec: 11 | progressDeadlineSeconds: 600 12 | replicas: 2 13 | selector: 14 | matchLabels: 15 | app: kubesphere 16 | component: ks-sample 17 | tier: backend 18 | strategy: 19 | rollingUpdate: 20 | maxSurge: 100% 21 | maxUnavailable: 100% 22 | type: RollingUpdate 23 | template: 24 | metadata: 25 | labels: 26 | app: kubesphere 27 | component: ks-sample 28 | tier: backend 29 | spec: 30 | containers: 31 | - env: 32 | - name: CACHE_IGNORE 33 | value: js|html 34 | - name: CACHE_PUBLIC_EXPIRATION 35 | value: 3d 36 | image: $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME 37 | readinessProbe: 38 | httpGet: 39 | path: / 40 | port: 8080 41 | timeoutSeconds: 10 42 | failureThreshold: 30 43 | periodSeconds: 5 44 | imagePullPolicy: Always 45 | name: ks 46 | ports: 47 | - containerPort: 8080 48 | protocol: TCP 49 | resources: 50 | limits: 51 | cpu: 300m 52 | memory: 600Mi 53 | requests: 54 | cpu: 100m 55 | memory: 100Mi 56 | terminationMessagePath: /dev/termination-log 57 | terminationMessagePolicy: File 58 | dnsPolicy: ClusterFirst 59 | restartPolicy: Always 60 | terminationGracePeriodSeconds: 30 -------------------------------------------------------------------------------- /deploy/prod/devops-sample-svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | app: kubesphere 6 | component: ks-sample 7 | name: ks-sample 8 | namespace: kubesphere-sample-prod 9 | spec: 10 | ports: 11 | - name: http 12 | port: 8080 13 | protocol: TCP 14 | targetPort: 8080 15 | nodePort: 30961 16 | selector: 17 | app: kubesphere 18 | component: ks-sample 19 | tier: backend 20 | sessionAffinity: None 21 | type: NodePort -------------------------------------------------------------------------------- /deploy/prod/devops-sample.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | labels: 5 | app: kubesphere 6 | component: ks-sample 7 | tier: backend 8 | name: ks-sample 9 | namespace: kubesphere-sample-prod 10 | spec: 11 | progressDeadlineSeconds: 600 12 | replicas: 2 13 | selector: 14 | matchLabels: 15 | app: kubesphere 16 | component: ks-sample 17 | tier: backend 18 | strategy: 19 | rollingUpdate: 20 | maxSurge: 100% 21 | maxUnavailable: 100% 22 | type: RollingUpdate 23 | template: 24 | metadata: 25 | labels: 26 | app: kubesphere 27 | component: ks-sample 28 | tier: backend 29 | spec: 30 | containers: 31 | - env: 32 | - name: CACHE_IGNORE 33 | value: js|html 34 | - name: CACHE_PUBLIC_EXPIRATION 35 | value: 3d 36 | image: $REGISTRY/$HARBOR_NAMESPACE/$APP_NAME:$TAG_NAME 37 | readinessProbe: 38 | httpGet: 39 | path: / 40 | port: 8080 41 | timeoutSeconds: 10 42 | failureThreshold: 30 43 | periodSeconds: 5 44 | imagePullPolicy: Always 45 | name: ks 46 | ports: 47 | - containerPort: 8080 48 | protocol: TCP 49 | resources: 50 | limits: 51 | cpu: 300m 52 | memory: 600Mi 53 | requests: 54 | cpu: 100m 55 | memory: 100Mi 56 | terminationMessagePath: /dev/termination-log 57 | terminationMessagePolicy: File 58 | dnsPolicy: ClusterFirst 59 | restartPolicy: Always 60 | terminationGracePeriodSeconds: 30 61 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | io.kubesphere.devops 6 | devops-sample 7 | 0.0.1-SNAPSHOT 8 | devops-sample :: HelloWorld Demo 9 | 10 | 11 | UTF-8 12 | UTF-8 13 | 14 | 15 | 18 | ${PWD}/./target/jacoco.exec 19 | target/classes 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-parent 26 | 2.1.11.RELEASE 27 | 28 | 29 | 30 | 31 | spring 32 | https://maven.aliyun.com/repository/spring 33 | 34 | true 35 | 36 | 37 | true 38 | 39 | 40 | 41 | 42 | 43 | spring 44 | https://maven.aliyun.com/repository/spring 45 | 46 | true 47 | 48 | 49 | true 50 | 51 | 52 | 53 | 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-starter-web 58 | 59 | 60 | junit 61 | junit 62 | 63 | 64 | 65 | 66 | 67 | 68 | org.jacoco 69 | jacoco-maven-plugin 70 | 0.8.2 71 | 72 | true 73 | 74 | 75 | 76 | agent-for-ut 77 | 78 | prepare-agent 79 | 80 | 81 | 82 | agent-for-it 83 | 84 | prepare-agent-integration 85 | 86 | 87 | 88 | jacoco-site 89 | verify 90 | 91 | report 92 | 93 | 94 | 95 | 96 | 97 | org.springframework.boot 98 | spring-boot-maven-plugin 99 | 100 | true 101 | 102 | 103 | 104 | org.sonarsource.scanner.maven 105 | sonar-maven-plugin 106 | 3.6.0.1398 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /src/main/java/io/kubesphere/devops/Application.java: -------------------------------------------------------------------------------- 1 | package io.kubesphere.devops; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class,args); 11 | } 12 | } -------------------------------------------------------------------------------- /src/main/java/io/kubesphere/devops/HelloWorldController.java: -------------------------------------------------------------------------------- 1 | package io.kubesphere.devops; 2 | 3 | 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | * Hello world! 10 | */ 11 | @RestController 12 | @EnableAutoConfiguration 13 | public class HelloWorldController { 14 | 15 | @RequestMapping("/") 16 | public String sayHello() { 17 | return "Really appreciate your star, that's the power of our life."; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/io/kubesphere/devops/HelloWorldControllerTest.java: -------------------------------------------------------------------------------- 1 | package io.kubesphere.devops; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | public class HelloWorldControllerTest { 8 | 9 | @Test 10 | public void testSayHello() { 11 | assertEquals("Really appreciate your star, that's the power of our life.", new HelloWorldController().sayHello()); 12 | } 13 | } 14 | --------------------------------------------------------------------------------