Golang
Go Application Stack
The Go application stack is used to build and deploy Go applications and produce deployment-ready containers for the SCALE environment.
The containers produced in this application stack share common requirements with other application stacks deployed to the SCALE environment. These shared requirements include:
- Security scanning for any vulnerabilities
- Code coverage scanning for test quality
- Staging of the application container in the appropriate Docker container repositories and tagged according to SCALE conventions
- Completion of Unit Testing and User Acceptance Testing
- Gated approvals before allowing deployments into pre-production and production environments
- Audit trail and history of deployment within the SCALE CI/CD Pipeline
Because of the above-listed requirements, the Go application stack is provided in order to support the build and deployment of Go applications in a manner that integrates with SCALE requirements and processes. The flow of deployment includes first a Continuous Integration stage of processing in a pipeline prior to deployment in the Continuous Deployment stages. The Continuous Integration stage focuses on building the application, running scans to check for test coverage and security vulnerabilities, and staging the container in the appropriate Docker repository ready for deployment. Subsequent pipeline stages deploy the application to the appropriate target Kubernetes spaces.
For details on getting started, see getting started.
For details on repository structure, see repository structure.
The source directory contains boilerplate code creating a Go application.
For details on application configuration, see application configuration.
For details on CI/CD pipelines, see CI/CD pipelines.
For details on pipeline definition, see pipeline definition.
Upgrading to Pipeline v4.7
Note: Please refer to v4.4 of the Go documentation for details on Go upgrade.
For details on upgrading to Pipeline v4.7, see upgrading to Pipeline v4.7.
Backward Compactibility
To avoid any potential build issues during the pipeline process, it is important to specify the Golang version explicitly in your azure-pipelines.yml file. Add the below variable in your azure-pipelines.yml file.
appVersion: 4.7.0
golang:
version: '1.17'
Application-Specific Pipeline Configuration
The extends YAML object is a complex object consisting of additional YAML objects. This object is used to extend the v4.7 pipeline logic (referenced by the repository defined in the resources object) by (a) referencing the correct appstack pipeline entry point (devops/golang.yml for the Go pipeline) and (b) passing a set of YAML objects as parameters to influence the behavior of the pipeline to meet an application teams specific needs.
The extends YAML object consists of 2 objects beneath it:
- template
- parameters
The template YAML object is a single value set to the initial entry point for the v4.7 pipeline for the Go appstack, so it should always be defined as follows:
extends:
template: devops/golang.yml@spaces
The parameters YAML object is defined immediately following the template object and at the same indentation level. This is the object that requires the most attention and definition to be set up.
The parameters YAML object includes multiple parameters which can be used to configure CI/CD pipeline. Primarily this object contains parameters used for application builds. A typical setting in here would be to define appVersion used to build the application, looking like the following (including all of the extends object preceding it):
extends:
template: devops/golang.yml@spaces
parameters:
appVersion: 4.7.x
Go version configuration
Generally, CI/CD pipeline uses Go 1.19 for building Go application. This can be overridden by configuring Go version as follows:
extends:
template: devops/golang.yml@spaces
parameters:
golang:
version: 1.19 # Minimum version must be 1.11
Minimum supported version for Go is 1.11.
Go image configuration
Pipeline uses latest ubi8/ubi-minimal image as base image for building Go application docker image. Different image can be configured using baseImage parameter as follows:
extends:
template: devops/golang.yml@spaces
parameters:
golang:
baseImage: "ubuntu:latest"
For details on skipping deployments, see skipping deployments.
For details on defining hostspaces, see defining hostspaces.
For details on Horizontal Pod Autoscaler, see Horizontal Pod Autoscaler.
For details on PVC for application stacks, see PVC for application stacks.
DR Changes
With the introduction of pipeline v4.7, we have implemented DR capabilities that require changes in the Helm chart. Please refer to this document below for the necessary modifications and kindly update your Helm chart accordingly.
Please refer to the following document to prepare your codebase for disaster recovery. DR Config Map and Ingress Setup
For details on Pod Anti-Affinity, see Pod Anti-Affinity.
For details on detailed pipeline configuration, see detailed pipeline configuration.
For details on Kubernetes deployment objects, see Kubernetes deployment objects.
For details on troubleshooting, see troubleshooting.