|
1 | | -# origoss-task |
| 1 | +# origoss-task |
| 2 | + |
| 3 | +<div align="center"> |
| 4 | + <img src="https://origoss.com/images/logo.svg" alt="Logo" width="160" height="80"> |
| 5 | + |
| 6 | + <h3 align="center">Origoss Task</h3> |
| 7 | + <p align="center">An HTTP server and its infrastructure</p> |
| 8 | +</div> |
| 9 | + |
| 10 | +## About This Project |
| 11 | +This project demonstrates a complete end-to-end workflow for deploying a simple Go HTTP server with modern infrastructure practices. |
| 12 | +## Features: |
| 13 | +- A **Go HTTP server** that responds with `Hello, World!` at `/` |
| 14 | +- A **Dockerfile** for server containerization |
| 15 | +- A **GitHub CI workflow** for building and pushing the server changes to Docker Hub |
| 16 | +- **Kubernetes manifests** for deployment, service, and ingress |
| 17 | +- **Terraform infrastructure** replicating the Kubernetes resources plus some additional enhancements |
| 18 | +- Deployment is designed for a **Minikube** cluster for local development |
| 19 | + |
| 20 | + |
| 21 | +## Languages and Technologies |
| 22 | + |
| 23 | +- [](#) Server Programming Language |
| 24 | +- [](#) Containerization |
| 25 | +- [](#) Orchestration |
| 26 | +- [](#) Infrastructure-as-Code |
| 27 | +- [](#) Local Cluster |
| 28 | +- [](#) CI |
| 29 | + |
| 30 | + |
| 31 | +## Set Up |
| 32 | +### Prerequisites |
| 33 | + |
| 34 | +- [Go](https://go.dev/) |
| 35 | +- [Docker](https://www.docker.com/) |
| 36 | +- [Minikube](https://minikube.sigs.k8s.io/) |
| 37 | +- [kubectl](https://kubernetes.io/) |
| 38 | +- [Terraform](https://developer.hashicorp.com/terraform/) |
| 39 | + |
| 40 | + |
| 41 | +### Installation |
| 42 | + |
| 43 | +1. **Clone the repository** |
| 44 | + |
| 45 | +```bash |
| 46 | +git clone https://github.com/your-username/origoss-task.git |
| 47 | +cd origoss-task |
| 48 | +``` |
| 49 | + |
| 50 | +2. **Start Minikube** |
| 51 | + |
| 52 | +```bash |
| 53 | +minikube start |
| 54 | +``` |
| 55 | + |
| 56 | +3. **Add local domain to host list** |
| 57 | + |
| 58 | +Aquire Minikube IP and add to `/etc/hosts` |
| 59 | +```bash |
| 60 | +echo "$(minikube ip) origoss-task.local" | sudo tee -a /etc/hosts |
| 61 | +``` |
| 62 | + |
| 63 | + |
| 64 | +## Usage |
| 65 | + |
| 66 | +There are a two ways to use the Minikube cluster. There are kubernetes manifest YAML files and also a terraform infrastructure. |
| 67 | + |
| 68 | +### Via Kubernetes Manifest |
| 69 | + |
| 70 | +1. **Apply the manifests** |
| 71 | + |
| 72 | +```bash |
| 73 | +cd kubernetes |
| 74 | +kubectl apply -f deployment.yaml -f service.yaml -f ingress.yaml |
| 75 | +``` |
| 76 | + |
| 77 | +2. **Access the server** |
| 78 | + |
| 79 | +```bash |
| 80 | +curl origoss-task.local |
| 81 | +``` |
| 82 | + |
| 83 | + |
| 84 | +### Via Terraform |
| 85 | + |
| 86 | +1. **Initialize Terraform** |
| 87 | + |
| 88 | +```bash |
| 89 | +cd minikube-infra |
| 90 | +terraform init |
| 91 | +``` |
| 92 | + |
| 93 | +2. **Apply the infrastructure** |
| 94 | + |
| 95 | +```bash |
| 96 | +terraform apply |
| 97 | +``` |
| 98 | + |
| 99 | +3. **Access the server** |
| 100 | + |
| 101 | +```bash |
| 102 | +curl origoss-task.local |
| 103 | +``` |
| 104 | + |
| 105 | + |
| 106 | +## Utilising CI |
| 107 | +To use CI capabilities for custom development, follow these steps: |
| 108 | + |
| 109 | +### Fork The Repository |
| 110 | +Follow the official [Forking - GitHub documentation](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) |
| 111 | +### Edit Workflow File |
| 112 | +1. Change the image reference to a custom one |
| 113 | +2. Generate Docker Hub Personal Access Token (`Settings` > `Personal access tokens` > `Generate new token`) |
| 114 | +3. Set The PAT for GitHub as `DOCKER_HUB_TOKEN` (`Settings` > `Secrets and variables`> `Actions` > `New Repository Secret`) |
| 115 | +### Change Image |
| 116 | +#### Kubernetes Manifest |
| 117 | +1. Change the image reference in deployment.yaml |
| 118 | +#### Terraform |
| 119 | +1. Create a `terraform.tfvars` file with the updated image reference or change the default image value in `variables.tf` |
| 120 | +### Trigger GitHub Action |
| 121 | +1. Navigate to `Actions` |
| 122 | +2. Find and choose the action from left side menu |
| 123 | +3. Find the `This workflow has a workflow_dispatch event trigger.` field and choose `Run workflow` |
| 124 | +4. Continue with the [usage steps](#usage) |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | +## Notes |
| 129 | +* Feel free to change local domain from `origoss-task.local` to any custom one |
| 130 | +* Feel free to change replica count according to custom needs |
| 131 | +* This approach aims to satisfy the main requirements: simplicity and efficiency. If more complexity is acceptable, a few improvements could be added: |
| 132 | + - AWS EKS cluster usage (possibly with additional features) |
| 133 | + - additional Go endpoints for Kubernetes probes |
| 134 | + - etc. |
| 135 | + |
0 commit comments