Skip to content

Commit c418579

Browse files
kubernetes manifest
1 parent 8e10f95 commit c418579

4 files changed

Lines changed: 60 additions & 1 deletion

File tree

DockerHub/push-to-dockerhub.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Log into Dockerhub
2+
docker login --username=yourhubusername (you will be prompted for your password)
3+
4+
# Tag the Docker image
5+
docker tag golangwebapi adminturneddevops/golangwebapi:latest
6+
7+
# Push the Docker image to DockerHub
8+
docker push adminturneddevops/golangwebapi:latest

Kubernetes/gokubernetes.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: gowebapi
5+
spec:
6+
selector:
7+
matchLabels:
8+
app: gowebapi
9+
replicas: 2
10+
template:
11+
metadata:
12+
labels:
13+
app: gowebapi
14+
spec:
15+
containers:
16+
- name: gowebapi
17+
image: adminturneddevops/golangwebapi:latest
18+
ports:
19+
- containerPort: 8080
20+
---
21+
apiVersion: v1
22+
kind: Service
23+
metadata:
24+
name: gowebapi
25+
spec:
26+
selector:
27+
app: gowebapi
28+
ports:
29+
- protocol: TCP
30+
port: 8080

main/main

-888 KB
Binary file not shown.

main/main.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
11
package main
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"log"
67
"net/http"
78
)
89

10+
type whoami struct {
11+
Name string
12+
Title string
13+
State string
14+
}
15+
916
func main() {
1017
request1()
1118
}
1219

20+
func whoAmI(response http.ResponseWriter, r *http.Request) {
21+
who := []whoami{
22+
whoami{Name: "Michael Levan",
23+
Title: "Developer Advocate",
24+
State: "NJ",
25+
},
26+
}
27+
28+
json.NewEncoder(response).Encode(who)
29+
30+
fmt.Println("Endpoint Hit", who)
31+
}
32+
1333
func homePage(response http.ResponseWriter, r *http.Request) {
14-
fmt.Printf("Welcome to the Go Web API!")
34+
fmt.Fprintf(response, "Welcome to the Go Web API!")
1535
fmt.Println("Endpoint Hit: homePage")
1636
}
1737

@@ -25,6 +45,7 @@ func aboutMe(response http.ResponseWriter, r *http.Request) {
2545
func request1() {
2646
http.HandleFunc("/", homePage)
2747
http.HandleFunc("/aboutme", aboutMe)
48+
http.HandleFunc("/whoami", whoAmI)
2849

2950
log.Fatal(http.ListenAndServe(":8080", nil))
3051
}

0 commit comments

Comments
 (0)