Reorganize devops user guide

Signed-off-by: Sherlock113 <sherlockxu@yunify.com>
This commit is contained in:
Sherlock113 2020-12-07 18:09:34 +08:00
parent edbca71ded
commit 240d722af0
46 changed files with 1260 additions and 238 deletions

View File

@ -4,7 +4,7 @@ description: "Getting started with KubeSphere DevOps project"
layout: "single"
linkTitle: "DevOps User Guide"
weight: 12000
weight: 11000
icon: "/images/docs/docs.svg"
---

View File

@ -1,6 +1,6 @@
---
linkTitle: "Examples"
weight: 400
weight: 11400
_build:
render: false

View File

@ -3,7 +3,7 @@ title: "How to Build and Deploy a Maven Project"
keywords: 'kubernetes, docker, devops, jenkins, maven'
description: ''
linkTitle: "Build And Deploy A Maven Project"
weight: 200
weight: 11430
---
## Prerequisites

View File

@ -3,7 +3,7 @@ title: "Build and Deploy a Go Project"
keywords: 'Kubernetes, docker, devops, jenkins, go, KubeSphere'
description: 'This tutorial demonstrates how to build and deploy a Go project.'
linkTitle: "Build and Deploy a Go Project"
weight: 200
weight: 11410
---
## Prerequisites

View File

@ -3,7 +3,7 @@ title: "Deploy Apps in a Multi-cluster Project Using Jenkinsfile"
keywords: 'Kubernetes, KubeSphere, docker, devops, jenkins, multi-cluster'
description: 'This tutorial demonstrates how to deploy apps in a multi-cluster project using a Jenkinsfile.'
linkTitle: "Deploy Apps in a Multi-cluster Project Using Jenkinsfile"
weight: 300
weight: 11420
---
## Prerequisites

View File

@ -1,6 +1,6 @@
---
linkTitle: "Tool Integration"
weight: 300
weight: 11300
_build:
render: false

View File

@ -3,7 +3,7 @@ title: "How to integrate Harbor in Pipeline"
keywords: 'kubernetes, docker, devops, jenkins, harbor'
description: ''
linkTitle: "Integrate Harbor in Pipeline"
weight: 360
weight: 11320
---
## Prerequisites

View File

@ -3,7 +3,7 @@ title: "Integrate SonarQube into Pipelines"
keywords: 'Kubernetes, KubeSphere, devops, jenkins, sonarqube, pipeline'
description: 'This tutorial demonstrates how to integrate SonarQube into pipelines.'
linkTitle: "Integrate SonarQube into Pipelines"
weight: 200
weight: 11310
---
[SonarQube](https://www.sonarqube.org/) is a popular continuous inspection tool for code quality. You can use it for static and dynamic analysis of a codebase. After it is integrated into pipelines in KubeSphere, you can view common code issues such as bugs and vulnerabilities directly on the dashboard as SonarQube detects issues in a running pipeline.

View File

@ -1,6 +1,6 @@
---
linkTitle: "Using DevOps"
weight: 200
linkTitle: "Use DevOps"
weight: 11200
_build:
render: false

View File

@ -3,7 +3,7 @@ title: "Choose Jenkins Agent"
keywords: 'Kubernetes, KubeSphere, docker, devops, jenkins, agent'
description: 'This tutorial introduces Jenkins agents and built-in podTemplates in KubeSphere.'
linkTitle: "Choose Jenkins Agent"
weight: 400
weight: 11250
---
The `agent` section specifies where the entire Pipeline, or a specific stage, will execute in the Jenkins environment depending on where the `agent` section is placed. The section must be defined at the top-level inside the `pipeline` block, but stage-level usage is optional. For more information, see [the official documentation of Jenkins](https://www.jenkins.io/doc/book/pipeline/syntax/#agent).

View File

@ -3,7 +3,7 @@ title: "Create a Pipeline Using Graphical Editing Panels"
keywords: 'KubeSphere, Kubernetes, jenkins, cicd, graphical pipelines'
description: 'How to create a pipeline using graphical editing panels.'
linkTitle: 'Create a Pipeline Using Graphical Editing Panels'
weight: 300
weight: 11220
---
A graphical editing panel in KubeSphere contains all the necessary operations used in Jenkins [stages](https://www.jenkins.io/doc/book/pipeline/#stage) and [steps](https://www.jenkins.io/doc/book/pipeline/#step). You can directly define these stages and steps on the highly responsive and interactive panel without creating any Jenkinsfile.

View File

@ -3,7 +3,7 @@ title: "Create a Pipeline Using a Jenkinsfile"
keywords: 'KubeSphere, Kubernetes, docker, spring boot, Jenkins, devops, ci/cd, pipeline'
description: "How to create a pipeline using a Jenkinsfile."
linkTitle: "Create a Pipeline Using a Jenkinsfile"
weight: 200
weight: 11210
---
A Jenkinsfile is a text file that contains the definition of a Jenkins pipeline and is checked into source control. As it stores the entire workflow as code, it underpins the code review and iteration process of a pipeline. For more information, see [the official documentation of Jenkins](https://www.jenkins.io/doc/book/pipeline/jenkinsfile/).

View File

@ -3,7 +3,7 @@ title: "Credential Management"
keywords: 'Kubernetes, docker, credential, KubeSphere, devops'
description: 'This tutorial demonstrates how to manage credentials in a DevOps project.'
linkTitle: "Credential Management"
weight: 400
weight: 11230
---
Credentials are objects containing sensitive information, such as usernames and passwords, SSH keys, and tokens. When a KubeSphere DevOps pipeline is running, it interacts with objects in external environments to perform a series of tasks, including pulling code, pushing and pulling images, and running scripts. During this process, credentials need to be provided accordingly while they do not appear explicitly in the pipeline.

View File

@ -3,7 +3,7 @@ title: "Set Email Server for KubeSphere Pipelines"
keywords: 'KubeSphere, Kubernetes, notification, jenkins, devops, ci/cd, pipeline, email server'
description: 'Set Email server for KubeSphere CI/CD pipelines'
linkTitle: "Set Email Server for KubeSphere Pipelines"
Weight: 400
Weight: 11260
---

View File

@ -3,7 +3,7 @@ title: "Jenkins System Settings"
keywords: 'Kubernetes, KubeSphere, Jenkins, CasC'
description: 'How to set up Jenkins in KubeSphere.'
linkTitle: 'Jenkins System Settings'
Weight: 1000
Weight: 11240
---
Jenkins is powerful and flexible and it has become the de facto standard for CI/CD workflows. Nevertheless, many plugins require users to set system-level configurations before they can be put to use.

View File

@ -3,5 +3,5 @@ title: "Pipeline Settings"
keywords: 'KubeSphere, Kubernetes, Docker, Jenkins, pipelines'
description: ''
linkTitle: "Pipeline Settings"
weight:
weight: 11280
---

View File

@ -3,7 +3,7 @@ title: "Set a CI Node for Dependency Caching"
keywords: 'Kubernetes, docker, KubeSphere, Jenkins, cicd, pipeline, dependency cache'
description: 'How to set a CI node for dependency caching of KubeSphere pipelines.'
linkTitle: "Set a CI Node for Dependency Caching"
weight: 400
weight: 11270
---
Generally, different dependencies need to be pulled as applications are being built. This may cause some issues such as long pulling time and network instability, further resulting in build failures. To provide your pipeline with a more enabling and stable environment, you can configure a node or a group of nodes specifically for continuous integration (CI). These CI nodes can speed up the building process by using caches.

View File

@ -0,0 +1,7 @@
---
linkTitle: "Understand and Manage DevOps Projects"
weight: 11100
_build:
render: false
---

View File

@ -3,7 +3,7 @@ title: "DevOps Project Management"
keywords: 'kubernetes, docker, helm, jenkins, istio, prometheus'
description: ''
linkTitle: "DevOps Project Management"
weight: 110
weight: 11120
---
This tutorial demonstrates how to create and manage DevOps projects.

View File

@ -3,6 +3,6 @@ title: "Overview"
keywords: 'Kubernetes, KubeSphere, DevOps, overview'
description: 'This tutorial gives an overview of the KubeSphere DevOps system.'
linkTitle: "Overview"
weight: 50
weight: 11110
---

View File

@ -3,7 +3,7 @@ title: "Role and Member Management"
keywords: 'Kubernetes, KubeSphere, DevOps, role, member'
description: 'Role and Member Management'
linkTitle: "Role and Member Management"
weight: 120
weight: 11130
---
This guide demonstrates how to manage roles and members in your DevOps project. For more information about KubeSphere roles, see Overview of Role Management.

View File

@ -1,7 +0,0 @@
---
linkTitle: "DevOps Administration"
weight: 2200
_build:
render: false
---

View File

@ -1,10 +0,0 @@
---
title: "Role and Member Management"
keywords: 'kubernetes, kubesphere, air gapped, installation'
description: 'Role and Member Management'
weight: 2240
---
TBD

View File

@ -0,0 +1,7 @@
---
linkTitle: "Examples"
weight: 11400
_build:
render: false
---

View File

@ -0,0 +1,171 @@
---
title: "How to Build and Deploy a Maven Project"
keywords: 'kubernetes, docker, devops, jenkins, maven'
description: ''
linkTitle: "Build And Deploy A Maven Project"
weight: 11430
---
## Prerequisites
- You need to [enable KubeSphere DevOps System](../../../../docs/pluggable-components/devops/).
- You need to create [DockerHub](http://www.dockerhub.com/) account.
- You need to create a workspace, a DevOps project, and a user account, and this account needs to be invited into the DevOps project as the role of `maintainer`.
## Workflow for Maven Project
As is shown in the graph, there is the workflow for a Maven project in KubeSphere DevOps, which uses the pipeline of Jenkins to build and deploy the Maven project. All steps are defined in the pipeline.
When running, Jenkins Master creates a Pod to run the pipeline. Kubernetes creates the Pod as the agent of Jenkins Master, and the Pod will be destoryed after pipeline finished. The main process is to clone code, build & push image, and deploy the workload.
![workflow](/images/devops/maven-project-jenkins.png)
## Default Configurations in Jenkins
### Maven Version
Execute the following command in the Maven builder container to get version info.
```bash
mvn --version
Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T19:49:05Z)
Maven home: /opt/apache-maven-3.5.3
Java version: 1.8.0_232, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-0.el7_7.i386/jre
Default locale: en_US, platform encoding: UTF-8
```
### Maven Cache
Jenkins Agent mounts the directories by Docker Volume on the node. So the pipeline can cache some spicial directory such as `/root/.m2`, which is used for the Maven building and the default cache directory for Maven tools in KubeSphere DevOps so that the dependency packages are downloaded and cached on the node.
### Global Maven Settings in Jenkins Agent
The default Maven settings file path is `maven` and the configuration file path is `/opt/apache-maven-3.5.3/conf/settings.xml`. Execute the following command to get the content of Maven settings.
```bash
kubectl get cm -n kubesphere-devops-system ks-devops-agent -o yaml
```
### Network of Maven Pod
The Pod labeled `maven` uses the docker-in-docker network to run the pipeline. That is, the `/var/run/docker.sock` in the node is mounted into the Maven container.
## A Maven Pipeline Example
### Prepare for the Maven Project
- ensure build the Maven project successfully on the development device.
- add the Dockerfile file into the project repo for building the image, refer to <https://github.com/kubesphere/devops-java-sample/blob/master/Dockerfile-online>.
- add the yaml file into the project repo for deploy the workload, refer to <https://github.com/kubesphere/devops-java-sample/tree/master/deploy/dev-ol>. If there are different environments, you need to prepare multiple deployment files.
### Create the Credentials
- dockerhub-id. A *Account Credentials* for registry, e.g DockerHub.
- demo-kuebconfig. A *Kubeconfig Credential* for deploying workloads.
For details, please refer to the [Credentials Management](../../how-to-use/credential-management/).
![view credential list](/images/devops/view-credential-list.png)
### Create the Project for Workloads
In this demo, all of workloads are deployed under `kubesphere-sample-dev`. So you need to create the project `kubesphere-sample-dev` in advance.
![view namespace](/images/devops/view-namespace.png)
### Create the Pipeline for the Maven Project
At first, create a *DevOps Project* and a *Pipeline* refer to [Create a Pipeline - using Graphical Editing Panel](../../how-to-use/create-a-pipeline-using-graphical-editing-panel).
Secondly, click *Edit Jenkinsfile* button under your pipeline.
![edit jenkinsfile](/images/devops/edit-jenkinsfile.png)
Paste the following text into the pop-up window and save it.
```groovy
pipeline {
agent {
node {
label 'maven'
}
}
parameters {
string(name:'TAG_NAME',defaultValue: '',description:'')
}
environment {
DOCKER_CREDENTIAL_ID = 'dockerhub-id'
KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig'
REGISTRY = 'docker.io'
// need to replace by yourself dockerhub namespace
DOCKERHUB_NAMESPACE = 'shaowenchen'
APP_NAME = 'devops-java-sample'
BRANCH_NAME = 'dev'
}
stages {
stage ('checkout scm') {
steps {
git branch: 'master', url: "https://github.com/kubesphere/devops-java-sample.git"
}
}
stage ('unit test') {
steps {
container ('maven') {
sh 'mvn clean -o -gs `pwd`/configuration/settings.xml test'
}
}
}
stage ('build & push') {
steps {
container ('maven') {
sh 'mvn -o -Dmaven.test.skip=true -gs `pwd`/configuration/settings.xml clean package'
sh 'docker build -f Dockerfile-online -t $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER .'
withCredentials([usernamePassword(passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,credentialsId : "$DOCKER_CREDENTIAL_ID" ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER'
}
}
}
}
stage('deploy to dev') {
steps {
kubernetesDeploy(configs: 'deploy/dev-ol/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
}
}
```
After saving, you will get this.
![view jenkinsfile](/images/devops/view-edit-jenkinsfile.png)
### Run and test
Click `run` and type `TAG_NAME` to run the pipeline.
![run maven pipeling](/images/devops/run-maven-pipeline.png)
After the run is complete, you can see the following figure.
![view result](/images/devops/view-result-maven-pipeline.png)
Under the project of `kubesphere-sample-dev`, there are new workloads created.
![maven workload](/images/devops/view-result-maven-workload.png)
You can view the access address of the service through service.
![maven service](/images/devops/view-result-maven-workload-svc.png)
## Summary
This document is not a getting-started document. It introduces some configurations for building Maven projects on the KubeSphere DevOps Platform. At the same time, a example flow of the Maven project is provided. In your case, you are free to add new steps to improve the pipeline.

View File

@ -0,0 +1,160 @@
---
title: "Build and Deploy a Go Project"
keywords: 'Kubernetes, docker, devops, jenkins, go, KubeSphere'
description: 'This tutorial demonstrates how to build and deploy a Go project.'
linkTitle: "Build and Deploy a Go Project"
weight: 11410
---
## Prerequisites
- You need to [enable KubeSphere DevOps System](../../../../docs/pluggable-components/devops/).
- You need to have a [Docker Hub](https://hub.docker.com/) account.
- You need to create a workspace, a DevOps project, a project, and an account (`project-regular`). This account needs to be invited to the DevOps project and the project for deploying your workload with the role `operator`. For more information, see [Create Workspace, Project, Account and Role](../../../quick-start/create-workspace-and-project).
## Create Docker Hub Access Token
1. Sign in [Docker Hub](https://hub.docker.com/) and select **Account Settings** from the menu in the top right corner.
![dockerhub-settings](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/dockerhub-settings.jpg)
2. Click **Security** and **New Access Token**.
![dockerhub-create-token](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/dockerhub-create-token.jpg)
3. Enter the token name and click **Create**.
![dockerhub-token-ok](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/dockerhub-token-ok.jpg)
4. Click **Copy and Close** and remember to save the access token.
![dockerhub-token-copy](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/dockerhub-token-copy.jpg)
## Create Credentials
You need to create credentials in KubeSphere for the access token created so that the pipeline can interact with Docker Hub for imaging pushing. Besides, you also create kubeconfig credentials for the access to the Kubernetes cluster.
1. Log in the web console of KubeSphere as `project-regular`. Go to your DevOps project and click **Create** in **Credentials**.
![create-dockerhub-id](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/create-dockerhub-id.jpg)
2. In the dialogue that appears, set a **Credential ID**, which will be used later in the Jenkinsfile, and select **Account Credentials** for **Type**. Enter your Docker Hub account name for **Username** and the access token just created for **Token/Password**. When you finish, click **OK**.
![credential-docker-create](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/credential-docker-create.jpg)
{{< notice tip >}}
For more information about how to create credentials, see [Credential Management](../../../devops-user-guide/how-to-use/credential-management/).
{{</ notice >}}
3. Click **Create** again and select **kubeconfig** for **Type**. Note that KubeSphere automatically populates the **Content** field, which is the kubeconfig of the current user account. Set a **Credential ID** and click **OK**.
![create-kubeconfig](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/create-kubeconfig.jpg)
## Create a Pipeline
With the above credentials ready, you can create a pipeline using an example Jenkinsfile as below.
1. To create a pipeline, click **Create** on the **Pipelines** page.
![create-pipeline](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/create-pipeline.jpg)
2. Set a name in the pop-up window and click **Next** directly.
![set-pipeline-name](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/set-pipeline-name.jpg)
3. In this tutorial, you can use default values for all the fields. In **Advanced Settings**, click **Create** directly.
![create-pipeline-2](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/create-pipeline-2.jpg)
## Edit Jenkinsfile
1. In the pipeline list, click this pipeline to go to its detail page. Click **Edit Jenkinsfile** to define a Jenkinsfile and your pipeline runs based on it.
![edit-jenkinsfile](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/edit-jenkinsfile.jpg)
2. Copy and paste all the content below to the pop-up window as an example Jenkinsfile for your pipeline. You must replace the value of `DOCKERHUB_USERNAME`, `DOCKERHUB_CREDENTIAL`, `KUBECONFIG_CREDENTIAL_ID`, and `PROJECT_NAME` with yours. When you finish, click **OK**.
```groovy
pipeline {
agent {
node {
label 'maven'
}
}
environment {
// the address of your harbor registry
REGISTRY = 'docker.io'
// your docker hub username
DOCKERHUB_USERNAME = 'yuswift'
// docker image name
APP_NAME = 'devops-go-sample'
// dockerhubid is the credential id you created in KubeSphere for docker access token
DOCKERHUB_CREDENTIAL = credentials('dockerhubid')
//the kubeconfig credential id you created in KubeSphere
KUBECONFIG_CREDENTIAL_ID = 'go'
// the name of the project you created in KubeSphere, not the DevOps project name
PROJECT_NAME = 'devops-go'
}
stages {
stage('docker login') {
steps{
container ('maven') {
sh 'echo $DOCKERHUB_CREDENTIAL_PSW | docker login -u $DOCKERHUB_CREDENTIAL_USR --password-stdin'
}
}
}
stage('build & push') {
steps {
container ('maven') {
sh 'git clone https://github.com/yuswift/devops-go-sample.git'
sh 'cd devops-go-sample && docker build -t $REGISTRY/$DOCKERHUB_USERNAME/$APP_NAME .'
sh 'docker push $REGISTRY/$DOCKERHUB_USERNAME/$APP_NAME'
}
}
}
stage ('deploy app') {
steps {
container('maven') {
kubernetesDeploy(configs: 'devops-go-sample/manifest/deploy.yaml', kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
}
}
}
```
{{< notice note >}}
If your pipeline runs successfully, images will be pushed to Docker Hub. If you are using Harbor, you cannot pass the parameter to `docker login -u` via the Jenkins credential with environment variables. This is because every Harbor robot account username contains a `$` character, which will be converted to `$$` by Jenkins when used by environment variables. [Learn more](https://number1.co.za/rancher-cannot-use-harbor-robot-account-imagepullbackoff-pull-access-denied/).
{{</ notice >}}
## Run Pipeline
1. After you finish the Jenkinsfile, you can see graphical panels display on the dashboard. Click **Run** to run the pipeline.
![run-pipeline](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/run-pipeline.jpg)
2. In **Activity**, you can see the status of the pipeline. It may take a while before it successfully runs.
![pipeline-running](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/pipeline-running.jpg)
## Verify Results
1. A **Deployment** will be created in the project specified in the Jenkinsfile if the pipeline runs successfully.
![view-deployments](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/view-deployments.jpg)
2. Check whether the image is pushed to Docker Hub as shown below:
![docker-image-1](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/docker-image-1.jpg)
![docker-image-2](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/docker-image-2.jpg)

View File

@ -0,0 +1,155 @@
---
title: "Deploy Apps in a Multi-cluster Project Using Jenkinsfile"
keywords: 'Kubernetes, KubeSphere, docker, devops, jenkins, multi-cluster'
description: 'This tutorial demonstrates how to deploy apps in a multi-cluster project using a Jenkinsfile.'
linkTitle: "Deploy Apps in a Multi-cluster Project Using Jenkinsfile"
weight: 11420
---
## Prerequisites
- You need to [enable the multi-cluster feature](../../../../docs/multicluster-management/).
- You need to have a [Docker Hub](https://hub.docker.com/) account.
- You need to [enable KubeSphere DevOps System](../../../../docs/pluggable-components/devops/) on your host cluster.
- You need to create a workspace with multiple clusters, a DevOps project on your **host** cluster, a multi-cluster project (in this tutorial, this multi-cluster project is created on the host cluster and one member cluster), and an account (`project-regular`). This account needs to be invited to the DevOps project and the multi-cluster project with the role `operator`. For more information, see [Create Workspace, Project, Account and Role](../../../quick-start/create-workspace-and-project), [Multi-cluster Management](../../../multicluster-management) and [Multi-cluster Projects](../../../project-administration/project-and-multicluster-project/#multi-cluster-projects).
## Create Docker Hub Access Token
1. Sign in [Docker Hub](https://hub.docker.com/) and select **Account Settings** from the menu in the top right corner.
![dockerhub-settings](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-multi-cluster-project/dockerhub-settings.jpg)
2. Click **Security** and **New Access Token**.
![dockerhub-create-token](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-multi-cluster-project/dockerhub-create-token.jpg)
3. Enter the token name and click **Create**.
![dockerhub-token-ok](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-multi-cluster-project/dockerhub-token-ok.jpg)
4. Click **Copy and Close** and remember to save the access token.
![dockerhub-token-copy](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-multi-cluster-project/dockerhub-token-copy.jpg)
## Create Credentials
You need to create credentials in KubeSphere for the access token created so that the pipeline can interact with Docker Hub for imaging pushing. Besides, you also need to create kubeconfig credentials for the access to the Kubernetes cluster.
1. Log in the web console of KubeSphere as `project-regular`. Go to your DevOps project and click **Create** in **Credentials**.
![create-dockerhub-id](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-multi-cluster-project/create-dockerhub-id.jpg)
2. In the dialogue that appears, set a **Credential ID**, which will be used later in the Jenkinsfile, and select **Account Credentials** for **Type**. Enter your Docker Hub account name for **Username** and the access token just created for **Token/Password**. When you finish, click **OK**.
![credential-docker-create](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-multi-cluster-project/credential-docker-create.jpg)
{{< notice tip >}}
For more information about how to create credentials, see [Credential Management](../../../devops-user-guide/how-to-use/credential-management/).
{{</ notice >}}
3. Click **Create** again and select **kubeconfig** for **Type**. Note that KubeSphere automatically populates the **Content** field, which is the kubeconfig of the current user account. Set a **Credential ID** and click **OK**.
![create-kubeconfig](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-multi-cluster-project/create-kubeconfig.jpg)
## Create a Pipeline
With the above credentials ready, you can create a pipeline using an example Jenkinsfile as below.
1. To create a pipeline, click **Create** on the **Pipelines** page.
![create-pipeline](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/create-pipeline.jpg)
2. Set a name in the pop-up window and click **Next** directly.
![set-pipeline-name](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/set-pipeline-name.jpg)
3. In this tutorial, you can use default values for all the fields. In **Advanced Settings**, click **Create** directly.
![create-pipeline-2](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/create-pipeline-2.jpg)
## Edit Jenkinsfile
1. In the pipeline list, click this pipeline to go to its detail page. Click **Edit Jenkinsfile** to define a Jenkinsfile and your pipeline runs based on it.
![edit-jenkinsfile](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-project/edit-jenkinsfile.jpg)
2. Copy and paste all the content below to the pop-up window as an example Jenkinsfile for your pipeline. You must replace the value of `DOCKERHUB_USERNAME`, `DOCKERHUB_CREDENTIAL`, `KUBECONFIG_CREDENTIAL_ID`, `MULTI_CLUSTER_PROJECT_NAME`, and `MEMBER_CLUSTER_NAME` with yours. When you finish, click **OK**.
```
pipeline {
agent {
node {
label 'maven'
}
}
environment {
REGISTRY = 'docker.io'
// username of dockerhub
DOCKERHUB_USERNAME = 'yuswift'
APP_NAME = 'devops-go-sample'
// dockerhubid is the dockerhub credential id you created on ks console
DOCKERHUB_CREDENTIAL = credentials('dockerhubid')
// the kubeconfig credential id you created on ks console
KUBECONFIG_CREDENTIAL_ID = 'multi-cluster'
// mutli-cluster project name under your own workspace
MULTI_CLUSTER_PROJECT_NAME = 'devops-with-go'
// the member cluster name you want to deploy app on
// in this tutorial, you are assumed to deploy app on host and only one member cluster
// for more member clusters, please edit manifest/multi-cluster-deploy.yaml
MEMBER_CLUSTER_NAME = 'c9'
}
stages {
stage('docker login') {
steps {
container('maven') {
sh 'echo $DOCKERHUB_CREDENTIAL_PSW | docker login -u $DOCKERHUB_CREDENTIAL_USR --password-stdin'
}
}
}
stage('build & push') {
steps {
container('maven') {
sh 'git clone https://github.com/yuswift/devops-go-sample.git'
sh 'cd devops-go-sample && docker build -t $REGISTRY/$DOCKERHUB_USERNAME/$APP_NAME .'
sh 'docker push $REGISTRY/$DOCKERHUB_USERNAME/$APP_NAME'
}
}
}
stage('deploy app to multi cluster') {
steps {
container('maven') {
script {
withCredentials([
kubeconfigFile(
credentialsId: 'multi-cluster',
variable: 'KUBECONFIG')
]) {
sh 'envsubst < devops-go-sample/manifest/multi-cluster-deploy.yaml | kubectl apply -f -'
}
}
}
}
}
}
}
```
{{< notice note >}}
If your pipeline runs successfully, images will be pushed to Docker Hub. If you are using Harbor, you cannot pass the parameter to `docker login -u` via the Jenkins credential with environment variables. This is because every Harbor robot account username contains a `$` character, which will be converted to `$$` by Jenkins when used by environment variables. [Learn more](https://number1.co.za/rancher-cannot-use-harbor-robot-account-imagepullbackoff-pull-access-denied/).
{{</ notice >}}
## Run Pipeline
After you save the Jenkinsfile, click **Run**. If everything goes well, you will see the Deployment workload in your multi-cluster project.
![multi-cluster-ok](/images/docs/devops-user-guide/examples/compile-and-deploy-a-go-multi-cluster-project/multi-cluster-ok.png)

View File

@ -0,0 +1,7 @@
---
linkTitle: "Tool Integration"
weight: 11300
_build:
render: false
---

View File

@ -0,0 +1,128 @@
---
title: "How to integrate Harbor in Pipeline"
keywords: 'kubernetes, docker, devops, jenkins, harbor'
description: ''
linkTitle: "Integrate Harbor in Pipeline"
weight: 11320
---
## Prerequisites
- You need to [enable KubeSphere DevOps System](../../../../docs/pluggable-components/devops/).
- You need to create a workspace, a DevOps project, and a **project-regular** user account, and this account needs to be invited into a DevOps project. See [create-workspace-and-project](../../../../docs/quick-start/create-workspace-and-project).
- You need to have installed **Harbor** already.
## Install Harbor
It is highly recommended that you install harbor [by application store](). You can also install harbor manally by helm3.
```bash
helm repo add harbor https://helm.goharbor.io
# for qucik taste, you can expose harbor by nodeport and disable tls.
# set externalURL as one of your node ip and make sure it can be accessed by jenkins.
helm install harbor-release harbor/harbor --set expose.type=nodePort,externalURL=http://$ip:30002,expose.tls.enabled=false
```
After several minutes, open your browser and visit http:$node_ip:30003. Enter **admin** and **Harbor12345** , then click **LOG** **IN**.
![](/images/devops/harbor-login.png)
Click **NEW** **PROJECT** , enter the project name, then click **ok**.
## Get Harbor credential
![](/images/devops/harbor-new-project.png)
![](/images/devops/harbor-project-ok.png)
Click your project name you just created, find the **Robot Accounts** tab, then click **NEW ROBOT ACCOUNT**.
![](/images/devops/harbor-robot-account.png)
Enter the name of the robot account, then save it.
![](/images/devops/harbor-robot-account-ok.png)
Click **EXPORT TO FILE** to save the credential.
![](/images/devops/harbor-robot-account-save.png)
### Create Credentials
Log into KubeSphere, enter into the created DevOps project and create the following credential under **Project Management → Credentials**:
![](/images/devops/ks-console-create-credential.png)
The **Username** is the name field of the json file you just saved. **Password** takes the token field.
![](/images/devops/ks-console-credential-ok.png)
## Create a pipeline
![](/images/devops/ks-console-create-pipline.png)
Fill in the pipeline's basic information in the pop-up window, enter the name of pipelne and set the others as default value.
![](/images/devops/create-pipline-2.png)
![](/images/devops/create-pipline-3.png)
## Edit jenkins file
Click **Edit Jenkins File** button under your pipeline and paste the following text into the pop-up window. You need to replace **REGISTRY**, **HARBOR_NAMESPACE**, **APP_NAME**, **HARBOR_CREDENTIAL** as yours.
```pipeline {
pipeline {
agent {
node {
label 'maven'
}
}
environment {
// the address of your harbor registry
REGISTRY = '103.61.38.55:30002'
// the project name
// make sure your robot account have enough access to the project
HARBOR_NAMESPACE = 'ks-devops-harbor'
// docker image name
APP_NAME = 'docker-example'
// yuswift is the credential id you created on ks console
HARBOR_CREDENTIAL = credentials('yuswift')
}
stages {
stage('docker login') {
steps{
container ('maven') {
// replace the username behind -u and do not forget ''
sh '''echo $HARBOR_CREDENTIAL_PSW | docker login $REGISTRY -u 'robot$yuswift2018' --password-stdin'''
}
}
}
stage('build & push') {
steps {
container ('maven') {
sh 'git clone https://github.com/kstaken/dockerfile-examples.git'
sh 'cd dockerfile-examples/rethinkdb && docker build -t $REGISTRY/$HARBOR_NAMESPACE/$APP_NAME:devops-test .'
sh 'docker push $REGISTRY/$HARBOR_NAMESPACE/$APP_NAME:devops-test'
}
}
}
}
}
```
> Note:
>
> - You can pass the parameter to `docker login -u ` via jenkins credential with environment variable. However, every harbor-robot-account username contains a "\$" character, which will be converted into "\$$" by jenkins when used by environment varibles. See more about [this](https://number1.co.za/rancher-cannot-use-harbor-robot-account-imagepullbackoff-pull-access-denied/).
![](/images/devops/edit-jenkins-file.png)
## Run the pipeline
After you have saved the jenkins file, click the **Run** button. If everything goes well, you will see image have been pushed into your harbor registry by jenkins.
![](/images/devops/run-pipline.png)

View File

@ -3,7 +3,7 @@ title: "将 SonarQube 集成到流水线"
keywords: 'Kubernetes, KubeSphere, devops, jenkins, sonarqube, pipeline'
description: '本教程演示了如何将 SonarQube 集成到流水线中。'
linkTitle: "将 SonarQube 集成到流水线"
weight: 200
weight: 11310
---
[SonarQube](https://www.sonarqube.org/) 是一种流行的代码质量持续监测工具。 您可以将其用于代码库的静态和动态分析。将其集成到 KubeSphere 的流水线中后, 当 SonarQube 在运行的流水线检测到问题时,您可以直接在仪表盘上查看常见的代码问题,比如 bug 和漏洞。</br>

View File

@ -0,0 +1,7 @@
---
linkTitle: "Use DevOps"
weight: 11200
_build:
render: false
---

View File

@ -3,7 +3,7 @@ title: "选择 Jenkins Agent"
keywords: 'Kubernetes, KubeSphere, docker, devops, jenkins, agent'
description: '本教程介绍了 Jenkins Agent 和 KubeSphere 中的内置 podTemplates。'
linkTitle: "选择 Jenkins Agent"
weight: 400
weight: 11250
---
`Agent` 部分指定整个流水线或特定阶段将在 Jenkins 环境中执行的位置,具体取决于 Agent 部分的放置位置。该部分必须在流水线的顶层定义,但是阶段级别的用法是可选的。有关更多信息,请参阅 [Jenkins 的官方文档。](https://www.jenkins.io/doc/book/pipeline/syntax/#agent)

View File

@ -0,0 +1,396 @@
---
title: "Create a Pipeline Using Graphical Editing Panels"
keywords: 'KubeSphere, Kubernetes, jenkins, cicd, graphical pipelines'
description: 'How to create a pipeline using graphical editing panels.'
linkTitle: 'Create a Pipeline Using Graphical Editing Panels'
weight: 11220
---
A graphical editing panel in KubeSphere contains all the necessary operations used in Jenkins [stages](https://www.jenkins.io/doc/book/pipeline/#stage) and [steps](https://www.jenkins.io/doc/book/pipeline/#step). You can directly define these stages and steps on the highly responsive and interactive panel without creating any Jenkinsfile.
This tutorial demonstrates how to create a pipeline through graphical editing panels in KubeSphere. During the whole process, you do not need to create any Jenkinsfile manually as KubeSphere will automatically generate one based on your settings on the editing panels. When the pipeline successful runs, it creates a Deployment and a Service accordingly in your development environment and pushes an image to Docker Hub.
## Prerequisites
- You need to [enable the KubeSphere DevOps System](../../../../docs/pluggable-components/devops/).
- You need to have a [Docker Hub](http://www.dockerhub.com/) account.
- You need to create a workspace, a DevOps project, and an account (`project-regular`). This account must be invited to the DevOps project with the `operator` role. See [Create Workspace, Project, Account and Role](../../../quick-start/create-workspace-and-project/) if they are not ready.
- Set CI dedicated nodes to run the pipeline. For more information, see [Set CI Node for Dependency Cache](../set-ci-node/).
- Configure your email server for pipeline notifications (Optional). For more information, see [Set Email Server for KubeSphere Pipelines](../../how-to-use/jenkins-email/).
- Configure SonarQube to include code analysis as part of the pipeline (Optional). For more information, see [Integrate SonarQube into Pipelines](../../../devops-user-guide/how-to-integrate/sonarqube/).
## Pipeline Overview
This example pipeline includes the following six stages.
![Pipeline](https://pek3b.qingstor.com/kubesphere-docs/png/20190516091714.png#align=left&display=inline&height=1278&originHeight=1278&originWidth=2190&search=&status=done&width=2190)
{{< notice note >}}
- **Stage 1. Checkout SCM**: Pull source code from a GitHub repository.
- **Stage 2. Unit test**: It will not proceed with the next stage unit the test is passed.
- **Stage 3. Code analysis**: Configure SonarQube for static code analysis.
- **Stage 4. Build and push**: Build an image and push it to Docker Hub with the tag `snapshot-$BUILD_NUMBER`, the `$BUILD_NUMBER` of which is the record serial number in the pipelines activity list.
- **Stage 5. Artifacts**: Generate an artifact (jar package) and save it.
- **Stage 6. Deploy to DEV**: Create a Deployment and a Service in the development environment. It requires review in this stage. An email notification will be sent after the Deployment is successful.
{{</ notice >}}
## Hands-on Lab
### Step 1: Create Credentials
1. Log in the KubeSphere console as `project-regular`. Go to your DevOps project and create the following credentials in **Credentials** under **Project Management**. For more information about how to create credentials, see [Credential Management](../credential-management/).
{{< notice note >}}
If there are any special characters such as `@` and `$` in your account or password, they can cause errors as a pipeline runs because they may not be recognized. In this case, you need to encode your account or password on some third-party websites first, such as [urlencoder](https://www.urlencoder.org/). After that, copy and paste the output for your credential information.
{{</ notice >}}
| Credential ID | Type | Where to use |
| --------------- | ------------------- | ------------ |
| dockerhub-id | Account Credentials | Docker Hub |
| demo-kubeconfig | kubeconfig | Kubernetes |
2. You need to create an additional credential ID (`sonar-token`) for SonarQube, which is used in stage 3 (Code analysis) mentioned above. Refer to [Create SonarQube Token for New Project](../../../devops-user-guide/how-to-integrate/sonarqube/#create-sonarqube-token-for-new-project) to use the token for the **secret** field below. Click **OK** to finish.
![sonar-token](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/sonar-token.jpg)
3. In total, you have three credentials in the list.
![credential-list](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/credential-list.jpg)
### Step 2: Create a Project
In this tutorial, the example pipeline will deploy the [sample](https://github.com/kubesphere/devops-java-sample/tree/sonarqube) app to a project. Hence, you must create the project (for example, `kubesphere-sample-dev`) in advance. The Deployment and Service of the app will be created automatically in the project once the pipeline runs successfully.
You can use the account `project-admin` to create the project. Besides, this account is also the reviewer of the CI/CD pipeline. Make sure the account `project-regular` is invited to the project with the role of `operator`. For more information, see [Create Workspace, Project, Account and Role](../../../quick-start/create-workspace-and-project/).
### Step 3: Create a Pipeline
1. Make sure you have logged in KubeSphere as `project-regular`, and then go to your DevOps project. Click **Create** in **Pipelines**.
![create-pipeline](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/create-pipeline.jpg)
2. In the dialog that appears, name it `graphical-pipeline` and click **Next**.
![basic-info](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/basic-info.jpg)
3. On the **Advanced Settings** page, click **Add Parameter** to add three string parameters as follows. These parameters will be used in the Docker command of the pipeline. Click **Create** when you finish adding.
![add-parameter](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/add-parameter.jpg)
| Parameter Type | Name | Value | Description |
| -------------- | ------------------- | --------------- | ------------------------------------------------------------ |
| String | REGISTRY | `docker.io` | This is the image registry address. This example uses `docker.io`. |
| String | DOCKERHUB_NAMESPACE | Docker ID | You Docker Hub account or the organization name under the account. |
| String | APP_NAME | `devops-sample` | The app name. |
{{< notice note >}}
For other fields, use the default values directly or refer to [Pipeline Settings](../pipeline-settings/) to customize the configuration.
{{</ notice >}}
4. The pipeline created will appear in the list.
![pipeline-list](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/pipeline-list.jpg)
### Step 4: Edit the Pipeline
Click the pipeline to go to its detail page. To use graphical editing panels, click **Edit Pipeline** under the tab **Pipeline**. This pipeline consists of six stages. Follow the steps below to set each stage.
![edit-pipeline](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/edit-pipeline.jpg)
{{< notice note >}}
You can also click **Edit Jenkinsfile** to create a Jenkinsfile manually for your pipeline.
{{</ notice >}}
#### Stage 1: Pull source code (Checkout SCM)
A graphical editing panel includes two areas - **canvas** on the left and **content** on the right. It automatically generates a Jenkinsfile based on how you configure different stages and steps, which is much more user-friendly for developers.
{{< notice note >}}
Pipelines include [declarative pipelines](https://www.jenkins.io/doc/book/pipeline/syntax/#declarative-pipeline) and [scripted pipelines](https://www.jenkins.io/doc/book/pipeline/syntax/#scripted-pipeline). Currently, you can create declarative pipelines through the panel. For more information about pipeline syntax, see [Jenkins Documentation](https://jenkins.io/doc/book/pipeline/syntax/).
{{</ notice >}}
1. On the graphical editing panel, select **node** from the **Type** drop-down list and input `maven` for **label**.
{{< notice note >}}
`agent` is used to define the execution environment. The `agent` directive tells Jenkins where and how to execute the pipeline. For more information, see [Choose Jenkins Agent](../choose-jenkins-agent/).
{{</ notice >}}
![graphical-panel](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/graphical-panel.jpg)
2. To add a stage, click the plus icon on the left. Click the box above the **Add Step** area and set a name (for example, `Checkout SCM`) for the stage in the field **Name** on the right.
![edit-panel](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/edit-panel.jpg)
3. Click **Add Step**. Select **git** from the list as the example code is pulled from GitHub. In the dialog that appears, fill in the required field. Click **OK** to finish.
- **Url**. Enter the GitHub repository address `https://github.com/kubesphere/devops-java-sample.git`. Note that this is an example and you need to use your own repository address.
- **Credential ID**. You do not need to enter the Credential ID for this tutorial.
- **Branch**. It defaults to the master branch if you leave it blank. Enter `sonarqube` or leave it blank if you do not need the code analysis stage.
![enter-repo-url](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/enter-repo-url.jpg)
4. The first stage is now set.
![first-stage-set](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/first-stage-set.jpg)
#### Stage 2: Unit test
1. Click the plus icon on the right of stage 1 to add a new stage to perform a unit test in the container. Name it `Unit Test`.
![unit-test](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/unit-test.jpg)
2. Click **Add Step** and select **container** from the list. Name it `maven` and then click **OK**.
![container](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/container.jpg)
3. Click **Add nesting steps** to add a nested step under the `maven` container. Select **shell** from the list and enter the following command in the command line. Click **OK** to save it.
```shell
mvn clean -o -gs `pwd`/configuration/settings.xml test
```
{{< notice note >}}
You can specify a series of [steps](https://www.jenkins.io/doc/book/pipeline/syntax/#steps) to be executed in a given stage directive on the graphical editing panel.
{{</ notice >}}
![shell](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/shell.jpg)
![unit-test-set](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/unit-test-set.jpg)
#### Stage 3: Code analysis (Optional)
This stage uses SonarQube to test your code. You can skip this stage if you do not need the analysis.
1. Click the plus icon on the right of the `Unit Test` stage to add a stage for SonarQube code analysis in the container. Name it `Code Analysis`.
![code-analysis-stage](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/code-analysis-stage.jpg)
2. Click **Add Step** under **Task** in **Code Analysis** and select **container**. Name it `maven` and click **OK**.
![maven-container](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/maven-container.jpg)
3. Click **Add nesting steps** under the `maven` container to add a nested step. Click **withCredentials** and select the SonarQube token (`sonar-token`) from the **Credential ID** list. Input `SONAR_TOKEN` for **Text Variable**, then click **OK**.
![sonarqube-credentials](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/sonarqube-credentials.jpg)
4. Under the **withCredentials** step, click **Add Nesting steps** to add a nested step for it.
![nested-step](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/nested-step.jpg)
5. Click **withSonarQubeEnv**. In the dialog that appears, do not change the default name `sonar` and click **OK** to save it.
![sonar](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/sonar.jpg)
6. Under the **withSonarQubeEnv** step, click **Add Nesting steps** to add a nested step for it.
![add-nested-step](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/add-nested-step.jpg)
7. Click **shell** and enter the following command in the command line for the sonarqube branch and authentication. Click **OK** to finish.
```shell
mvn sonar:sonar -o -gs `pwd`/configuration/settings.xml -Dsonar.login=$SONAR_TOKEN
```
![sonarqube-shell-new](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/sonarqube-shell-new.jpg)
8. Click **Add nesting steps** (the third one) for the **container** step directly and select **timeout**. Input `1` for time and select **Hours** for unit. Click **OK** to finish.
![add-nested-step-2](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/add-nested-step-2.jpg)
![timeout](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/timeout.jpg)
9. Click **Add nesting steps** for the **timeout** step and select **waitforSonarQubeGate**. Select **Start the follow-up task after the inspection** in the pop-up dialog. Click **OK** to save it.
![waitforqualitygate](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/waitforqualitygate.jpg)
![sonar-ready](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/sonar-ready.jpg)
#### Stage 4: Build and push the image
1. Click the plus icon on the right of the previous stage to add a new stage to build and push images to Docker Hub. Name it `Build and Push`.
![build-and-push-image](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/build-and-push-image.jpg)
2. Click **Add Step** under **Task** and select **container**. Name it `maven`, and then click **OK**.
![maven-set](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/maven-set.jpg)
3. Click **Add nesting steps** under the `maven` container to add a nested step. Select **shell** from the list, and enter the following command in the pop-up window. Click **OK** to finish.
```shell
mvn -o -Dmaven.test.skip=true -gs `pwd`/configuration/settings.xml clean package
```
![nested-step-maven](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/nested-step-maven.jpg)
4. Click **Add nesting steps** again and select **shell**. Enter the following command in the command line to build a Docker image based on the [Dockerfile](https://github.com/kubesphere/devops-java-sample/blob/sonarqube/Dockerfile-online). Click **OK** to confirm.
{{< notice note >}}
DO NOT omit the dot `.` at the end of the command.
{{</ notice >}}
```shell
docker build -f Dockerfile-online -t $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BUILD_NUMBER .
```
![shell-command](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/shell-command.jpg)
5. Click **Add nesting steps** again and select **withCredentials**. Fill in the following fields in the dialog. Click **OK** to confirm.
- **Credential ID**: Select the Docker Hub credentials you created, such as `dockerhub-id`.
- **Password Variable**: Enter `DOCKER_PASSWORD`.
- **Username Variable**: Enter `DOCKER_USERNAME`.
{{< notice note >}}
For security reasons, the account information displays as variables in the script.
{{</ notice >}}
![docker-credential](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/docker-credential.jpg)
6. Click **Add nesting steps** (the first one) in the **withCredentials** step created above. Select **shell** and enter the following command in the pop-up window, which is used to log in Docker Hub. Click **OK** to confirm.
```shell
echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin
```
![login-docker-command](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/login-docker-command.jpg)
7. Click **Add nesting steps** in the **withCredentials** step. Select **shell** and enter the following command to push the SNAPSHOT image to Docker Hub. Click **OK** to finish.
```shell
docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BUILD_NUMBER
```
![push-snapshot-to-docker](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/push-snapshot-to-docker.jpg)
#### Stage 5: Generate the artifact
1. Click the plus icon on the right of the **Build and Push** stage to add a new stage to save artifacts and name it `Artifacts`. This example uses a jar package.
![add-artifact-stage](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/add-artifact-stage.jpg)
2. With the **Artifacts** stage selected, click **Add Step** under **Task** and select **archiveArtifacts**. Enter `target/*.jar` in the dialog, which is used to set the archive path of artifacts in Jenkins. Click **OK** to finish.
![artifact-info](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/artifact-info.jpg)
#### Stage 6: Deploy to development
1. Click the plus icon on the right of the stage **Artifacts** to add the last stage. Name it `Deploy to Dev`. This stage is used to deploy resources to your development environment (namely, the project of `kubesphere-sample-dev`).
![develop-to-dev](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/develop-to-dev.jpg)
2. Click **Add Step** under the **Deploy to Dev** stage. Select **input** from the list and enter `@project-admin` in the **Message** field, which means the account `project-admin` will review this pipeline when it runs to this stage. Click **OK** to save it.
![input-message](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/input-message.jpg)
3. Click **Add Step** under the **Deploy to Dev** stage again. Select **kubernetesDeploy** from the list and fill in the following fields in the dialog. Click **OK** to save it.
- **Kubeconfig**: Select the Kubeconfig you created, such as `demo-kubeconfig`.
- **Configuration File Path**: Enter `deploy/no-branch-dev/**`, which is the relative path of the Kubernetes resource [YAML](https://github.com/kubesphere/devops-java-sample/tree/sonarqube/deploy/no-branch-dev) file in the code repository.
![kubernetesDeploy](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/kubernetesDeploy.jpg)
4. If you want to receive email notifications when the pipeline runs successfully, click **Add Step** and select **mail** to add email information. Note that configuring the email server is optional, which means you can still run your pipeline if you skip this step.
{{< notice note >}}
For more information on configuring your email server, see [Set Email Server for KubeSphere Pipelines](../jenkins-email/).
{{</ notice >}}
5. When you finish the steps above, click **Confirm** and **Save** in the bottom right corner. You can see the pipeline now has a complete workflow with each stage clearly listed on the pipeline. When you define a pipeline using the graphical editing panel, KubeSphere automatically creates its corresponding Jenkinsfile. Click **Edit Jenkinsfile** to view the Jenkinsfile.
![pipeline-done](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/pipeline-done.jpg)
### Step 5: Run a Pipeline
1. You need to manually run the pipeline that is created through the graphical editing panel. Click **Run**, and you can see three string parameters defined in Step 3. Click **OK** to run the pipeline.
![run-pipeline](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/run-pipeline.jpg)
2. To see the status of a pipeline, go to the **Activity** tab and click the record you want to view.
3. Wait for a while and the pipeline stops at the stage **Deploy to Dev** if it runs successfully. As the reviewer of the pipeline, `project-admin` needs to approve it before resources are deployed to the development environment.
![pipeline-successful](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/pipeline-successful.jpg)
4. Log out of KubeSphere and log back in the console as `project-admin`. Go to your DevOps project and click the pipeline `graphical-pipeline`. Under the **Activity** tab, click the record to be reviewed. To approve the pipeline, click **Proceed**.
### Step 6: View Pipeline Details
1. Log back in the console as `project-regular`. Go to your DevOps project and click the pipeline `graphical-pipeline`. Under the **Activity** tab, click the record marked with **Success** under **Status**.
2. If everything runs successfully, you can see that all stages are completed.
![complete](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/complete.jpg)
3. Click **Show Logs** in the top right corner to inspect all the logs. Click each stage to see detailed logs of it. You can debug any problems based on the logs which also can be downloaded locally for further analysis.
![inspect-logs](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/inspect-logs.jpg)
### Step 7: Download Artifact
Click the **Artifacts** tab and then click the icon on the right to download the artifact.
![download-artifact](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/download-artifact.jpg)
### Step 8: View Code Analysis Result
On the **Code Quality** page, view the code analysis result of this example pipeline, which is provided by SonarQube. If you do not configure SonarQube in advance, this section is not available. For more information, see [Integrate SonarQube into Pipelines](../../../devops-user-guide/how-to-integrate/sonarqube/).
![sonarqube-result-detail](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/sonarqube-result-detail.jpg)
### Step 9: Verify Kubernetes Resources
1. If every stage of the pipeline runs successfully, a Docker image will be automatically built and pushed to your Docker Hub repository. Ultimately, the pipeline automatically creates a Deployment and a Service in the project you set beforehand.
2. Go to the project (i.e. `kubesphere-sample-dev` in this tutorial), click **Workloads** under **Application Workloads**, and you can see the Deployment displays in the list.
![view-deployment](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/view-deployment.jpg)
3. In **Services**, you can find the port number of the example Service is exposed through NodePort. To access the Service, visit `node IP:port number`.
![service-exposed](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/service-exposed.jpg)
![access-service](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/access-service.jpg)
{{< notice note >}}
You may need to configure port forwarding rules and open the port in your security group before you access the Service.
{{</ notice >}}
4. Now that the pipeline has run successfully, an image will be pushed to Docker Hub. Log in Docker Hub and check the result.
![dockerhub-image](/images/docs/devops-user-guide/using-devops/create-a-pipeline-using-graphical-editing-panels/dockerhub-image.jpg)
5. The app is named `devops-sample` as it is the value of `APP_NAME` and the tag is the value of `SNAPSHOT-$BUILD_NUMBER`. `$BUILD_NUMBER` is the serial number of a record under the **Activity** tab.
6. If you set the email server and add the email notification step in the final stage, you can also receive the email message.
## See Also
[Create a Pipeline Using a Jenkinsfile](../create-a-pipeline-using-jenkinsfile/)
[Choose Jenkins Agent](../choose-jenkins-agent/)
[Set Email Server for KubeSphere Pipelines](../jenkins-email/)

View File

@ -3,7 +3,7 @@ title: "使用 Jenkinsfile 创建流水线"
keywords: 'KubeSphere, Kubernetes, docker, spring boot, Jenkins, devops, ci/cd, pipeline'
description: "如何使用 Jenkinsfile 创建流水线。"
linkTitle: "使用 Jenkinsfile 创建流水线"
weight: 200
weight: 11210
---
Jenkinsfile 是一个文本文件,它包含了 Jenkins 流水线的定义并被检入源代码控制仓库。由于将整个工作流存储为代码,因此它是代码审查和流水线迭代过程的基础。有关更多信息,请参阅 [Jenkins官方文档](https://www.jenkins.io/doc/book/pipeline/jenkinsfile/)。

View File

@ -3,7 +3,7 @@ title: "凭证管理"
keywords: 'Kubernetes, docker, credential, KubeSphere, devops'
description: '本教程演示了如何在 DevOps 项目中管理凭证。'
linkTitle: "凭证管理"
weight: 400
weight: 11230
---
凭证是包含了敏感数据的对象例如用户名密码、SSH 密钥和一些 Token 等。 当 KubeSphere 流水线运行时会与很多外部环境交互如拉取代码push/pull 镜像SSH 连接至相关环境中执行脚本等,此过程中需提供一系列凭证,而这些凭证不应明文出现在流水线中。</br>

View File

@ -3,7 +3,7 @@ title: "为 KubeSphere 流水线设置电子邮件服务器"
keywords: 'KubeSphere, Kubernetes, notification, jenkins, devops, ci/cd, pipeline, email server'
description: '为 KubeSphere CI/CD 流水线设置电子邮件服务器'
linkTitle: "为 KubeSphere 流水线设置电子邮件服务器"
Weight: 400
Weight: 11260
---

View File

@ -0,0 +1,87 @@
---
title: "Jenkins System Settings"
keywords: 'Kubernetes, KubeSphere, Jenkins, CasC'
description: 'How to set up Jenkins in KubeSphere.'
linkTitle: 'Jenkins System Settings'
Weight: 11240
---
Jenkins is powerful and flexible and it has become the de facto standard for CI/CD workflows. Nevertheless, many plugins require users to set system-level configurations before they can be put to use.
The KubeSphere DevOps System offers containerized CI/CD functions based on Jenkins. To provide users with a schedulable Jenkins environment, KubeSphere uses **Configuration-as-Code** for Jenkins system settings, which requires users to log in the Jenkins dashboard and reload the configuration after it is modified. In the current release, Jenkins system settings are not available on the KubeSphere console, which will be supported in upcoming releases.
This tutorial demonstrates how to set up Jenkins and reload configurations on the Jenkins dashboard.
## Prerequisites
You have enabled [the KubeSphere DevOps System](../../../pluggable-components/devops/).
## Modify the ConfigMap
It is recommended that you configure Jenkins in KubeSphere through Configuration-as-Code (CasC). The built-in Jenkins CasC file is stored as a [ConfigMap](../../../project-user-guide/configuration/configmaps/).
1. Log in KubeSphere as `admin`. Click **Platform** in the top left corner and select **Clusters Management**.
![cluster-management](/images/docs/devops-user-guide/using-devops/jenkins-system-settings/cluster-management.jpg)
2. If you have enabled the [multi-cluster feature](../../../multicluster-management) with member clusters imported, you can select a specific cluster to edit the ConfigMap. If you have not enabled the feature, refer to the next step directly.
3. From the navigation bar, select **ConfigMaps** under **Configurations**. On the **ConfigMaps** page, select `kubesphere-devops-system` from the drop-down list and click `jenkins-casc-config`.
![edit-configmap](/images/docs/devops-user-guide/using-devops/jenkins-system-settings/edit-configmap.jpg)
4. On the detail page, click **Edit YAML** from the **More** drop-down list.
![more-list](/images/docs/devops-user-guide/using-devops/jenkins-system-settings/more-list.jpg)
5. The configuration template for `jenkins-casc-config` is a YAML file as shown below. You can modify the container image, label, etc. in the broker (Kubernetes Jenkins agent) in the ConfigMap or add a container in the podTemplate. When you finish, click **Update**.
![edit-jenkins](/images/docs/devops-user-guide/using-devops/jenkins-system-settings/edit-jenkins.jpg)
## Log in Jenkins to Reload Configurations
After you modified `jenkins-casc-config`, you need to reload your updated system configuration on the **Configuration as Code** page on the Jenkins dashboard. This is because system settings configured directly through the Jenkins dashboard may be overwritten by the CasC configuration after Jenkins is rescheduled.
1. Execute the following command to get the address of Jenkins.
```bash
export NODE_PORT=$(kubectl get --namespace kubesphere-devops-system -o jsonpath="{.spec.ports[0].nodePort}" services ks-jenkins)
export NODE_IP=$(kubectl get nodes --namespace kubesphere-devops-system -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
```
2. You can see the expected output as below, which tells you the IP address and port number of Jenkins.
```bash
http://192.168.0.4:30180
```
3. Access Jenkins at `http://Node IP:Port Number`. When KubeSphere is installed, the Jenkins dashboard is also installed by default. Besides, Jenkins is configured with KubeSphere LDAP, which means you can log in Jenkins with KubeSphere accounts (e.g. `admin/P@88w0rd`) directly.
![jenkins-dashboard](/images/docs/devops-user-guide/using-devops/jenkins-system-settings/jenkins-dashboard.jpg)
{{< notice note >}}
You may need to set up necessary port forwarding rules and open the port `30180` to access Jenkins in your security groups depending on where your instances are deployed.
{{</ notice >}}
4. After you log in the dashboard, click **Manage Jenkins** from the navigation bar.
![manage-jenkins](/images/docs/devops-user-guide/using-devops/jenkins-system-settings/manage-jenkins.jpg)
5. Scroll down and click **Configuration as Code**.
![configuration-as-code](/images/docs/devops-user-guide/using-devops/jenkins-system-settings/configuration-as-code.jpg)
6. To reload configurations that you have modified in the ConfigMap, click **Apply new configuration**.
![app-config](/images/docs/devops-user-guide/using-devops/jenkins-system-settings/app-config.jpg)
7. For more information about how to set up Jenkins via CasC, see the [Jenkins documentation](https://github.com/jenkinsci/configuration-as-code-plugin).
{{< notice note >}}
In the current version, not all plugins support CasC settings. CasC will only overwrite plugin configurations that are set up through CasC.
{{</ notice >}}

View File

@ -0,0 +1,7 @@
---
title: "Pipeline Settings"
keywords: 'KubeSphere, Kubernetes, Docker, Jenkins, pipelines'
description: ''
linkTitle: "Pipeline Settings"
weight: 11280
---

View File

@ -3,7 +3,7 @@ title: "为缓存依赖项设置 CI 节点"
keywords: 'Kubernetes, docker, KubeSphere, Jenkins, cicd, pipeline, dependency cache'
description: '如何为 KubeSphere 流水线的缓存依赖项设置 CI 节点'
linkTitle: "为缓存依赖项设置 CI 节点"
weight: 400
weight: 11270
---
通常,在构建应用程序时需要提取不同的依赖关系。 这可能会导致某些问题,例如较长的拉取时间和网络的不稳定会进一步导致构建失败。 为了为您的流水线提供更可靠和稳定的环境您可以配置一个或一组专门用于持续集成CI的节点。 这些 CI 节点可以通过使用缓存来加快构建过程。</br>

View File

@ -1,7 +0,0 @@
---
linkTitle: "DevOps Project Introduction"
weight: 2100
_build:
render: false
---

View File

@ -1,93 +0,0 @@
---
title: "Introduction"
keywords: 'kubernetes, docker, helm, jenkins, istio, prometheus'
description: 'KubeSphere Installation Overview'
linkTitle: "Introduction"
weight: 2110
---
[KubeSphere](https://kubesphere.io/) is an enterprise-grade multi-tenant container platform built on [Kubernetes](https://kubernetes.io). It provides an easy-to-use UI for users to manage application workloads and computing resources with a few clicks, which greatly reduces the learning curve and the complexity of daily work such as development, testing, operation and maintenance. KubeSphere aims to alleviate the pain points of Kubernetes including storage, network, security and ease of use, etc.
KubeSphere supports installing on cloud-hosted and on-premises Kubernetes cluster, e.g. native K8s, GKE, EKS, RKE, etc. It also supports installing on Linux host including virtual machine and bare metal with provisioning fresh Kubernetes cluster. Both of the two methods are easy and friendly to install KubeSphere. Meanwhile, KubeSphere offers not only online installer, but air-gapped installer for such environment with no access to the internet.
KubeSphere is open source project on [GitHub](https://github.com/kubesphere). There are thousands of users are using KunbeSphere, and many of them are running KubeSphere for their production workloads.
In summary, there are several installation options you can choose. Please note not all options are mutually exclusive. For instance, you can deploy KubeSphere with minimal packages on existing K8s cluster on multiple nodes in air-gapped environment. Here is the decision tree shown in the following graph you may reference for your own situation.
- [All-in-One](../all-in-one): Intall KubeSphere on a singe node. It is only for users to quickly get familar with KubeSphere.
- [Multi-Node](../multi-node): Install KubeSphere on multiple nodes. It is for testing or development.
- [Install KubeSphere on Air Gapped Linux](../install-ks-on-linux-airgapped): All images of KubeSphere have been encapsulated into a package, it is convenient for air gapped installation on Linux machines.
- [High Availability Multi-Node](../master-ha): Install high availability KubeSphere on multiple nodes which is used for production environment.
- [KubeSphere on Existing K8s](../install-on-k8s): Deploy KubeSphere on your Kubernetes cluster including cloud-hosted services such as GKE, EKS, etc.
- [KubeSphere on Air-Gapped K8s](../install-on-k8s-airgapped): Install KubeSphere on a disconnected Kubernetes cluster.
- Minimal Packages: Only install minimal required system components of KubeSphere. The minimum of resource requirement is down to 1 core and 2G memory.
- [Full Packages](../complete-installation): Install all available system components of KubeSphere including DevOps, service mesh, application store, etc.
![Installer Options](https://pek3b.qingstor.com/kubesphere-docs/png/20200305093158.png)
## Before Installation
- As the installation will pull images and update operating system from the internet, your environment must have the internet access. If not, then you need to use the air-gapped installer instead.
- For all-in-one installation, the only one node is both the master and the worker.
- For multi-node installation, you are asked to specify the node roles in the configuration file before installation.
- Your linux host must have OpenSSH Server installed.
- Please check the [ports requirements](../port-firewall) before installation.
## Quick Install For Development and Testing
KubeSphere has decoupled some components since v2.1.0. The installer only installs required components by default which brings the benefits of fast installation and minimal resource consumption. If you want to install any optional component, please check the following section [Pluggable Components Overview](../intro#pluggable-components-overview) for details.
The quick install of KubeSphere is only for development or testing since it uses local volume for storage by default. If you want a production install please refer to the section [High Availability Installation for Production Environment](../intro#high-availability-installation-for-production-environment).
### 1. Install KubeSphere on Linux
- [All-in-One](../all-in-one): It means a single-node hassle-free configuration installation with one-click.
- [Multi-Node](../multi-node): It allows you to install KubeSphere on multiple instances using local volume, which means it is not required to install storage server such as Ceph, GlusterFS.
> NoteWith regard to air-gapped installation please refer to [Install KubeSphere on Air Gapped Linux Machines](../install-ks-on-linux-airgapped).
### 2. Install KubeSphere on Existing Kubernetes
You can install KubeSphere on your existing Kubernetes cluster. Please refer [Install KubeSphere on Kubernetes](../install-on-k8s) for instructions.
## High Availability Installation for Production Environment
### 1. Install HA KubeSphere on Linux
KubeSphere installer supports installing a highly available cluster for production with the prerequisites being a load balancer and persistent storage service set up in advance.
- [Persistent Service Configuration](../storage-configuration): By default, KubeSphere Installer uses [Local Volume](https://kubernetes.io/docs/concepts/storage/volumes/#local) based on [openEBS](https://openebs.io/) to provide storage service with dynamic provisioning in Kubernetes cluster. It is convenient for quick install of testing environment. In production environment, it must have a storage server set up. Please refer [Persistent Service Configuration](../storage-configuration) for details.
- [Load Balancer Configuration for HA install](../master-ha): Before you get started with multi-node installation in production environment, you need to configure a load balancer. Either cloud LB or `HAproxy + keepalived` works for the installation.
### 2. Install HA KubeSphere on Existing Kubernetes
Before you install KubeSphere on existing Kubernetes, please check the prerequisites of the installation on Linux described above, and verify the existing Kubernetes to see if it satisfies these prerequisites or not, i.e., a load balancer and persistent storage service.
If your Kubernetes is ready, please refer [Install KubeSphere on Kubernetes](../install-on-k8s) for instructions.
> You can install KubeSphere on cloud Kubernetes service such as [Installing KubeSphere on GKE cluster](../install-on-gke)
## Pluggable Components Overview
KubeSphere has decoupled some core feature components since v2.1.0. These components are designed to be pluggable, which means you can enable any of them before or after installation. The installer by default does not install the pluggable components. Please check the guide [Enable Pluggable Components Installation](../pluggable-components) for your requirement.
![Pluggable Components](https://pek3b.qingstor.com/kubesphere-docs/png/20191207140846.png)
## Storage Configuration Instruction
The following links explain how to configure different types of persistent storage services. Please refer to [Storage Configuration Instruction](../storage-configuration) for detailed instructions regarding how to configure the storage class in KubeSphere.
- [NFS](https://kubernetes.io/docs/concepts/storage/volumes/#nfs)
- [GlusterFS](https://www.gluster.org/)
- [Ceph RBD](https://ceph.com/)
- [QingCloud Block Storage](https://docs.qingcloud.com/product/storage/volume/)
- [QingStor NeonSAN](https://docs.qingcloud.com/product/storage/volume/super_high_performance_shared_volume/)
## Add New Nodes
KubeSphere Installer allows you to scale the number of nodes, see [Add New Nodes](../add-nodes).
## Uninstall
Uninstall will remove KubeSphere from the machines. This operation is irreversible and dangerous. Please check [Uninstall](../uninstall).

View File

@ -1,93 +0,0 @@
---
title: "Introduction"
keywords: 'kubernetes, docker, helm, jenkins, istio, prometheus'
description: 'KubeSphere Installation Overview'
linkTitle: "Introduction"
weight: 2110
---
[KubeSphere](https://kubesphere.io/) is an enterprise-grade multi-tenant container platform built on [Kubernetes](https://kubernetes.io). It provides an easy-to-use UI for users to manage application workloads and computing resources with a few clicks, which greatly reduces the learning curve and the complexity of daily work such as development, testing, operation and maintenance. KubeSphere aims to alleviate the pain points of Kubernetes including storage, network, security and ease of use, etc.
KubeSphere supports installing on cloud-hosted and on-premises Kubernetes cluster, e.g. native K8s, GKE, EKS, RKE, etc. It also supports installing on Linux host including virtual machine and bare metal with provisioning fresh Kubernetes cluster. Both of the two methods are easy and friendly to install KubeSphere. Meanwhile, KubeSphere offers not only online installer, but air-gapped installer for such environment with no access to the internet.
KubeSphere is open source project on [GitHub](https://github.com/kubesphere). There are thousands of users are using KunbeSphere, and many of them are running KubeSphere for their production workloads.
In summary, there are several installation options you can choose. Please note not all options are mutually exclusive. For instance, you can deploy KubeSphere with minimal packages on existing K8s cluster on multiple nodes in air-gapped environment. Here is the decision tree shown in the following graph you may reference for your own situation.
- [All-in-One](../all-in-one): Intall KubeSphere on a singe node. It is only for users to quickly get familar with KubeSphere.
- [Multi-Node](../multi-node): Install KubeSphere on multiple nodes. It is for testing or development.
- [Install KubeSphere on Air Gapped Linux](../install-ks-on-linux-airgapped): All images of KubeSphere have been encapsulated into a package, it is convenient for air gapped installation on Linux machines.
- [High Availability Multi-Node](../master-ha): Install high availability KubeSphere on multiple nodes which is used for production environment.
- [KubeSphere on Existing K8s](../install-on-k8s): Deploy KubeSphere on your Kubernetes cluster including cloud-hosted services such as GKE, EKS, etc.
- [KubeSphere on Air-Gapped K8s](../install-on-k8s-airgapped): Install KubeSphere on a disconnected Kubernetes cluster.
- Minimal Packages: Only install minimal required system components of KubeSphere. The minimum of resource requirement is down to 1 core and 2G memory.
- [Full Packages](../complete-installation): Install all available system components of KubeSphere including DevOps, service mesh, application store, etc.
![Installer Options](https://pek3b.qingstor.com/kubesphere-docs/png/20200305093158.png)
## Before Installation
- As the installation will pull images and update operating system from the internet, your environment must have the internet access. If not, then you need to use the air-gapped installer instead.
- For all-in-one installation, the only one node is both the master and the worker.
- For multi-node installation, you are asked to specify the node roles in the configuration file before installation.
- Your linux host must have OpenSSH Server installed.
- Please check the [ports requirements](../port-firewall) before installation.
## Quick Install For Development and Testing
KubeSphere has decoupled some components since v2.1.0. The installer only installs required components by default which brings the benefits of fast installation and minimal resource consumption. If you want to install any optional component, please check the following section [Pluggable Components Overview](../intro#pluggable-components-overview) for details.
The quick install of KubeSphere is only for development or testing since it uses local volume for storage by default. If you want a production install please refer to the section [High Availability Installation for Production Environment](../intro#high-availability-installation-for-production-environment).
### 1. Install KubeSphere on Linux
- [All-in-One](../all-in-one): It means a single-node hassle-free configuration installation with one-click.
- [Multi-Node](../multi-node): It allows you to install KubeSphere on multiple instances using local volume, which means it is not required to install storage server such as Ceph, GlusterFS.
> NoteWith regard to air-gapped installation please refer to [Install KubeSphere on Air Gapped Linux Machines](../install-ks-on-linux-airgapped).
### 2. Install KubeSphere on Existing Kubernetes
You can install KubeSphere on your existing Kubernetes cluster. Please refer [Install KubeSphere on Kubernetes](../install-on-k8s) for instructions.
## High Availability Installation for Production Environment
### 1. Install HA KubeSphere on Linux
KubeSphere installer supports installing a highly available cluster for production with the prerequisites being a load balancer and persistent storage service set up in advance.
- [Persistent Service Configuration](../storage-configuration): By default, KubeSphere Installer uses [Local Volume](https://kubernetes.io/docs/concepts/storage/volumes/#local) based on [openEBS](https://openebs.io/) to provide storage service with dynamic provisioning in Kubernetes cluster. It is convenient for quick install of testing environment. In production environment, it must have a storage server set up. Please refer [Persistent Service Configuration](../storage-configuration) for details.
- [Load Balancer Configuration for HA install](../master-ha): Before you get started with multi-node installation in production environment, you need to configure a load balancer. Either cloud LB or `HAproxy + keepalived` works for the installation.
### 2. Install HA KubeSphere on Existing Kubernetes
Before you install KubeSphere on existing Kubernetes, please check the prerequisites of the installation on Linux described above, and verify the existing Kubernetes to see if it satisfies these prerequisites or not, i.e., a load balancer and persistent storage service.
If your Kubernetes is ready, please refer [Install KubeSphere on Kubernetes](../install-on-k8s) for instructions.
> You can install KubeSphere on cloud Kubernetes service such as [Installing KubeSphere on GKE cluster](../install-on-gke)
## Pluggable Components Overview
KubeSphere has decoupled some core feature components since v2.1.0. These components are designed to be pluggable, which means you can enable any of them before or after installation. The installer by default does not install the pluggable components. Please check the guide [Enable Pluggable Components Installation](../pluggable-components) for your requirement.
![Pluggable Components](https://pek3b.qingstor.com/kubesphere-docs/png/20191207140846.png)
## Storage Configuration Instruction
The following links explain how to configure different types of persistent storage services. Please refer to [Storage Configuration Instruction](../storage-configuration) for detailed instructions regarding how to configure the storage class in KubeSphere.
- [NFS](https://kubernetes.io/docs/concepts/storage/volumes/#nfs)
- [GlusterFS](https://www.gluster.org/)
- [Ceph RBD](https://ceph.com/)
- [QingCloud Block Storage](https://docs.qingcloud.com/product/storage/volume/)
- [QingStor NeonSAN](https://docs.qingcloud.com/product/storage/volume/super_high_performance_shared_volume/)
## Add New Nodes
KubeSphere Installer allows you to scale the number of nodes, see [Add New Nodes](../add-nodes).
## Uninstall
Uninstall will remove KubeSphere from the machines. This operation is irreversible and dangerous. Please check [Uninstall](../uninstall).

View File

@ -0,0 +1,7 @@
---
linkTitle: "Understand and Manage DevOps Projects"
weight: 11100
_build:
render: false
---

View File

@ -3,7 +3,7 @@ title: "DevOps 工程管理"
keywords: 'kubernetes, docker, helm, jenkins, istio, prometheus'
description: '本教程演示了如何创建和管理 DevOps 工程。'
linkTitle: "DevOps 工程管理 "
weight: 110
weight: 11120
---
本教程演示了如何创建和管理 DevOps 工程。

View File

@ -0,0 +1,8 @@
---
title: "Overview"
keywords: 'Kubernetes, KubeSphere, DevOps, overview'
description: 'This tutorial gives an overview of the KubeSphere DevOps system.'
linkTitle: "Overview"
weight: 11110
---

View File

@ -0,0 +1,85 @@
---
title: "Role and Member Management"
keywords: 'Kubernetes, KubeSphere, DevOps, role, member'
description: 'Role and Member Management'
linkTitle: "Role and Member Management"
weight: 11130
---
This guide demonstrates how to manage roles and members in your DevOps project. For more information about KubeSphere roles, see Overview of Role Management.
In DevOps project scope, you can grant the following resources' permissions to a role:
- Pipelines
- Credentials
- DevOps Settings
- Access Control
## Prerequisites
At least one DevOps project has been created, such as `demo-devops`. Besides, you need an account of the `admin` role (e.g. `devops-admin`) at the DevOps project level.
## Built-in Roles
In **Project Roles**, there are three available built-in roles as shown below. Built-in roles are created automatically by KubeSphere when a DevOps project is created and they cannot be edited or deleted.
| Built-in Roles | Description |
| ------------------ | ------------------------------------------------------------ |
| viewer | The viewer who can view all resources in the DevOps project. |
| operator | The normal member in a DevOps project who can create pipelines and credentials in the DevOps project. |
| admin | The administrator in the DevOps project who can perform any action on any resource. It gives full control over all resources in the DevOps project. |
## Create a DevOps Project Role
1. Log in the console as `devops-admin` and select a DevOps project (e.g. `demo-devops`) under **DevOps Projects** list.
{{< notice note >}}
The account `devops-admin` is used as an example. As long as the account you are using is granted a role including the authorization of **Project Members View**, **Project Roles Management** and **Project Roles View** in **Access Control** at DevOps project level, it can create a DevOps project role.
{{</ notice >}}
2. Go to **Project Roles** in **Project Management**, click **Create** and set a **Role Identifier**. In this example, a role named `pipeline-creator` will be created. Click **Edit Authorization** to continue.
![Create a devops project role](/images/docs/devops-admin/devops_role_step1.png)
3. In **Pipelines Management**, select the authorization that you want the user granted this role to have. For example, **Pipelines Management** and **Pipelines View** are selected for this role. Click **OK** to finish.
![Edit Authorization](/images/docs/devops-admin/devops_role_step2.png)
{{< notice note >}}
**Depend on** means the major authorization (the one listed after **Depend on**) needs to be selected first so that the affiliated authorization can be assigned.
{{</ notice >}}
4. Newly-created roles will be listed in **Project Roles**. You can click the three dots on the right to edit it.
![Edit Roles](/images/docs/devops-admin/devops_role_list.png)
{{< notice note >}}
The role of `pipeline-creator` is only granted **Pipelines Management** and **Pipelines View**, which may not satisfy your need. This example is only for demonstration purpose. You can create customized roles based on your needs.
{{</ notice >}}
## Invite a New Member
1. In **Project Management**, select **Project Members** and click **Invite Member**.
2. Invite a user to the DevOps project. Grant the role of `pipeline-creator` to the user.
![invite member](/images/docs/devops-admin/devops_invite_member.png)
{{< notice note >}}
The user must be invited to the DevOps project's workspace first.
{{</ notice >}}
3. After you add a user to the DevOps project, click **OK**. In **Project Members**, you can see the newly invited member listed.
4. You can also change the role of an existing member by editing it or remove it from the DevOps project.
![edit member role](/images/docs/devops-admin/devops_user_edit.png)