How to create a DevOps pipeline with RazorOps

Shyam Mohan K
4 min readJan 22, 2023

To create a DevOps pipeline with Razorops, you can follow these steps:

  1. Sign up for a Razorops account and create a new project.

https://dashboard.razorops.com/users/sign_in

  1. Connect your source code repository (such as GitHub, Bitbucket, or GitLab) to RazorOps.

https://dashboard.razorops.com/integration

  1. Create a new pipeline in the Razorops dashboard. You can choose from a variety of pre-configured templates or create a custom pipeline from scratch.

https://dashboard.razorops.com/apps

  1. Configure the pipeline stages, including build, test, and deploy. You can also add additional stages such as security scanning and monitoring.
# spec version (v1/v2)
version: v2
global: # defines default properties for the `tasks`
runner:
os_image: ubuntu # use Linux-VM build environment to run the tasks
variables: # environment variables to be injected into each task
- CGO_ENABLED=0
- GOOS=linux
- GOARCH=amd64
- GOFLAGS=-mod=vendor
- LD_FLAGS=-w -s

tasks:
unit-tests: # first task
steps:
- checkout # clone the git repo

# It tries to pull cached content by calculating an unique key.
- cache/pull: go-dep-{{ checksum "go.sum" }}

# fetch code dependencies ( uses go modules )
- name: Download dependencies
run: go mod vendor

- name: Execute test suite
commands:
- GO_PACKAGES=$(go list ./... | grep -v vendor)
## run tests cases and generate reports
- go test -coverprofile=coverage.out $GO_PACKAGES
- mkdir coverage && go tool cover -html=coverage.out -o coverage/index.html

# publish code dependencies with an unique key to speedup the next build
- cache/push:
key: go-dep-{{ checksum "go.sum" }}
paths: [~/go/pkg/mod]
# upload coverage report to view it later in Dashboard
- reports/html:
name: cover
dir: coverage/index.html

compile: # second task (compile and unit-tests will start in parallel)
steps:
# clone git repo
- checkout

# restore cache if available
- cache/pull: go-dep-{{ checksum "go.sum" }}

# download missing dependencies
- run: go mod vendor

# compile package
- commands:
- go build -ldflags "$LD_FLAGS" -o hack/dist/api ./cmd/server

# persist files needed for deploy task
- workspace/persist:
paths: [hack, Dockerfile.ci]

deploy:
when: branch == 'develop' # only run if code is pushed to develop branch
depends: [unit-tests, compile] # wait for compile and unit-tests to finish
steps:
# download the files persisted from upstream tasks (compile)
- workspace/attach

# build and push a Docker image. You will need to add the credentials in Dashboard
- docker/build:
image: us.gcr.io/demo/api
tags: ["${CI_COMMIT_SHA:0:8}", "${CI_REPO_BRANCH}", "latest"]
dockerfile: Dockerfile.ci
context: hack
push: true

# deploy on kubernetes cluster `example`, You need to add the credentials in Dashboard
- name: Update image using kubectl
commands:
- DOCKER_IMAGE=us.gcr.io/demo/api:${CI_COMMIT_SHA:0:8}

- kubectl config use-context example
- kubectl set image deployment/api api=$DOCKER_IMAGE
  1. Set up environment variables and secrets for the pipeline.
  1. Add triggers for the pipeline, such as when a new code is pushed to the repository or when a pull request is opened.
  2. Test the pipeline by manually triggering a build.
  3. Once the pipeline is working as expected, you can integrate it with other tools like Slack, Jira, and GitHub for better collaboration and monitoring.
  4. Monitor the pipeline and make adjustments as needed to ensure it’s running smoothly.

Note: Razorops is a cloud-native, Kubernetes-based platform. It does not require any additional infrastructure or setup. It’s also easy to integrate with existing CI/CD tools and processes.

https://razorops.com/schedule-demo?utm_source=kubeify

Click Here to Book a Free Meeting

--

--

Shyam Mohan K

Founder at RazorOps CICD, I love Container Native DevOps with Docker and Kubernetes, SO