-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[secret] refactor: rewrite secret code by add hellok8s:v5.
- Loading branch information
1 parent
ad9b3ca
commit 400c6cb
Showing
6 changed files
with
119 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Dockerfile | ||
FROM golang:1.16-buster AS builder | ||
RUN mkdir /src | ||
ADD . /src | ||
WORKDIR /src | ||
|
||
RUN go env -w GO111MODULE=auto | ||
RUN go build -o main . | ||
|
||
FROM gcr.io/distroless/base-debian10 | ||
|
||
WORKDIR / | ||
|
||
COPY --from=builder /src/main /main | ||
EXPOSE 3000 | ||
ENTRYPOINT ["/main"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# hellok8s-secret.yaml | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"net/http" | ||
"os" | ||
) | ||
|
||
func hello(w http.ResponseWriter, r *http.Request) { | ||
host, _ := os.Hostname() | ||
dbPassword := os.Getenv("DB_PASSWORD") | ||
io.WriteString(w, fmt.Sprintf("[v5] Hello, Kubernetes! From host: %s, Get Database Connect Password: %s", host, dbPassword)) | ||
} | ||
|
||
func main() { | ||
http.HandleFunc("/", hello) | ||
http.ListenAndServe(":3000", nil) | ||
} |