Git Product home page Git Product logo

golinks's Introduction

Personal GoLinks

Inspired by golinks.io

This application is a redirect service written in Rust that uses routes statically defined in a YAML file to provide easy link shortening.

Although prior versions written in Go (>=1.0 <1.1) supported stateful updates to the running routes, this was removed from the Rust implementation (>=1.1) as I was only deploying the application in my cluster, and ultimately I still managed my available routes by synchronizing the running state with a YAML file that a client used.

Since the application now uses a ConfigMap to deploy to a cluster, I am able to scale up to as many replicas as I want without having to worry about persistance or synchronizing storage. This doesn't matter for a service that is only being used by me, but was a fun experiment.

Quickstart

  1. Install Rust
  2. Clone repository
  3. Write a links.yaml file
  4. Run cargo run
  5. Go to localhost:8000/heartbeat and see the JSON output

Example links.yaml file

routes:
  golinks: https://github.com/cryptaliagy/golinks
  google: https://google.com
  github: https://github.com

Quickstart (Docker)

  1. Create a conf directory and write a links.yaml file in it (see above for example).
  2. Pull the container with docker pull ghcr.io/cryptaliagy/golinks:latest
  3. Run the container with docker run -e GOLINKS_ROUTES=/conf/links.yaml ROCKET_LOG_LEVEL=normal -v "$(pwd)"/conf:/conf -p 8000:8000 ghcr.io/cryptaliagy/golinks:latest
  4. Go to localhost:8000/heartbeat and see the JSON output

Installation (Helm)

helm repo add golinks https://cryptaliagy.github.io/golinks/charts
helm repo update
helm install golinks/golinks

K3s HelmChart CRD

NOTE: Make sure you configure ingress/service in your values file contents appropriately.

---
apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
  name: golinks
  namespace: charts
spec:
  chart: golinks
  repo: https://cryptaliagy.github.io/golinks/charts
  targetNamespace: golinks
  valuesContent: |-
    routes:
      golinks: https://github.com/cryptaliagy/golinks
      google: https://google.com

Installation (Manifest)

Generate a manifest from Helm

helm template --repo https://cryptaliagy.github.io/golinks/charts golinks -g > golinks.yaml

Edit it as desired then apply it to the cluster

kubectl apply -f golinks.yaml

Additional Notes

This service is very simple, and as such is designed to be as minimal as possible. Running on my machine, the container took up ~1MB of memory, and simple route profiling showed that routes took ~20-40 μs.

The final container image size is <10MB and uses an image based on scratch with a statically-linked binary. This also means that the latest and x.y.z versioned containers do not have a shell or any additional tools. For potential debugging purposes, a debug (and x.y.z-debug) container is available. This uses the same binary that latest (and x.y.z) uses, but is based on alpine:latest to include a shell, package manager, etc.

Deploying to Cloud Services

If you would like to deploy this to a cloud service and do not have the ability to mount a file (or otherwise would like the container to be fully atomic), you can build your own image that includes the route configs. To do this, first author a links.yaml file, then use the following Dockerfile:

FROM ghcr.io/cryptaliagy/golinks:latest

COPY links.yaml /links.yaml

This image can then be pushed to a container registry and deployed in the cloud service of your choice.

golinks's People

Contributors

cryptaliagy avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

golinks's Issues

Add instructions on how to use golinks without docker

Some users might prefer to use this without docker, especially if they already run nginx. While most who would fall under this category are probably able to deconstruct this and configure their own, adding some info on the wiki on how to do this would be the neighbourly thing to do

Making services optional

Maybe using templates to generate Nginx server definitions based on services that are defined in the links.yaml file instead of having it be assumed the service will always be run

Sometimes configuration isn't loaded on first run of cleanly-installed repo

Not sure what causes this but when testing the tutorial process, the first time make run was executed, nginx didn't pick up on the configurations even though they had been generated. This was solved by running make teardown && make run to do a 'do over' of sorts, but should be explored. Maybe using depends_on in the docker-compose file for one of the services could solve this problem?

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.