Simplify Deployment

Simplify Deployment

Spring Application Deployed with Kubernetes

Step by step building an application using Spring Boot and deployed via Docker on Kubernetes with Helm

full course
  1. Setup: IDE and New Project
  2. Create the Data Repository
  3. Building a Service Layer
  4. Create a REST Controller
  5. Logging, Tracing and Error Handling
  6. Documentation and Code Coverage
  7. Database as a Service
  8. Containerize the Service With Docker
  9. Docker Registry
  10. Automated Build Pipeline
  11. Helm for Deployment
  12. Setting up a Kubernetes Cluster
  13. Automating Deployment (for CICD)
  14. System Design
  15. Messaging and Event Driven Design
  16. Web UI with React
  17. Containerizing our UI
  18. UI Build Pipeline
  19. Put the UI in to Helm
  20. Creating an Ingress in Kubernetes
  21. Simplify Deployment
  22. Conclusion and Review

Now that we have multiple components lets simplify our deployment so that we can deploy our complete application in one step.

Create an Umbrella Chart

Create a new git repository called medium-application. This is the repository that will house the helm umbrella chart. Create a directory called helm and run helm create medium-application in that directory. Again, we’re not going to need hardly any of this so lets remove any files that are unnecessary.

we only need a Chart.yaml

apiVersion: v1
name: medium-application
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: 1.16.0
dependencies:
  - name: medium-customer
    version: 11
    repository: alias:codefresh
  - name: medium-customer-manager
    version: 6
    repository: alias:codefresh
  - name: medium-ingress
    version: 1
    repository: alias:codefresh

Lets go ahead and make a new pipeline to package and index this chart into our helm repo.

version: "1.0"
stages:
  - "clone"
  - "helmpublish"
steps:
  Clone:
    title: "Cloning repository"
    type: "git-clone"
    repo: "https://github.com/brianrook/medium-application"
    revision: "master"
    stage: "clone"
  HelmChartGetVersion:
    title: Get Helm Chart Version
    stage: helmpublish
    image: codefresh/cfstep-helm
    working_directory: '/codefresh/volume/medium-application'
    environment:
      - CHART_PATH=helm/medium-application
      - CHART_NAME=medium-application
    commands:
      - export ACTION=auth
      - source /opt/bin/release_chart
      - helm repo add default ${{CF_CTX_CF_HELM_DEFAULT_URL}}
      - yq .version ${CHART_PATH}/Chart.yaml
      - export CURRENT_CHART_VERSION=`helm search default/${CHART_NAME} | awk 'FNR==2{print $2}' || yq .version ${CHART_PATH}/Chart.yaml`
      - echo $CURRENT_CHART_VERSION
      - cf_export NEW_CHART_VERSION=`echo "${CURRENT_CHART_VERSION}" | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g'`
      - echo $NEW_CHART_VERSION
  HelmChartUpdate:
    title: Update Helm Chart Version
    stage: helmpublish
    image: gksoftware/yq
    working_directory: '/codefresh/volume/medium-application'
    environment:
      - CHART_PATH=helm/medium-application
      - YAML_PATH=image.tag
    commands: 
      - echo $NEW_CHART_VERSION
      - yq w -i ${CHART_PATH}/Chart.yaml version ${NEW_CHART_VERSION}
      - echo $CF_SHORT_REVISION
      - yq w -i ${CHART_PATH}/values.yaml ${YAML_PATH} '"${{CF_SHORT_REVISION}}"'
  HelmChartPush:
      title: Push Helm Chart to Chart Repository
      stage: helmpublish
      image: codefresh/cfstep-helm
      working_directory: '/codefresh/volume/medium-application'
      environment:
        - CHART_REF=helm/medium-application/
        - ACTION=push

Make sure to change your trigger to kick off from a master commit. Also make sure to add the shared configuration for the helm registry so our pipeline can access it.

Commit and Build

git checkout -b helm
git add .
git commit -m "helm chart"
git push
git checkout master
git merge helm
git push

Our pipeline should now detect that change and put our umbrella chart in the helm registry. Lets pull it down and try to deploy it.

helm repo update
helm search repo codefresh
helm delete medium
helm install medium codefresh/medium-application

Hit your endpoint and you should see the deployed application at http://medium-example.com/

0 comments on “Simplify DeploymentAdd yours →

Leave a Reply

Your email address will not be published. Required fields are marked *