Read env vars USERNAME and MY_POD_NAME

This commit is contained in:
2023-09-06 15:26:21 +03:00
parent 8d03b79a29
commit 6c61682771
2 changed files with 4 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/penglongli/gin-metrics/ginmetrics" "github.com/penglongli/gin-metrics/ginmetrics"
"net/http" "net/http"
"os"
) )
func main() { func main() {
@@ -14,7 +15,7 @@ func main() {
metrics.Use(router) metrics.Use(router)
router.GET("/api/v1/gin", func(c *gin.Context) { router.GET("/api/v1/gin", func(c *gin.Context) {
c.String(http.StatusOK, "Hello from Go!") c.String(http.StatusOK, "Hello " + os.Getenv("USERNAME") + " from " + os.Getenv("MY_POD_NAME"))
}) })
router.Run(":8000") router.Run(":8000")

View File

@@ -20,6 +20,8 @@ spec:
- name: hello-gin - name: hello-gin
image: hello-gin image: hello-gin
env: env:
- name: USERNAME
value: world
- name: MY_POD_NAME - name: MY_POD_NAME
valueFrom: valueFrom:
fieldRef: fieldRef: