Skip to content

Steadfastie/gokube

Repository files navigation

Build Release Publish

gokubelogo

🍇 gokube

This project started to master deployment of Go application to Kubernetes. The code reflects a commitment to emulating production-grade architecture and navigating implementation challenges. With sincere hope, this repository evolves into a useful template. While this page focuses on practical how-tos, the ⚓wiki is about whys

Regardless of how one configures their local development environment, running the project may require:

Updating swagger docs

Swagger is configured with 🔗swaggo/swag. Docker files are set up to automatically update Swagger docs during the build process. The very same command can be used manually:

swag init -g api/main.go -o ./api/docs  

Auth0 credentials for Swagger

🔗The officail guide does not cover a lot. If you require configured credentials or guidance on configuring them yourself, please feel free to contact me via any of my profile links

One is always welcome to open an issue or create a discussion!

🍉 Docker-compose

Execute the command within the project directory

docker-compose up -d

🍒 Kubernetes

The local developer environment for this project was constructed using:

🔗KinD

🔗Strimzi

🔗MongoDB Community Kubernetes Operator

📂 Configure KinD cluster

Execute the command within the project directory

kind create cluster --config=kind-config.yaml
Dashboard setup
  1. kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
    
  2. kubectl apply -f ./deployment/dashboard.yaml
    
  3. kubectl proxy
    
  4. kubectl -n kubernetes-dashboard create token admin-user --duration=24h
    

Next, deploy Kafka and MongoDB. When you're ready to deploy gokube services, use the following command

kubectl apply -f ./deployment

📂 Configure Kafka cluster

The easiest approach would be to follow 🔗Deploy Strimzi using installation files guide. To deploy a cluster use

kubectl apply -f ./deployment/strimzi-kafka.yaml

An alternative, albeit more intricate, method, allowing manual configuration, is well described 🔗here. However it's regrettable that Windows environments is not yet covered

📂 Configure MongoDB cluster

  1. Follow 🔗the official guilde diligently
  2. Ensure that the MongoDB user being used within gokube has the readWriteAnyDatabase role. Consider configuring it as follows:
apiVersion: mongodbcommunity.mongodb.com/v1
kind: MongoDBCommunity
metadata:
  name: example-mongodb
spec:
  members: 3
  type: ReplicaSet
...
  users:
    - name: my-user
      db: admin
...
      roles:
        - name: clusterAdmin
          db: admin
        - name: userAdminAnyDatabase
          db: admin
        - name: readWriteAnyDatabase # keep and eye here
          db: admin