Skip to content

Commit 2befd24

Browse files
committed
Auto-register routes based on kubernetes service annotations
1 parent d3d1f36 commit 2befd24

File tree

7 files changed

+403
-116
lines changed

7 files changed

+403
-116
lines changed

.circleci/config.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ jobs:
2424

2525
- restore_cache:
2626
keys:
27-
- cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gopkg.lock" }}
27+
- cache-{{ arch }}-{{ .Branch }}-{{ checksum "glide.lock" }}
2828
- cache-{{ arch }}-{{ .Branch }}
2929
- cache
3030

31-
- run: make install-dep
31+
- run:
32+
name: install dependencies
33+
command: glide install
3234

3335
- save_cache:
34-
key: cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gopkg.lock" }}
36+
key: cache-{{ arch }}-{{ .Branch }}-{{ checksum "glide.lock" }}
3537
paths:
3638
- vendor
3739

@@ -42,7 +44,9 @@ jobs:
4244
steps:
4345
- checkout
4446

45-
- run: make install-dep
47+
- run:
48+
name: install dependencies
49+
command: glide install
4650

4751
- setup_remote_docker
4852
- run: echo $DOCKER_PASSWORD | docker login -u $DOCKER_USER --password-stdin

Gopkg.lock

Lines changed: 0 additions & 63 deletions
This file was deleted.

Gopkg.toml

Lines changed: 0 additions & 38 deletions
This file was deleted.

cmd/mc-router/main.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
package main
22

33
import (
4-
"net"
5-
"github.com/itzg/mc-router/server"
4+
"context"
5+
"fmt"
66
"github.com/alecthomas/kingpin"
7-
"strconv"
7+
"github.com/itzg/mc-router/server"
88
"github.com/sirupsen/logrus"
9-
"context"
9+
"net"
1010
"os"
1111
"os/signal"
12-
"fmt"
12+
"strconv"
1313
)
1414

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

2627
var (
2728
version = "dev"
28-
commit = "none"
29-
date = "unknown"
29+
commit = "none"
30+
date = "unknown"
3031
)
3132

32-
func showVersion() {
33+
func showVersion() {
3334
fmt.Printf("%v, commit %v, built at %v", version, commit, date)
3435
}
3536

@@ -54,6 +55,13 @@ func main() {
5455
server.StartApiServer(*apiBinding)
5556
}
5657

58+
err := server.K8sWatcher.Start(*kubeConfigFile)
59+
if err != nil {
60+
logrus.WithError(err).Warn("Skipping kubernetes integration")
61+
} else {
62+
defer server.K8sWatcher.Stop()
63+
}
64+
5765
<-c
5866
logrus.Info("Stopping")
5967
cancel()

0 commit comments

Comments
 (0)