Skip to content

Commit 027affb

Browse files
committed
Adding new version to test images update
1 parent f886914 commit 027affb

File tree

2 files changed

+7
-47
lines changed

2 files changed

+7
-47
lines changed

k8s/k8s.go

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import (
66
"net/http"
77
)
88

9-
var (
10-
bannedIp = "0.0.0.0"
11-
)
12-
139
func getServerIP() string {
1410
conn, err := net.Dial("udp", "8.8.8.8:80")
1511
if err != nil {
@@ -19,54 +15,18 @@ func getServerIP() string {
1915
return conn.LocalAddr().(*net.UDPAddr).IP.String()
2016
}
2117

22-
func getHTML(status string) string {
23-
message := "DevOps, Mr. Cat speaking, how can I help you?"
24-
image := "1.3.0"
25-
color := "orange"
26-
if status == "alive" {
27-
message = "High five budy, I'm healthy as ever!"
28-
image = "1.3.1"
29-
color = "green"
30-
}
31-
if status == "dead" {
32-
message = "I don't want to die Mr. Stark..."
33-
image = "1.3.2"
34-
color = "red"
35-
}
36-
return `<!DOCTYPE html><html><body><center>
37-
<img src="https://raw.githubusercontent.com/twogg-git/k8s-workshop/master/src/` + image + `.png">
38-
<h1 style="color:` + color + `">` + message + `</h3>
39-
<h2 style="color:green">Playing with Kubernetes</h1>
40-
<h2 style="color:blue">Server IP ` + getServerIP() + `</h2>
41-
<h3 style="color:blue">Version twogghub/k8s-workshop:1.3-liveness</h3>
42-
</center></body></html>`
43-
}
44-
4518
func playHome(w http.ResponseWriter, r *http.Request) {
46-
if bannedIp == getServerIP() {
47-
fmt.Fprintf(w, getHTML("dead"))
48-
} else {
49-
fmt.Fprintf(w, getHTML("home"))
50-
}
51-
}
52-
53-
func playHealth(w http.ResponseWriter, r *http.Request) {
54-
if getServerIP() == bannedIp {
55-
w.WriteHeader(http.StatusServiceUnavailable)
56-
} else {
57-
fmt.Fprintf(w, getHTML("alive"))
58-
}
59-
}
60-
61-
func playKillMe(w http.ResponseWriter, r *http.Request) {
62-
bannedIp = getServerIP()
63-
fmt.Fprintf(w, getHTML("dead"))
19+
html := `<!DOCTYPE html><html><body><center>
20+
<img src="https://raw.githubusercontent.com/twogg-git/k8s-workshop/master/src/1.1.2.png">
21+
<h1 style="color:orange">Playing with Kubernetes</h1>
22+
<h2 style="color:orange">Server IP ` + getServerIP() + `</h2>
23+
<h3 style="color:orange">Version twogghub/k8s-workshop:1.1-rolling</h3>
24+
</center></body></html>`
25+
fmt.Fprintf(w, html)
6426
}
6527

6628
func main() {
6729
http.HandleFunc("/", playHome)
68-
http.HandleFunc("/health", playHealth)
69-
http.HandleFunc("/killme", playKillMe)
7030
if err := http.ListenAndServe(":8080", nil); err != nil {
7131
panic(err)
7232
}

src/1.1.2.png

96.6 KB
Loading

0 commit comments

Comments
 (0)