Simple Golang CloudNative App

Simple Golang CloudNative App

This is a sample sample repo will explain how you build simple golang app locally , contanairze it and deploy into a Kubernetes cluster. You can check GitHub actions for sample PR builds and CI builds.

In the second part I propose Ideal workflow for CI/CD piplene.

Fixes

Changing quote v3 import -> make quote v3 as a named import · lkravi/golang@1bcbb58 · GitHub

Changing localhost to multicast -> making localhost to multicast, to serve all incoming requests instead… · lkravi/golang@e1c47c4 · GitHub

Changing Docker file to multi-stage build -> https://github.com/lkravi/golang/commit/8354e996bd2870ae2420e1219c64bd117bdb348a

Test Golang app locally

go mod init github.com/lkravi/golang
go mod tidy
go build -o golang-test
./golang-test

This will bring up the web-server on port 8000. You can check your browser

Build Docker Image

We are using multi-stage docker build as we don't need to include build dependencies in to running container.

docker build . -t golang-test

#Check docker container locally
docker run -p 8000:8000 golang-test

Deploying to Kubernates Cluster

You can find sample yaml files for kubernates deployment inside the /k8s directory.

kubectl apply -f k8s/deployment.yaml

#Check your service locally using port-forwading
kubectl port-forward service/golang-test-service 8000:80

Ideal CI/CD Pipeline

Alt text

01 - PR build and CI build on merge

  • Run Unit tests
  • Static code analysis
    • SonarQube
      • Inspection of code quality to perform review to detect code smells, security vulnerabilities and bugs.
    • Fortify / CheckMarks
      • Static application security testing tool for scan security vulnerabilities.
    • Lint Tools
      • Lint tool used to check for programmatic and stylistic errors.
  • Build failure notifications / JIRA ticket upgrade etc.
  • Build artefacts on merge builds. tag them as snapshot/dev and upload to artefact repository.
  • Deploy that artefact to development environment.

Pull requests merged after quality gate checks and code review approvals.

02 - Release branch builds

  • Run Unit tests
  • Static code analysis
    • Refer step #1 for more detail
  • Dynamic code analysis
    • Fortify Webinspect / App Spider
      • Dynamic application security testing tool that identifies application vulnerabilities in deployed web application and services.
  • Build artefacts on merge builds, tag them with correct version (git tags) and upload to artefact repository.
  • Artefact analysis
    • Twistlock / Trivy / Clair
      • Vulnerability scanners for container images.
    • Nexus IQ
      • Policy violations, Security Issues, License analysis
  • Deploy that artefacts to Test Environment.

When feature completed or when development branch needed to work on next release changes. we need to create a release branch. Release branch builds will create versioned artefact which can promote across Test, UAT, Production based on verification success.

03 - Continuous deployment

  • Deploy to Staging and Production on demand using push button deployments.
    • Promote artefacts to Staging/UAT and Production environments using continuous deployment mechanisms.
      • Can use specialised tools like GitOPS (Flux, ArgoCD), GoCD for continuous deployment.
      • Use Infrastructure as code scripts to maintain environment states/resources.

Deployment artefacts are configured to take environment variable based parameters/ k8s cluster based secrets and config maps to support different environment configurations.

Alt text

  • Application configurations are stored in config maps.
  • Application sensitive information stored in cluster secrets.
  • Each pods have health-check routes and deployments configured Kubernates pod health-checks.
  • Ingress proxy(nginx, traefik) is configured to handle and route external requests to correct services.
    • In this setup TLS termination happen in Load Balancer level.
    • However based on the requirement if we need to manage our own cert-manager and TLS termination inside the cluster. It can be done using a tool like jetstack cert manager.
  • RABC configured to control resources changes/ unauthorised access to cluster.
  • Rolling released based deployment ensure zero outage deployments.

Additional Notes

SonarCloud : https://sonarcloud.io/summary/overall?id=lkravi-golang

Docker Image : Docker Hub

Similar Resources

Go-cent-app - CENT.APP GO Package

CENT.APP - GO Package Official documentation - https://cent.app/en/merchant/api

Dec 20, 2022

This is for managing Slack App Manifests, it is no use if you are not developing an App for Slack.

Terraform Provider Slack App This is for managing Slack App Manifests, it is no use if you are not developing an App for Slack. Requirements Terraform

May 23, 2022

Simple-Weather-API - Simple weather api app created using golang and Open Weather API key

Simple-Weather-API - Simple weather api app created using golang and Open Weather API key

Simple Weather API Simple weather api app created using golang and Open Weather

Feb 6, 2022

Simple-go-api - This porject deploys a simple go app inside a EKS Cluster

SimpleGoApp This porject deploys a simple go app inside a EKS Cluster Prerequisi

Jan 19, 2022

An app skeleton for very simple golang web applications

Golang App Skeleton This is a skeleton for a golang web application optimized for simplicity and rapid development. Prerequisites Go 1.15 or greater O

Oct 16, 2022

Simple Golang Load testing app built on top of vegeta

Simple Golang Load testing app built on top of vegeta

LOVE AND WAR : Give Your App Love By Unleashing War Simple load testing app to test your http services Installation Build docker image: docker build -

Oct 26, 2021

A simple zip compactor app written in golang to help you life. Usage with native GUI and CLI.

A simple zip compactor app written in golang to help you life. Usage with native GUI and CLI.

Usage Install go install github.com/gustavonobreza/zip-compactor Run in GUI (Can select many files) zip-compactor Run in CLI (Can select just one file

Nov 12, 2021

Arjuns-urgent-notification-backend - A simple Golang app that handles form JSON POST requests

Arjun's Urgent Notification Backend This is intended to let people urgently noti

Jan 7, 2022

This is repository for Simple HTTP GET golang app that counts standard deviation from random.org integers

Simple Get Deviation App This is repository for Simple HTTP GET golang app that counts standard deviation from random.org integers IMPORTANT: Because

Jan 10, 2022

Go-get-gin - Simple golang app deployed on gcp

go-get-gin a simple golang gin app to be deployed on gcp Getting started make su

Jan 12, 2022

A simple app to produce messages to sqs by using aws sdk v2 package for Golang.

go-sqs-producer A simple app to produce messages to SQS by using aws sdk v2 package for Golang in performatic meaning. How to run | go 1.17 or above i

Apr 22, 2022

Golang-demo - A repo for app golang-demo; bootstrapped by DevStream

golang-demo This is a repo for app golang-demo; bootstrapped by DevStream. By de

Mar 1, 2022

This is a simple chat app which shows how to use Go with Hotwire.

This is a simple chat app which shows how to use Go with Hotwire.

chat-hotwire-go This is a simple chat app which shows how to use Go with Hotwire. Messages from another user are received via Turbo Streams over a web

Jul 2, 2022

Simple web app using Go and Gin framework

go-gin-app Simple web app using Go and Gin framework Golang 과 Gin 프레임워크를 사용한 간단한 웹 앱 How to get Started Install Gin and have Go installed on your syst

Oct 18, 2021

📡 mock is a simple, cross-platform, cli app to simulate HTTP-based APIs.

 📡 mock is a simple, cross-platform, cli app to simulate HTTP-based APIs.

mock 📡 mock is a simple, cross-platform, cli app to simulate HTTP-based APIs. About mock Mock allows you to spin up a local http server based of a .m

May 6, 2022

Simple CLI App for creating recurring google calendar events

Kronus A CLI App to help you stay in touch with the people that matter by leveraging the google calender API. You can create touchbase events for cont

Nov 7, 2022

This is a very simple web-app which simply always returns HTTP status code 200

Responder This is a very simple web-app which simply always returns HTTP status code 200. It will also wait for an amount of time which can be set in

Dec 14, 2021

simple cli app for search and watch anime

simple terminal app for search and watch movie or anime

Oct 30, 2021

This is a simple version of user profile using Echo app.

This is a simple version of user profile using Echo app.

Overview It's an API of simple profile to CRUD profile user based on Echo framework. How to run it Run the application using the command in the termin

Nov 3, 2021
Go language interface to Swift / Openstack Object Storage / Rackspace cloud files (golang)

Swift This package provides an easy to use library for interfacing with Swift / Openstack Object Storage / Rackspace cloud files from the Go Language

Nov 9, 2022
Cloudpods is a cloud-native open source unified multi/hybrid-cloud platform developed with Golang
Cloudpods is a cloud-native open source unified multi/hybrid-cloud platform developed with Golang

Cloudpods is a cloud-native open source unified multi/hybrid-cloud platform developed with Golang, i.e. Cloudpods is a cloud on clouds. Cloudpods is able to manage not only on-premise KVM/baremetals, but also resources from many cloud accounts across many cloud providers. It hides the differences of underlying cloud providers and exposes one set of APIs that allow programatically interacting with these many clouds.

Jan 11, 2022
A simple Go app and GitHub workflow that shows how to use GitHub Actions to test, build and deploy a Go app to Docker Hub

go-pipeline-demo A repository containing a simple Go app and GitHub workflow that shows how to use GitHub Actions to test, build and deploy a Go app t

Nov 17, 2021
High-Performance Shortlink ( Short URL ) app creator in Golang. For privacy reasons, you may prefer to host your own short URL app and this is the one to use.
High-Performance Shortlink ( Short URL ) app creator in Golang. For privacy reasons, you may prefer to host your own short URL app and this is the one to use.

About The Project Shortlink App in Golang Multiple Node based Architecture to create and scale at ease Highly performant key-value storage system Cent

Jan 3, 2023
How to get a Go / Golang app using the Gin web framework running natively on Windows Azure App Service WITHOUT using a Docker container

Go on Azure App Service View the running app -> https://go-azure-appservice.azurewebsites.net ?? This is an example repo of how to get a Go / Golang a

Nov 28, 2022
記帳-PWA-web-app (Bookkeeping-PWA-web-app)
記帳-PWA-web-app (Bookkeeping-PWA-web-app)

GoKeep (bookkeeping web app) 記帳-PWA-web-app (Bookkeeping-PWA-web-app) demo link : https://bookkepping.herokuapp.com/ 測試用帳密 : tester002 , tester002 (亦可

Jan 31, 2022
Built Virtual Operating System and integrated application like calculator, gallery app , weather app, and text editor.
Built Virtual Operating System and integrated application like calculator, gallery app , weather app, and text editor.

Virtual Operating System Built Virtual Operating System and integrated application like calculator, gallery app , weather app, and text editor. Langua

Nov 2, 2021
CLI and web app to convert HTML markup to go-app.dev's syntax.
CLI and web app to convert HTML markup to go-app.dev's syntax.

HTML to go-app Converter CLI and web app to convert HTML markup to go-app.dev's syntax. Installation CLI Static binaries are also available on GitHub

Dec 18, 2022
Test-app-url-shortner - A sample url shortener app to test Keploy integration capabilities
Test-app-url-shortner - A sample url shortener app to test Keploy integration capabilities

test-app-url-shortner A sample url shortener app to test Keploy integration capa

Jan 23, 2022