Skip to content

Commit 650b171

Browse files
committed
Refactor on starter version of files
1 parent 8fafa17 commit 650b171

File tree

7 files changed

+3
-40
lines changed

7 files changed

+3
-40
lines changed

docker/website/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<title>Docker</title>
55
</head>
66
<body><center>
7-
<img src="https://raw.githubusercontent.com/twogg-git/docker-nginx/master/docker.png">
7+
<img src="https://raw.githubusercontent.com/twogg-git/k8s-workshop/master/src/0.0.png">
88
<h1 style="color:blue">Baby steps with docker!</h1>
99
</center></body>
1010
</html>

k8s/k8s.go

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,20 @@ package main
22

33
import (
44
"fmt"
5-
"net"
65
"net/http"
76
)
87

9-
var (
10-
version = "1.0"
11-
bannedIp = "0.0.0.0"
12-
)
13-
14-
func getServerIP() string {
15-
conn, err := net.Dial("udp", "8.8.8.8:80")
16-
if err != nil {
17-
panic(err)
18-
}
19-
defer conn.Close()
20-
return conn.LocalAddr().(*net.UDPAddr).IP.String()
21-
}
22-
238
func playHome(w http.ResponseWriter, r *http.Request) {
249
html := `<!DOCTYPE html><html><body><center>
25-
<img src="https://raw.githubusercontent.com/twogg-git/k8s-intro/master/kubernetes_katacoda.png">
10+
<img src="https://raw.githubusercontent.com/twogg-git/k8s-workshop/master/src/1.0.png">
2611
<h1 style="color:green">Playing with Kubernetes</h1>
27-
<h2 style="color:blue">Your server IP:` + getServerIP() + `</h2>
28-
<h3 style="color:blue">Version: twogghub/k8s-workshop:` + version + `</h3>
29-
<h3 style="color:red">Banned IP: ` + bannedIp + `</h3>
12+
<h3 style="color:blue">Version: twogghub/k8s-workshop:1.0-baby</h3>
3013
</center></body></html>`
3114
fmt.Fprintf(w, html)
3215
}
3316

34-
func playHealth(w http.ResponseWriter, r *http.Request) {
35-
ip := getServerIP()
36-
if ip == bannedIp {
37-
w.WriteHeader(http.StatusInternalServerError)
38-
} else {
39-
fmt.Fprintf(w, "I'm alive!.. but also dead for IP: "+bannedIp)
40-
}
41-
}
42-
43-
func playDead(w http.ResponseWriter, r *http.Request) {
44-
bannedIp = r.URL.Query().Get("ip")
45-
fmt.Fprintf(w, "Now playing dead for IP: "+bannedIp)
46-
}
47-
48-
/*func getBannedIP() string {
49-
return bannedIp
50-
}*/
51-
5217
func main() {
5318
http.HandleFunc("/", playHome)
54-
http.HandleFunc("/health", playHealth)
55-
http.HandleFunc("/kill", playDead)
5619
if err := http.ListenAndServe(":8080", nil); err != nil {
5720
panic(err)
5821
}

src/0.0.png

168 KB
Loading

src/1.0.png

121 KB
Loading

src/1.1.png

260 KB
Loading

src/1.2.png

214 KB
Loading

src/1.3.png

157 KB
Loading

0 commit comments

Comments
 (0)