Spring Application Deployed with Kubernetes
Step by step building an application using Spring Boot and deployed via Docker on Kubernetes with Helm
full course- Setup: IDE and New Project
- Create the Data Repository
- Building a Service Layer
- Create a REST Controller
- Logging, Tracing and Error Handling
- Documentation and Code Coverage
- Database as a Service
- Containerize the Service With Docker
- Docker Registry
- Automated Build Pipeline
- Helm for Deployment
- Setting up a Kubernetes Cluster
- Automating Deployment (for CICD)
- System Design
- Messaging and Event Driven Design
- Web UI with React
- Containerizing our UI
- UI Build Pipeline
- Put the UI in to Helm
- Creating an Ingress in Kubernetes
- Simplify Deployment
- Conclusion and Review
Lets set up automated build so that we can generate a docker image when a change hits master.
Build the Pipeline
Go in to codefresh and choose Projects. Create a new project in the top right. Call it medium
. Click on create pipeline. Call the pipeline medium-customer and choose our git repository from github. In the pipeline editor, add this yaml:
# More examples of Codefresh YAML can be found at
# https://codefresh.io/docs/docs/yaml-examples/examples/
version: "1.0"
# Stages can help you organize your steps in stages
stages:
- "clone"
- "build"
- "push"
steps:
Clone:
title: "Cloning repository"
type: "git-clone"
repo: "https://github.com/brianrook/medium-customer"
revision: "master"
stage: "clone"
PrintFileList:
title: 'Listing files'
stage: "clone"
image: alpine:latest
commands:
- 'ls -l'
BuildJar:
title: Create Jar
stage: "build"
image: 'maven:3.6.3-jdk-11'
commands:
- mvn -Dmaven.repo.local=/codefresh/volume/m2_repository clean package
working_directory: '/codefresh/volume/medium-customer'
BuildImage:
title: Building Docker Image
type: build
stage: build
image_name: medium/medium-customer
working_directory: '/codefresh/volume/medium-customer'
tag: '${{CF_SHORT_REVISION}}'
dockerfile: Dockerfile
PushToCodeFresh:
type: push
stage: "push"
title: Push to Remote Repository
candidate: ${{BuildImage}}
tag: '${{CF_SHORT_REVISION}}'
image_name: medium-customer
registry: cfcr
fail_fast: false
We’re telling the build pipeline to clone our repo, use maven to build the jar and then execute docker build (like we did in the last section) to package the jar into an image. We then push that image to codefresh’s docker image registry.
Go ahead and run it and make sure that it builds an image correctly. We can view the docker image registry via the browser to confirm the build.
Hooking it into Our Master Commit
We should have a trigger already set. Click on triggers on the right bar and confirm that a trigger for github exists. You can view it with the pencil. It should be listening for push commits. We can test that by making a commit to any of our branches.
0 comments on “Automated Build Pipeline”Add yours →