I tried to deploy Dockerized  GoLang HTTP server on Kubernetes

I tried to deploy Dockerized GoLang HTTP server on Kubernetes

2022.10.20

This article was published more than one year ago. Please be aware that the information may be outdated.

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

Share this article

Related articles