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
devopscorner/bookstore:alpine docker image size
devopscorner/bookstore:alpine-latest docker image size
devopscorner/bookstore:alpine-3.15 docker image size
devopscorner/bookstore:go1.18-alpine3.15 docker image size
devopscorner/bookstore:go1.19-alpine3.15 docker image size
devopscorner/bookstore:alpine-3.16 docker image size
devopscorner/bookstore:go1.18-alpine3.16 docker image size
devopscorner/bookstore:go1.19-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

Development

Prequests

  • Install jq libraries

    apt-get install -y jq
    
  • Install golang dependencies

    go mod init
    go mod tidy
    

Runnning

go run main.go

API Test

  • Get Books
GET    : /books
         curl --request GET \
            --url 'http://localhost:8080/books' \
            --header 'Content-Type: application/json' | jq
  • Add Book 1
POST   : /books
         curl --request POST \
            --url 'http://localhost:8080/books' \
            --header 'Content-Type: application/json' \
            --data '{
                "title": "Mastering Go: Create Golang production applications using network libraries, concurrency, and advanced Go data structures",
                "author": "Mihalis Tsoukalos"
            }' | jq
  • Add Book 2
POST   : /books
         curl --request POST \
            --url 'http://localhost:8080/books' \
            --header 'Content-Type: application/json' \
            --data '{
                "title": "Introducing Go: Build Reliable, Scalable Programs",
                "author": "Caleb Doxsey"
            }' | jq
  • Add Book 3
POST   : /books
         curl --request POST \
            --url 'http://localhost:8080/books' \
            --header 'Content-Type: application/json' \
            --data '{
                "title": "Learning Functional Programming in Go: Change the way you approach your applications using functional programming in Go",
                "author": "Lex Sheehan"
            }' | jq
  • Edit Book 3
PATCH   : /books/3
         curl --request PATCH \
            --url 'http://localhost:8080/books/3' \
            --header 'Content-Type: application/json' \
            --data '{
                "title": "Test Golang",
                "author": "ZeroC0D3Lab"
            }' | jq
  • Delete Book 3
DELETE   : /books/3
         curl --request DELETE \
            --url 'http://localhost:8080/books/3' \
            --header 'Content-Type: application/json' | jq

Tested Environment

Versioning

  • Docker version

    docker version
    
    Client:
    Cloud integration: v1.0.22
    Version:           20.10.12
    API version:       1.41
    Go version:        go1.16.12
    Git commit:        e91ed57
    Built:             Mon Dec 13 11:46:56 2021
    OS/Arch:           darwin/amd64
    Context:           default
    Experimental:      true
    
  • Docker-Compose version

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

    aws -v
    ---
    Note: AWS CLI version 2, the latest major version of the AWS CLI, is now stable and recommended for general use. For more information, see the AWS CLI version 2 installation instructions at: <https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html>
    
  • Terraform Cli

    terraform version
    ---
    Terraform v1.1.6
    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
    

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