My over-engineered homepage project to get an idea of the Kubernetes

Introduction

My over-engineered homepage project to get an idea of the Kubernetes. It shows traffic data from all my GitHub repositories. I added RabbitMQ, Redis and MongoDB so I got to play around with multiple k8s resources. Traffic data is fetched concurrently and Kubernetes manages that job as a cron job. Also now my old hobby projects are under Kubernetes.

See it in action

Go to https://miikka.xyz or run the project locally with your own GITHUB_API_TOKEN=token_here. Fetching traffic data automatically on start up, requires RUN_JOBS_ON_STARTUP=true to be set.

Docker reads environment variables from .env file, but code doesn't.

Run infrastructure and services with:

docker-compose --file docker-compose-all.yml up --build

Go to http://localhost

Development

Project structure

Package Description
assets/k8s Kubernetes manifests. Currently not in GitHub repository
cache Redis related code
cmd Contains main.go files for binaries
consts Constants that are being used in multiple places
docs Generated Swagger files, just as an example
events RabbitMQ related code
jobs Job for fetching traffic data from GitHub API concurrently. Kubernetes runs this as a cron job
lib Contains models, routes, store functions and tests for each entity
lib/user Just an example, no use for this project
server Server setup
server/tmpls Contains HTML-template which will be injected to binary
store Database connection

Local development

Run infrastructure with:

docker-compose up -d

Build binaries with make build and run those or use VS Code's .vscode/launch.json

Test

WIP.

If all tests are to be run at the same time, parallel count must be set to 1, because every test cleans database. Cached test will be disabled with that -count=1

go test -v -count=1 -p 1 ./...

Run one test function

go test -v -timeout 180s -count=1 -run ^TestJob$ miikka.xyz/devops-app/lib/job

Deploy application

Build Docker images and push to Docker registry

Eventlistener

docker build . -t tuommii/miikka-xyz-events -f Dockerfile-eventlistener
docker push tuommii/miikka-xyz-events

Traffic job

docker build . -t tuommii/miikka-xyz-traffic-job -f Dockerfile-traffic-job
docker push tuommii/miikka-xyz-traffic-job

API

docker build . -t tuommii/miikka-xyz-api -f Dockerfile-api
docker push tuommii/miikka-xyz-api

Update k8s resources

In case updating Kubernetes resources is needed, run following commands

kubectl apply -f assets/k8s/events.yml
kubectl apply -f assets/k8s/traffic-job.yml
kubectl apply -f assets/k8s/api.yml

Notes

Swagger

Swagger URL is http://localhost:8080/swagger/ if enabled

Update docs with make swagger

k8s

Get pods

kubectl get pod

Verify service

kubectl get svc miikka-xyz-api

Get a shell to the running container

kubectl exec --stdin --tty mongo-container-name -- /bin/bash

Get a YAML file

kubectl get deploy rabbitmq -o yaml > rabbit.yaml

Docker

Delete all volumes

docker volume rm $(docker volume ls -q)

Links

How To Set Up an Nginx Ingress on DigitalOcean Kubernetes Using Helm

How to Set Up an Nginx Ingress with Cert-Manager on DigitalOcean Kubernetes

Owner
Similar Resources

The cortex-operator is a project to manage the lifecycle of Cortex in Kubernetes.

cortex-operator The cortex-operator is a project to manage the lifecycle of Cortex in Kubernetes. Project status: alpha Not all planned features are c

Dec 14, 2022

OpenYurt - Extending your native Kubernetes to edge(project under CNCF)

OpenYurt - Extending your native Kubernetes to edge(project under CNCF)

openyurtio/openyurt English | 简体中文 What is NEW! Latest Release: September 26th, 2021. OpenYurt v0.5.0. Please check the CHANGELOG for details. First R

Jan 7, 2023

OpenAIOS vGPU scheduler for Kubernetes is originated from the OpenAIOS project to virtualize GPU device memory.

OpenAIOS vGPU scheduler for Kubernetes is originated from the OpenAIOS project to virtualize GPU device memory.

OpenAIOS vGPU scheduler for Kubernetes English version|中文版 Introduction 4paradigm k8s vGPU scheduler is an "all in one" chart to manage your GPU in k8

Jan 3, 2023

Karpenter: an open-source node provisioning project built for Kubernetes

Karpenter: an open-source node provisioning project built for Kubernetes

Karpenter is an open-source node provisioning project built for Kubernetes. Its goal is to improve the efficiency and cost of running workloads on Kub

Dec 1, 2022

Crane (FinOps Crane) is an opensource project which manages cloud resource on Kubernetes stack, it is inspired by FinOps concepts.

Crane (FinOps Crane) is an opensource project which manages cloud resource on Kubernetes stack, it is inspired by FinOps concepts.

Crane (FinOps Crane) is an opensource project which manages cloud resource on Kubernetes stack, it is inspired by FinOps concepts. Goal of Crane is to provide an one-stop shop project to help Kubernetes users to save cloud resource usage with a rich set of functionalities.

Jan 3, 2023

Christmas Hack Day Project: Build an Kubernetes Operator to deploy Camunda Cloud services

Camunda Cloud Operator Christmas Hack Day Project (2021): Build an Kubernetes Operator to deploy Camunda Cloud services Motiviation / Idea We currentl

May 18, 2022

Git-based DevOps PaaS: Project, Pipeline, Kubernetes, ServiceMesh, MutilCloud

gitctl 一体化 DevOps 平台 从代码到应用的一体化编排,应用全生命周期管理,多云托管。 gitctl 会有哪些功能? git 代码托管 projec

Oct 24, 2022

Litmus helps Kubernetes SREs and developers practice chaos engineering in a Kubernetes native way.

Litmus helps Kubernetes SREs and developers practice chaos engineering in a Kubernetes native way.

Litmus Cloud-Native Chaos Engineering Read this in other languages. 🇰🇷 🇨🇳 🇧🇷 🇮🇳 Overview Litmus is a toolset to do cloud-native chaos engineer

Jan 1, 2023
A reverse engineered github actions compatible self-hosted runner using nektos/act to execute your workflow steps

github-act-runner A reverse engineered github actions compatible self-hosted runner using nektos/act to execute your workflow steps. Unlike the offici

Dec 24, 2022
OCI transport plugin for apt-get (i.e., apt-get over ghcr.io)

apt-transport-oci: OCI transport plugin for apt-get (i.e., apt-get over ghcr.io) apt-transport-oci is an apt-get plugin to support distributing *.deb

Nov 1, 2022
A simple project (which is visitor counter) on kubernetesA simple project (which is visitor counter) on kubernetes

k8s playground This project aims to deploy a simple project (which is visitor counter) on kubernetes. Deploy steps kubectl apply -f secret.yaml kubect

Dec 16, 2022
Kubernetes OS Server - Kubernetes Extension API server exposing OS configuration like sysctl via Kubernetes API

KOSS is a Extension API Server which exposes OS properties and functionality using Kubernetes API, so it can be accessed using e.g. kubectl. At the moment this is highly experimental and only managing sysctl is supported. To make things actually usable, you must run KOSS binary as root on the machine you will be managing.

May 19, 2021
Access your Kubernetes Deployment over the Internet
Access your Kubernetes Deployment over the Internet

Kubexpose: Access your Kubernetes Deployment over the Internet Kubexpose makes it easy to access a Kubernetes Deployment over a public URL. It's a Kub

Dec 5, 2022
PolarDB Stack is a DBaaS implementation for PolarDB-for-Postgres, as an operator creates and manages PolarDB/PostgreSQL clusters running in Kubernetes. It provides re-construct, failover swtich-over, scale up/out, high-available capabilities for each clusters.
PolarDB Stack is a DBaaS implementation for PolarDB-for-Postgres, as an operator creates and manages PolarDB/PostgreSQL clusters running in Kubernetes. It provides re-construct, failover swtich-over, scale up/out, high-available capabilities for each clusters.

PolarDB Stack开源版生命周期 1 系统概述 PolarDB是阿里云自研的云原生关系型数据库,采用了基于Shared-Storage的存储计算分离架构。数据库由传统的Share-Nothing,转变成了Shared-Storage架构。由原来的N份计算+N份存储,转变成了N份计算+1份存储

Nov 8, 2022
Jan 4, 2022
Moby Project - a collaborative project for the container ecosystem to assemble container-based systems
Moby Project - a collaborative project for the container ecosystem to assemble container-based systems

The Moby Project Moby is an open-source project created by Docker to enable and accelerate software containerization. It provides a "Lego set" of tool

Jan 8, 2023
this Project is base project about restfull API and MySQL

Requirements. This project only supports to run on Ubuntu currently go version >= 1.16 docker docker-compose Install Protobuffer https://github.com/pr

Dec 10, 2021
dockin ops is a project used to handle the exec request for kubernetes under supervision
dockin ops is a project used to handle the exec request for kubernetes under supervision

Dockin Ops - Dockin Operation service English | 中文 Dockin operation and maintenance management system is a safe operation and maintenance management s

Aug 12, 2022