File tree Expand file tree Collapse file tree 5 files changed +213
-13
lines changed Expand file tree Collapse file tree 5 files changed +213
-13
lines changed Original file line number Diff line number Diff line change @@ -44,4 +44,5 @@ dockers:
4444changelog :
4545 filters :
4646 exclude :
47- - ' ^ci:'
47+ - ' ^ci:'
48+ - ' ^docs:'
Original file line number Diff line number Diff line change @@ -31,22 +31,20 @@ Flags:
3131
3232## Example kubernetes deployment
3333
34- [ These deployments] ( docs/k8s-example.yaml ) declare an ` mc-router ` that exposes a node port service
35- on the standard Minecraft server port 25565. Two "backend" Minecraft servers are declared as example
36- where users can choose stable/vanilla or snapshot simply based on the hostname they used.
34+ [ This example deployment] ( docs/k8s-example-auto.yaml )
35+ * Declares an ` mc-router ` service that exposes a node port 25565
36+ * Declares a service account with access to watch and list services
37+ * Declares ` --in-kube-cluster ` in the ` mc-router ` container arguments
38+ * Two "backend" Minecraft servers are declared each with an
39+ ` "mc-router.itzg.me/externalServerName" ` annotation that declares their external server name
3740
3841``` bash
39- kubectl apply -f https://raw.githubusercontent.com/itzg/mc-router/master/docs/k8s-example.yaml
42+ kubectl apply -f https://raw.githubusercontent.com/itzg/mc-router/master/docs/k8s-example-auto .yaml
4043```
4144
42- ![ ] ( docs/example-deployment.drawio.png )
45+ ![ ] ( docs/example-deployment-auto .drawio.png )
4346
4447#### Notes
4548* This deployment assumes two persistent volume claims: ` mc-stable ` and ` mc-snapshot `
4649* I extended the allowed node port range by adding ` --service-node-port-range=25000-32767 `
4750 to ` /etc/kubernetes/manifests/kube-apiserver.yaml `
48-
49- ## Coming Soon
50-
51- * Make ` mc-router ` kubernetes service aware. It would watch for backend instances with well known annotations
52- and dynamically create/remove routes accordingly
Original file line number Diff line number Diff line change 1+ ---
2+ apiVersion : v1
3+ kind : ServiceAccount
4+ metadata :
5+ name : mc-router
6+ ---
7+ apiVersion : rbac.authorization.k8s.io/v1
8+ kind : ClusterRole
9+ metadata :
10+ name : services-watcher
11+ rules :
12+ - apiGroups : [""]
13+ resources : ["services"]
14+ verbs : ["watch","list"]
15+ ---
16+ apiVersion : rbac.authorization.k8s.io/v1
17+ kind : ClusterRoleBinding
18+ metadata :
19+ name : mc-router-services-watcher
20+ subjects :
21+ - kind : ServiceAccount
22+ name : mc-router
23+ namespace : default
24+ roleRef :
25+ kind : ClusterRole
26+ name : services-watcher
27+ apiGroup : rbac.authorization.k8s.io
28+ ---
29+ apiVersion : v1
30+ kind : Service
31+ metadata :
32+ name : mc-router
33+ spec :
34+ type : NodePort
35+ ports :
36+ - targetPort : web
37+ name : web
38+ port : 8080
39+ nodePort : 25580
40+ - targetPort : proxy
41+ name : proxy
42+ port : 25565
43+ nodePort : 25565
44+ selector :
45+ run : mc-router
46+ ---
47+ apiVersion : apps/v1
48+ kind : Deployment
49+ metadata :
50+ labels :
51+ run : mc-router
52+ name : mc-router
53+ spec :
54+ selector :
55+ matchLabels :
56+ run : mc-router
57+ strategy :
58+ type : Recreate
59+ template :
60+ metadata :
61+ labels :
62+ run : mc-router
63+ spec :
64+ serviceAccountName : mc-router
65+ containers :
66+ - image : itzg/mc-router:1.1.1
67+ name : mc-router
68+ args : ["--api-binding", ":8080", "--in-kube-cluster"]
69+ ports :
70+ - name : proxy
71+ containerPort : 25565
72+ - name : web
73+ containerPort : 8080
74+ ---
75+ apiVersion : v1
76+ kind : Service
77+ metadata :
78+ name : mc-stable
79+ annotations :
80+ " mc-router.itzg.me/externalServerName " : " mc.your.domain"
81+ spec :
82+ ports :
83+ - port : 25565
84+ selector :
85+ run : mc-stable
86+ ---
87+ apiVersion : apps/v1
88+ kind : Deployment
89+ metadata :
90+ labels :
91+ run : mc-stable
92+ name : mc-stable
93+ spec :
94+ selector :
95+ matchLabels :
96+ run : mc-stable
97+ template :
98+ metadata :
99+ labels :
100+ run : mc-stable
101+ spec :
102+ securityContext :
103+ runAsUser : 1000
104+ fsGroup : 1000
105+ containers :
106+ - image : itzg/minecraft-server
107+ name : mc-stable
108+ env :
109+ - name : EULA
110+ value : " TRUE"
111+ ports :
112+ - containerPort : 25565
113+ volumeMounts :
114+ - name : data
115+ mountPath : /data
116+ volumes :
117+ - name : data
118+ persistentVolumeClaim :
119+ claimName : mc-stable
120+ ---
121+ apiVersion : v1
122+ kind : Service
123+ metadata :
124+ name : mc-snapshot
125+ annotations :
126+ " mc-router.itzg.me/externalServerName " : " snapshot.your.domain"
127+ spec :
128+ ports :
129+ - port : 25565
130+ selector :
131+ run : mc-snapshot
132+ ---
133+ apiVersion : apps/v1
134+ kind : Deployment
135+ metadata :
136+ labels :
137+ run : mc-snapshot
138+ name : mc-snapshot
139+ spec :
140+ selector :
141+ matchLabels :
142+ run : mc-snapshot
143+ template :
144+ metadata :
145+ labels :
146+ run : mc-snapshot
147+ spec :
148+ securityContext :
149+ runAsUser : 1000
150+ fsGroup : 1000
151+ containers :
152+ - image : itzg/minecraft-server
153+ name : mc-snapshot
154+ env :
155+ - name : EULA
156+ value : " TRUE"
157+ - name : VERSION
158+ value : " SNAPSHOT"
159+ ports :
160+ - containerPort : 25565
161+ volumeMounts :
162+ - name : data
163+ mountPath : /data
164+ volumes :
165+ - name : data
166+ persistentVolumeClaim :
167+ claimName : mc-snapshot
Original file line number Diff line number Diff line change 11---
22apiVersion : v1
3+ kind : ServiceAccount
4+ metadata :
5+ name : mc-router
6+ ---
7+ apiVersion : rbac.authorization.k8s.io/v1
8+ kind : ClusterRole
9+ metadata :
10+ name : services-watcher
11+ rules :
12+ - apiGroups : [""]
13+ resources : ["services"]
14+ verbs : ["watch","list"]
15+ ---
16+ apiVersion : rbac.authorization.k8s.io/v1
17+ kind : ClusterRoleBinding
18+ metadata :
19+ name : mc-router-services-watcher
20+ subjects :
21+ - kind : ServiceAccount
22+ name : mc-router
23+ namespace : default
24+ roleRef :
25+ kind : ClusterRole
26+ name : services-watcher
27+ apiGroup : rbac.authorization.k8s.io
28+ ---
29+ apiVersion : v1
330kind : Service
431metadata :
532 name : mc-router
@@ -27,15 +54,18 @@ spec:
2754 selector :
2855 matchLabels :
2956 run : mc-router
57+ strategy :
58+ type : Recreate
3059 template :
3160 metadata :
3261 labels :
3362 run : mc-router
3463 spec :
64+ serviceAccountName : mc-router
3565 containers :
36- - image : itzg/mc-router:1.0 .1
66+ - image : itzg/mc-router:1.1 .1
3767 name : mc-router
38- args : ["--api-binding", ":8080"]
68+ args : ["--api-binding", ":8080", "--in-kube-cluster" ]
3969 ports :
4070 - name : proxy
4171 containerPort : 25565
@@ -46,6 +76,8 @@ apiVersion: v1
4676kind : Service
4777metadata :
4878 name : mc-stable
79+ annotations :
80+ " mc-router.itzg.me/externalServerName " : " mc.your.domain"
4981spec :
5082 ports :
5183 - port : 25565
@@ -90,6 +122,8 @@ apiVersion: v1
90122kind : Service
91123metadata :
92124 name : mc-snapshot
125+ annotations :
126+ " mc-router.itzg.me/externalServerName " : " mc-snapshot.your.domain"
93127spec :
94128 ports :
95129 - port : 25565
You can’t perform that action at this time.
0 commit comments