File tree Expand file tree Collapse file tree 5 files changed +42
-4
lines changed Expand file tree Collapse file tree 5 files changed +42
-4
lines changed Original file line number Diff line number Diff line change @@ -10,13 +10,14 @@ services:
1010 - ./c#/src/:/work/
1111 ports :
1212 - 5000:5000
13- golang : # docker run -it -v ${PWD}:/go/src/work -p 5001:5000 -p 2345:2345 --security-opt "seccomp:unconfined" aimvector/golang:1.0.0
13+ golang : # docker run -it -v ${PWD}:/go/src/work -v ${PWD}/golang/configs/:/configs - p 5001:5000 -p 2345:2345 --security-opt "seccomp:unconfined" aimvector/golang:1.0.0
1414 container_name : golang
1515 image : aimvector/golang:1.0.0
1616 build :
1717 context : ./golang
1818 target : prod
1919 volumes :
20+ - ./golang/configs:/configs/
2021 - ./golang/src/:/go/src/work/
2122 ports :
2223 - 5001:5000
Original file line number Diff line number Diff line change 1+ {
2+ "environment" : " dev"
3+ }
Original file line number Diff line number Diff line change @@ -6,22 +6,39 @@ import (
66 //our web server that will host the mock
77 "github.com/buaazp/fasthttprouter"
88 "github.com/valyala/fasthttp"
9+ "os"
10+ "io/ioutil"
911)
1012
13+ var configuration []byte
14+
1115func Response (ctx * fasthttp.RequestCtx ) {
1216 fmt .Fprintf (ctx , "Hello" )
1317}
1418
1519func Status (ctx * fasthttp.RequestCtx ) {
1620 fmt .Fprintf (ctx , "ok" )
1721}
22+
23+ func ReadConfig (){
24+ fmt .Println ("reading config..." )
25+ config , e := ioutil .ReadFile ("/configs/config.json" )
26+ if e != nil {
27+ fmt .Printf ("Error reading config file: %v\n " , e )
28+ os .Exit (1 )
29+ }
30+ configuration = config
31+ fmt .Println ("config loaded!" )
32+
33+ }
34+
1835func main () {
1936
2037 fmt .Println ("starting..." )
21-
38+ ReadConfig ()
2239 router := fasthttprouter .New ()
2340 router .GET ("/" , Response )
2441 router .GET ("/status" , Status )
2542
2643 log .Fatal (fasthttp .ListenAndServe (":5000" , router .Handler ))
27- }
44+ }
Original file line number Diff line number Diff line change 1+ apiVersion : v1
2+ kind : ConfigMap
3+ metadata :
4+ name : example-config
5+ data :
6+ config.json : |
7+ {
8+ "environment" : "dev"
9+ }
10+ # kubectl create configmap example-config --from-file ./golang/configs/config.json
Original file line number Diff line number Diff line change 3030 cpu : " 50m"
3131 limits :
3232 memory : " 256Mi"
33- cpu : " 500m"
33+ cpu : " 500m"
34+ volumeMouts :
35+ - name : config-volume
36+ mountPath : /configs/
37+ volumes :
38+ - name : config-volume
39+ configMap :
40+ name : example-config # name of our configmap object
You can’t perform that action at this time.
0 commit comments