v1.13 change storage of podspec
This commit is contained in:
Родитель
078c43645c
Коммит
2bf370f57a
|
@ -1,7 +1,5 @@
|
|||
FROM golang:alpine
|
||||
|
||||
MAINTAINER Divyansh Manchanda <divyanshm@gmail.com>
|
||||
|
||||
RUN apk add --no-cache git mercurial \
|
||||
&& go get github.com/garyburd/redigo/redis \
|
||||
&& go get github.com/gorilla/handlers \
|
||||
|
|
|
@ -49,11 +49,12 @@ func CreatePod() string {
|
|||
securityContext:
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
- name: daemon-storage
|
||||
- name: agent-pv-storage
|
||||
mountPath: /var/lib/docker
|
||||
volumes:
|
||||
- name: daemon-storage
|
||||
emptyDir: {}
|
||||
- name: agent-pv-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: agent-pv-volume2
|
||||
`
|
||||
|
||||
var p1 v1.Pod
|
||||
|
|
|
@ -27,7 +27,7 @@ spec:
|
|||
tier: frontend
|
||||
spec:
|
||||
containers:
|
||||
- image: divyanshm/goserver:v1.12
|
||||
- image: divyanshm/goserver:v1.13
|
||||
name: goserver
|
||||
command: ["/app/main", "-redis", "goserver-redis:6379"]
|
||||
ports:
|
||||
|
|
19
main.go
19
main.go
|
@ -26,16 +26,15 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
// Create Redis storage
|
||||
r := NewRedisStorage(*redisFlag)
|
||||
storage := NewRedisStorage(*redisFlag)
|
||||
|
||||
// Define HTTP endpoints
|
||||
s := http.NewServeMux()
|
||||
s.HandleFunc("/", RootHandler)
|
||||
s.HandleFunc("/ping", PingHandler(r))
|
||||
s.HandleFunc("/ping", PingHandler(storage))
|
||||
s.HandleFunc("/version", VersionHandler)
|
||||
s.HandleFunc("/payload", PayloadHandler)
|
||||
s.HandleFunc("/create", KubernetesCreateHandler)
|
||||
s.HandleFunc("/delete", KubernetesDeleteHandler)
|
||||
s.HandleFunc("/create", func(w http.ResponseWriter, r *http.Request) { KubernetesCreateHandler(w, r, storage) })
|
||||
s.HandleFunc("/delete", func(w http.ResponseWriter, r *http.Request) { KubernetesDeleteHandler(w, r, storage) })
|
||||
|
||||
// Bootstrap logger
|
||||
logger := log.New(os.Stdout, "", log.LstdFlags)
|
||||
|
@ -46,12 +45,6 @@ func main() {
|
|||
log.Fatal(http.ListenAndServe(*listenFlag, loggingHandler))
|
||||
}
|
||||
|
||||
// RootHandler handles requests to the "/" path.
|
||||
// It will redirect the request to /ping with a 303 HTTP header
|
||||
func RootHandler(resp http.ResponseWriter, req *http.Request) {
|
||||
http.Redirect(resp, req, "/ping", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
// PingHandler handles request to the "/ping" endpoint.
|
||||
// It will send a PING request to Redis and return the response
|
||||
// of the NoSQL database.
|
||||
|
@ -104,7 +97,7 @@ func PayloadHandler(resp http.ResponseWriter, req *http.Request) {
|
|||
fmt.Fprintf(resp, "Payload: %s", string(body))
|
||||
}
|
||||
|
||||
func KubernetesCreateHandler(resp http.ResponseWriter, req *http.Request) {
|
||||
func KubernetesCreateHandler(resp http.ResponseWriter, req *http.Request, s Storage) {
|
||||
_, err := ioutil.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
resp.WriteHeader(http.StatusInternalServerError)
|
||||
|
@ -116,7 +109,7 @@ func KubernetesCreateHandler(resp http.ResponseWriter, req *http.Request) {
|
|||
fmt.Fprintf(resp, "Pods: %s", pods)
|
||||
}
|
||||
|
||||
func KubernetesDeleteHandler(resp http.ResponseWriter, req *http.Request) {
|
||||
func KubernetesDeleteHandler(resp http.ResponseWriter, req *http.Request, s Storage) {
|
||||
podname := req.URL.Query()["podname"][0]
|
||||
if podname == "" {
|
||||
fmt.Fprintf(resp, "Provide pod name as ?podname=somename");
|
||||
|
|
Загрузка…
Ссылка в новой задаче