Deploy Go applications on k8s via Minikube

Pre-requisite

  1. Minikube cluster
  2. Docker
  3. 2 different Go applications
  4. Kubectl

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

  1. start-repo
  2. go-docker
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))
}

--

--

--

Kubernetes open source contributor

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Concepts needed to start learning Kubernetes

My First HTML Page

A Guide to Markdown, the Formatting Language of the Internet

SqlDBM Q3 Update — aka. The Olympic Performance and Feature Pack

Introduction To Flutter.io: Overview

MITIT Type Approval | Yemen | MITIT Certification JR Compliance

Software…what do you need it to do?

Managing Remote Teams — Use Checklists

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
Shivani Singhal

Shivani Singhal

Kubernetes open source contributor

More from Medium

How to swap two integer variables in Java?

Design Patterns — Prototype Pattern

Chapter 14- Saving Objects

List Based Stack