Giter VIP home page Giter VIP logo

kubernetes's Introduction

Micro on Kubernetes

This repo provides pre-initialised versions of go-micro and the micro toolkit for kubernetes.

Services make use of the kubernetes registry plugin so there's zero external dependency for service discovery and the grpc plugins to make use of gRPC for communication.

Contents

Toolkit, go-micro initialisers and healthchecking sidecar:

  • cmd/micro - a preinitialised version of the micro toolkit with the kubernetes registry
    • go get github.com/micro/kubernetes/cmd/micro
  • cmd/health - a healthchecking sidecar for kubernetes
    • run in the pod and set a http healthcheck which calls your rpc service
    • exposes /health http endpoint
  • go/micro - a pre-initialiser for a go-micro service with k8s registry and grpc transport
    • service := micro.NewService()

Example configs:

  • config/micro - API, Web UI and Sidecar (spins up GCE Load Balancers)
  • config/services - Some example micro services

Getting Started

Here's the steps I took to get started.

Run Kubernetes

GKE is the easiest way to run a managed kubernetes cluster. What's even better? $300 free credit for 60 days.

  1. Get yourself a Free Trial of Google Container Engine
  2. Visit the Quickstart guide to create a cluster

Run Micro

We provide some predefined k8s configs with prebuilt micro images.

Make sure kubectl is in your path

./run.sh start

Writing a Service

Write a service as you would any other go-micro service.

import (
	"github.com/micro/go-micro"
	k8s "github.com/micro/kubernetes/go/micro"
)

func main() {
	service := k8s.NewService(
		micro.Name("my.service")
	)
	service.Init()
	service.Run()
}

Toolkit

Get a preinitialised version of the micro toolkit with the kubernetes registry

go get github.com/micro/kubernetes/cmd/micro

Build Yourself

go get github.com/micro/micro

Create a plugins.go file

package main

import _ "github.com/micro/go-plugins/registry/kubernetes"

Build binary

// For local use
go build -i -o micro ./main.go ./plugins.go

Flag usage of plugins

micro --registry=kubernetes

With Go Micro

Use the plugin with go-micro

package main

import (
	_ "github.com/micro/go-plugins/registry/kubernetes"
	"github.com/micro/go-micro"
)

func main() {
	service := micro.NewService(
		micro.Name("my.service"),
	)
	service.Init()
	service.Run()
}
go run main.go --registry=kubernetes

kubernetes's People

Contributors

danbopes avatar

Watchers

Greg Rubino 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.