I tried to deploy Dockerized GoLang HTTP server on Kubernetes

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

Introduction

Hi this is Akshay Rao currently working in Annotation.Inc. Last time i had built the docker image, this time will do the following:-

  • 1. Push built image to docker hub.
  • 2. Deploy the image by creating desirable pods in minikube
  • 3. Attach a static IP to the pods so that it can be accessed in web browser.

Let's Start

Push image to docker hub

  • To check the image has been created or not use “docker image ls”

images

  • Then run docker run -p 8080:8080 -it /docker image/
  • Push the image to the docker hub by tagging it to the repository in docker hub.

Deploy the image by creating desirable pods in minikube

  • Write a deployment.yml to deploy it on minikube.

deployment.yml

  • Check the pods are running by "kubectl get pods"

Attach a static IP to the pods so that it can be accessed in web browser

  • Create service.yml document to attach a static ip to the pods

  • Apply the service and tunnel through the minikube.

Results

Conclusion

Open localhost:8080 u will be able to see the docker image is running. if u get stuck the with this error. Use the command go env -w GO111MODULE=off Make sure the targetPort in service.yml is pointing at the containerport where the server is listening Thank you