Git Product home page Git Product logo

local_service_development_k8s_sample's Introduction

Local Backend Service Development on Kubernetes using mirrord (Sample Projects)

Prerequisites

  • Kubernetes local cluster (use: k3d, minikube etc.)
  • Skaffold to easily deploy the sample app in local kubernetes, Installing Skaffold
  • mirrord as a tool to develop service locally as if it is inside kubernetes cluster, Introduction

Setup

This section we're going to setup our sample cluster the scenario is that we already have a running service that we're developing.

To make it easy use skaffold so that we don't have to publish any container image in order to run it on cluster.

Deploy this project to local kubernetes using skaffold

skaffold run

You can observe that if successful a running pod will appear in cluster

Running Service Locally

In this case pretend that you have uncommitted code changes and want to test it on the cluster.

Next, we're going to run this service locally using mirrord, the target pod name can be copied from the cluster

mirrord exec --target pod/my-server-74cd947f55-lpqdq go run .

If there's no error, http port 8080 will be accessible and you can hit the endpoint localhost:8080/api/get_pods to test

curl localhost:8080/api/get_pods | json_pp

The endpoint serve by this sample app will return a list of pods inside the cluster, this shows that the local service is actually running as if it is inside the cluster

API response something like:

{
   "message" : "get pods successful, there are 9 pods",
   "pods" : [
      ...
      {
         "name" : "my-server-74cd947f55-lpqdq",
         "namespace" : "default"
      },
      {
         "name" : "mirrord-agent-zkjdyl9ffi-f8p47",
         "namespace" : "default"
      },
      ...
   ]
}

If you look closer to how mirrord works, it actually spawn a kubernetes job and run a mirrord agents pod to communicate with the target pod.

local_service_development_k8s_sample's People

Contributors

abdularis avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.