Coder Social home page Coder Social logo

octopus's Introduction

Octopus

Simple and Tested HTTP Server in Go for CI Experimentations.

This repository contains a simple HTTP server implemented in Go, designed for CI experimentations. The server includes features such as Dockerfile configuration, end-to-end tests using Playwright, unit testing, an endpoint with a database connection, deployment with Kustomization in staging and production environments, and support for canary deployment.

Features

  • HTTP Server in Go: A basic HTTP server written in Go to serve as a foundation for CI experiments.

  • Dockerfile: Includes a Dockerfile for containerizing the Go application.

  • End-to-End Tests with Playwright: Provides end-to-end tests using Playwright to ensure the reliability of the application.

  • Unit Testing: Includes unit tests for the Go codebase.

  • Database Connection: Demonstrates an endpoint with a database connection for more realistic scenarios.

  • Deployment with Kustomization:

    • Configurations for staging and production environments using Kustomize.
    • Secrets for sensitive information like DATABASE_PASSWORD and private registry credentials.
  • Canary Deployment: Supports canary deployments for gradual rollouts.

Prerequisites

Before you begin, ensure you have the following:

Configuration

Before deploying, make sure to configure the necessary secrets:

Secrets

  1. DATABASE_PASSWORD:

    • Create a secret named database-secret in your Kubernetes cluster with the key DATABASE_PASSWORD. Update the value accordingly.

      kubectl create secret generic database-secret --from-literal=DATABASE_PASSWORD=your_password_here
  2. Private Registry Credentials:

    • Create a secret named registry-secret in your Kubernetes cluster with the Docker registry credentials. You can create the .dockerconfigjson file and then create the secret using:

      kubectl create secret generic registry-secret --from-file=.dockerconfigjson=/path/to/your/.dockerconfigjson

    Ensure that your .dockerconfigjson contains credentials for your private Docker registry.

Usage

  1. Clone the repository:

    git clone https://github.com/michaelahli/octopus.git
    cd octopus
  2. Build the Docker image:

    docker build -t octopus:latest .
  3. Run the Docker container:

    docker run -p 8080:8080 -e DATABASE_PASSWORD=your_database_password -d octopus:latest

    Replace your_database_password with the actual database password.

  4. Access the application at http://localhost:8080.

Deployment

Staging Environment

Deploy to the staging environment using Kustomize:

cd deploy/overlays/staging
kustomize edit set image host.docker.internal:30500/octopus=host.docker.internal:5000/octopus:latest
kustomize build | kubectl apply -f -

Production Environment

Deploy to the production environment using Kustomize:

cd deploy/overlays/production
kustomize edit set image host.docker.internal:30500/octopus=host.docker.internal:5000/octopus:latest
kustomize build | kubectl apply -f -

Canary Deployment

For canary deployment, modify the Kustomization file in the k8s/canary directory as needed and apply the changes:

cd deploy/overlays/canary
kustomize edit set image host.docker.internal:30500/octopus=host.docker.internal:5000/octopus:latest
kustomize build | kubectl apply -f -

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.