Skip to content

Kubernetes Deployment for Simple Golang API (Bookstore) --- Mirror Repository from GitHub, GitLab, BitBucket, Azure DevOps to AWS CodeCommit --- GO Repository Pattern

License

Notifications You must be signed in to change notification settings

devopscorner/golang-deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang Deployment

Kubernetes Deployment for Simple Golang API

goreport all contributors tags docker pulls download all download latest view clone issues pull requests forks stars license


Available Tags

Alpine

Image name Size
devopscorner/bookstore:latest docker image size default-latest latest
devopscorner/bookstore:alpine docker image size latest
devopscorner/bookstore:alpine-latest docker image size
devopscorner/bookstore:alpine-3.16 docker image size
devopscorner/bookstore:go1.19-alpine3.16 docker image size
devopscorner/bookstore:go1.19.5-alpine3.16 docker image size
devopscorner/bookstore:alpine-3.17 docker image size
devopscorner/bookstore:go1.19-alpine3.17 docker image size
devopscorner/bookstore:go1.19.5-alpine3.17 docker image size

Previous Version - Alpine (Depreciated)

Image name Size
devopscorner/bookstore:alpine-3.15 docker image size
devopscorner/bookstore:go1.19-alpine3.15 docker image size
devopscorner/bookstore:go1.19.3-alpine3.15 docker image size
devopscorner/bookstore:go1.18-alpine3.15 docker image size
devopscorner/bookstore:go1.18-alpine3.16 docker image size

Documentation

  • Index Documentation, go to this link
  • Build, Tag & Push container image to DockerHub, go to this link
  • Build, Tag & Push container image to Amazon ECR (Elastic Container Registry), go to this link
  • Workflow CI/CD Pipeline, go to this link
  • GitOps & GitOps DevSecOps Flow (Azure DevOps Pipeline), go to this link
  • Deployments:
    • ArgoCD, detail here link
    • AWS CloudFormation, detail here link
    • AWS Developer Tools (AWS CodeCommit, AWS CodeBuild & AWS CodePipeline), detail here link
    • Amazon CodeCatalyst Pipeline, detail here link
    • Azure DevOps Pipeline, detail here link
    • Bitbucket Pipeline, detail here link
    • CircleCI Pipeline, detail here link
    • DroneCI Pipeline, detail here link
    • GitHub Action, detail here link
    • GitLab CI/CD, detail here link
    • Jenkins CI & Spinnaker CD, detail here link
    • Jenkins CI/CD, detail here link
    • OpenShift CI/CD, detail here link
    • SemaphoreCI, detail here link
    • Spinnaker CD, detail here link
    • Terraform AWS CodeBuild, AWS CodePipeline & Amazon SNS, detail here link
    • TravisCI, detail here link

GO Repository Pattern

  • Folder Structure

        .
        ├── .env
        ├── .env.example
        ├── config
        │   ├── config.go
        │   ├── config_test.go
        │   └── const.go
        ├── controller
        │   ├── book_controller.go
        │   ├── book_controller_test.go
        │   ├── login_controller.go
        │   └── login_controller_test.go
        ├── driver
        │   ├── db.go
        │   ├── dynamo.go
        │   ├── mysql.go
        │   ├── psql.go
        │   └── sqlite.go
        ├── go-bookstore.db
        ├── go.mod
        ├── go.sum
        ├── main.go
        ├── main_test.go
        ├── middleware
        │   ├── auth_middleware.go
        │   └── auth_middleware_test.go
        ├── migrate_book.go.example
        ├── migrate_book_dynamo.go.example
        ├── model
        │   └── book.go
        ├── repository
        │   └── book_repository.go
        ├── routes
        │   └── book_routes.go
        └── view
            ├── book_view.go
            ├── error_view.go
            └── login_view.go
    
        9 directories, 29 files
    
  • Environment Variables (Default)

    GIN_MODE=release
    APP_URL=http://localhost
    APP_PORT=8080
    DB_CONNECTION=sqlite
    DB_REGION=ap-southeast-1
    DB_HOST=localhost
    DB_PORT=
    DB_DATABASE=go-bookstore.db
    DB_USERNAME=root
    DB_PASSWORD=
    JWT_AUTH_USERNAME=devopscorner
    JWT_AUTH_PASSWORD=DevOpsCorner@2023
    JWT_SECRET=s3cr3t
    
  • Multi Driver Connection

    DB_CONNECTION=sqlite
    ---
    Available for:
    - sqlite
    - mysql
    - postgres
    - dynamo
    
  • DynamoDB Connection

    DB_CONNECTION=dynamo
    ---
    DB_DATABASE --> Dynamo Table
    DB_REGION   --> Dynamo Region
    

Reproduce Testing

  • RESTful API Testing, go to this link

Tested Environment

Versioning

  • Docker version

    docker version
    
    Client:
      Cloud integration: v1.0.22
      Version:           20.10.17-rd
      API version:       1.41
      Go version:        go1.17.11
      Git commit:        c2e4e01
      Built:             Fri Jul 22 18:31:17 2022
      OS/Arch:           darwin/amd64
      Context:           default
      Experimental:      true
    
  • Docker-Compose version

    docker-compose -v
    ---
    Docker Compose version v2.11.1
    
  • AWS Cli

    aws --version
    ---
    aws-cli/2.8.7 Python/3.9.11 Darwin/21.6.0 exe/x86_64 prompt/off
    
  • Terraform Cli

    terraform version
    ---
    Terraform v1.3.5
    on darwin_amd64
    - provider registry.terraform.io/hashicorp/aws v3.74.3
    - provider registry.terraform.io/hashicorp/local v2.1.0
    - provider registry.terraform.io/hashicorp/null v3.1.0
    - provider registry.terraform.io/hashicorp/random v3.1.0
    - provider registry.terraform.io/hashicorp/time v0.7.2
    
  • Terraform Environment Cli

    tfenv -v
    ---
    tfenv 2.2.2
    
  • Golang Version Manager (GVM)

    gvm version
    ---
    Go Version Manager v1.0.22 installed at /Users/devopscorner/.gvm
    
  • Golang Version

    go version
    ---
    go version go1.19.6 darwin/arm64
    

Security Check

Make sure that you didn't push sensitive information in this repository

  • AWS Credentials (AWS_ACCESS_KEY, AWS_SECRET_KEY)
  • AWS Account ID
  • AWS Resources ARN
  • Username & Password
  • Private (id_rsa) & Public Key (id_rsa.pub)
  • DNS Zone ID
  • APP & API Key

Copyright

  • Author: Dwi Fahni Denni (@zeroc0d3)
  • Vendor: DevOps Corner Indonesia (devopscorner.id)
  • License: Apache v2