In this guide, you'll learn how to deploy the Rancher Pipeline service and create a pipeline for a simple nodeJS service as an example.
-
A Rancher environment — To run Rancher Pipeline, we recommend more than two cores and 4GB memory for each host.
-
A GitHub account — Fork a repository from this pipeline-example repository.
Rancher Pipeline is available in the community-catalog.
- On the Rancher UI menu, click Catalog Catalog. The Catalog page displays.
- Search for the Rancher Pipeline template, and then click View Details. Configuration options for the template display.
- Ignore the configuration options for now, and click Launch to deploy the Pipeline stack. This process might take a few minutes. All components of your stack begin running, and a new Pipeline tab displays on the UI menu.
When all services in the Pipeline stack are in an Active
state, click Pipeline to access Pipeline UI.
Before adding a pipeline, first we need to configure source code management authentication. We will use Github OAuth for authentication in this Quick Start Guide.
-
In the top-right corner of the Pipeline UI, click the gear icon. The Settings page displays.
-
In the Git Authentication section, follow the instructions to complete the authentication. Once complete, your GitHub username displays in the Authenticated Users section.
Now we're going to add a pipeline and set up a source code management stage, a test stage to run a 'mock' test and build CI jobs, and a package stage for it.
- In the Pipeline UI, click Pipelines.
- Click Add Pipeline to create a new pipeline.
- To configure the source code repository for the pipeline, select the user and the forked repository.
- Click Add.
- On the pipeline graph, click Add a Stage. Name it
test_stage
and click Add. - Click Add a Step under the
test_stage
. - Select Run as a Service because we need to test this server in the next section.
- For Name, type
nodeserver
. We'll use this name in the next section. - For Image, select
node:8
. We're using this Docker image to run our server container. - For Command, type:
npm start
- Click Save.
Next, we need to add another step in test_stage
to test our server.
- Click Add a Step under the
test_stage
. - For Image, select
node:8
. - For Command, type:
npm install
npm test
- Under Environment Variables, click Add Variable.
- For Variable, type
SERVER
. For Value, typenodeserver
. The testing code requires you to set the environment variableSERVER
as the server address it will test against. - Click Save.
Lastly, we need to package our newly created server to a Docker image.
- Click Add a Stage and name it
package_stage
. - Click Add a Step under the
package_stage
. - For Step Type, select
build
. We're going to build and push an image. - For Image Tag, enter
<your dockerhub-id>/pipeline-helloword:latest
. - Select Push.
Note: If you haven't registered in the Rancher Registry setting, a notification for registry authentication displays. Before proceeding to the next step, follow the instructions to complete the authentication. Then, double-click Push to refresh and confirm that your registry is ready.
- Click Save.
Now we've set up a source code management stage, a test stage, and a package stage for the pipeline. Give a name to the pipeline, such as hello-world
, and then click Save. Your hello-world
pipeline displays in the list on the Pipeline page.
To manually run the pipeline, from the pipeline actions drop-down list on the right, click run.
By default, we've also registered a Webhook in GitHub. When you push to the GitHub repository, it will trigger a run of the associated pipeline. This Webhook only works if your Rancher Server is accessible from GitHub.
If you wanna make and test Rancher Pipeline yourself, just follow steps below.
- Clone this repository.
- Run
make
under your cloned directory. - After success of step 2, there will be four images(rancher/jenkins-slave:<-version->, rancher/pipeline:<-version->, rancher/pipeline-ui:<-version->, rancher/jenkins-boot:<-version->) built. Tag and Push them to your Registry.
- A Rancher environment. For each host, it is recommended to have more than 2 cores and 4 GB memory for running Rancher Pipeline.
There are two options you can select to set up the test environment.
-
Upgrade every service under
pipeline
stack to the image you built.
-
Fork community-catalog to your GitHub account.
-
Under your forked repository from step 1, modify images used in
infra-templates/pipeline/<-version->/docker-compose.yml.tpl
to the images you built. -
Add this forked repository as a Catalog in your Rancher Environment.
-
Deploy Rancher Pipeline in the Catalog of Step 3
Copyright (c) 2014-2017 Rancher Labs, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Please refer to Reference Guide for more information.