Skip to content

Commit

Permalink
Auto-register routes based on kubernetes service annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
itzg committed May 26, 2018
1 parent d3d1f36 commit 2befd24
Show file tree
Hide file tree
Showing 7 changed files with 403 additions and 116 deletions.
12 changes: 8 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ jobs:

- restore_cache:
keys:
- cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gopkg.lock" }}
- cache-{{ arch }}-{{ .Branch }}-{{ checksum "glide.lock" }}
- cache-{{ arch }}-{{ .Branch }}
- cache

- run: make install-dep
- run:
name: install dependencies
command: glide install

- save_cache:
key: cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gopkg.lock" }}
key: cache-{{ arch }}-{{ .Branch }}-{{ checksum "glide.lock" }}
paths:
- vendor

Expand All @@ -42,7 +44,9 @@ jobs:
steps:
- checkout

- run: make install-dep
- run:
name: install dependencies
command: glide install

- setup_remote_docker
- run: echo $DOCKER_PASSWORD | docker login -u $DOCKER_USER --password-stdin
Expand Down
63 changes: 0 additions & 63 deletions Gopkg.lock

This file was deleted.

38 changes: 0 additions & 38 deletions Gopkg.toml

This file was deleted.

30 changes: 19 additions & 11 deletions cmd/mc-router/main.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
package main

import (
"net"
"github.com/itzg/mc-router/server"
"context"
"fmt"
"github.com/alecthomas/kingpin"
"strconv"
"github.com/itzg/mc-router/server"
"github.com/sirupsen/logrus"
"context"
"net"
"os"
"os/signal"
"fmt"
"strconv"
)

var (
port = kingpin.Flag("port", "The port bound to listen for Minecraft client connections").
Default("25565").Int()
apiBinding = kingpin.Flag("api-binding", "The host:port bound for servicing API requests").
String()
String()
mappings = kingpin.Flag("mapping", "Mapping of external hostname to internal server host:port").
StringMap()
StringMap()
versionFlag = kingpin.Flag("version", "Output version and exit").
Bool()
Bool()
kubeConfigFile = kingpin.Flag("kube-config", "The path to a kubernetes configuration file").String()
)

var (
version = "dev"
commit = "none"
date = "unknown"
commit = "none"
date = "unknown"
)

func showVersion() {
func showVersion() {
fmt.Printf("%v, commit %v, built at %v", version, commit, date)
}

Expand All @@ -54,6 +55,13 @@ func main() {
server.StartApiServer(*apiBinding)
}

err := server.K8sWatcher.Start(*kubeConfigFile)
if err != nil {
logrus.WithError(err).Warn("Skipping kubernetes integration")
} else {
defer server.K8sWatcher.Stop()
}

<-c
logrus.Info("Stopping")
cancel()
Expand Down
Loading

0 comments on commit 2befd24

Please sign in to comment.