Deploy Go applications on k8s via Minikube

Pre-requisite

How to start minikube cluster ?

docker-machine create --driver virtualbox sample-docker-machine 
docker-machine ip sample-docker-machine
minikube start --vm-driver="virtualbox" --insecure-registry="<docker-machine ip address>":80

Create Go Applications

package mainimport (
"encoding/json"
"log"
"net/http"
"github.com/gorilla/mux"
)
type Person struct {
ID string `json:"id,omitempty"`
Firstname string `json:"firstname,omitempty"`
}
func GetPong(w http.ResponseWriter, req *http.Request) {
abc := Person{ID : "123",}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(abc)
}
func main() {
router := mux.NewRouter()
router.HandleFunc("/", GetPong).Methods("GET")
log.Fatal(http.ListenAndServe(":8080", router))
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store