kitex running in kubernetes cluster and discover each other in kubernetes Service way

Overview

Using kitex in kubernetes

Kitex [kaɪt'eks] is a high-performance and strong-extensibility Golang RPC framework. This go module helps you to build multiple services in single kubernetes cluster without using extra service discovery facilities.

how to use

Client and server in the same kubernetes namespace

import (
    "github.com/adolli/kitex-k8s-native-discovery"
    "github.com/cloudwego/kitex/client"
)

var cli your_rpc_client_code_gen.Client

serviceName := "my.awsome.service"   // (IMPORTANT!) call service by name 
var opts []client.Option
suite := kitex_k8s_native_discovery.NewDiscovery() // initialized this to run client and server in the same namespace
opts = append(opts, client.WithSuite(suite))

cli = your_rpc_client_code_gen.MustNewClient(serviceName, opts...)

Client and server in different kubernetes namespaces

import (
    "github.com/adolli/kitex-k8s-native-discovery"
    "github.com/cloudwego/kitex/client"
)

var cli your_rpc_client_code_gen.Client

serviceName := "my.awsome.service"   // (IMPORTANT!) call service by name 
serverNamespace := "server-production"
var opts []client.Option
suite := kitex_k8s_native_discovery.NewDiscoveryWithNamespace(serverNamespace) // <- pass the namespace to initialize  
opts = append(opts, client.WithSuite(suite))

cli = your_rpc_client_code_gen.MustNewClient(serviceName, opts...)

conventions

Your server deployed in kubernetes cluster should do the following steps

  • Use a Service object to expose your kitex service
  • The Service object should be named as in the form of a-b-c corresponding to your service name defined in kitex server
  • The Service object should expose a port 80 (check the following example)

If your server is initialized in this way and named my.awsome.service

kitex -module "your_module_name" -service my.awsome.service hello.thrift

Then apply a Service object like this

apiVersion: v1
kind: Service
metadata:
  name: my-awsome-service # <- (IMPORTANT!) define the Service name, replace all '.' and '_' to '-' 
spec:
  type: ClusterIP
  ports:
    - name: http
      protocol: TCP
      port: 80            # <- (IMPORTANT!) this port number must be 80
      targetPort: 6789    # <- this corresponding to port listened by kitex server
  selector:
    app: awsome-app 

Visit kitex getting started to get more usages about kitex.

You might also like...
Go-gke-pulumi - A simple example that deploys a GKE cluster and an application to the cluster using pulumi

This example deploys a Google Cloud Platform (GCP) Google Kubernetes Engine (GKE) cluster and an application to it

Natural-deploy - A natural and simple way to deploy workloads or anything on other machines.

Natural Deploy Its Go way of doing Ansibles: Motivation: Have you ever felt when using ansible or any declarative type of program that is used for dep

A pod scaler golang app that can scale replicas either inside of cluster or out of the cluster

pod-scaler A simple pod scaler golang application that can scale replicas via manipulating the deployment Technologies The project has been created us

Influxdb-cluster - InfluxDB Cluster for replacing InfluxDB Enterprise

InfluxDB ATTENTION: Around January 11th, 2019, master on this repository will be

Carrier is a Kubernetes controller for running and scaling game servers on Kubernetes.
Carrier is a Kubernetes controller for running and scaling game servers on Kubernetes.

Carrier is a Kubernetes controller for running and scaling game servers on Kubernetes. This project is inspired by agones. Introduction Genera

PolarDB-X Operator is a Kubernetes extension that aims to create and manage PolarDB-X cluster on Kubernetes.

GalaxyKube -- PolarDB-X Operator PolarDB-X Operator is a Kubernetes extension that aims to create and manage PolarDB-X cluster on Kubernetes. It follo

Automatically capture all potentially useful information about each executed command (as well as its output) and get powerful querying mechanism
Automatically capture all potentially useful information about each executed command (as well as its output) and get powerful querying mechanism

nhi is a revolutionary tool which automatically captures all potentially useful information about each executed command and everything around, and delivers powerful querying mechanism.

I'd like to share random apps in the spare times. Thus, I'm going to try learning some concepts of Go and as much as I can I try to clarify each line.

go-samples I'd like to share random apps in the spare times. Thus, I'm going to try learning some concepts of Go and as much as I can I try to clarify

The mec platform for service register/discovery/subscribe and other functions.roject main repo.

EdgeGallery MEP project Introduction Edgegallery MEP is an open source implementation of MEC platform according to ETSI MEC 003 [1] and 011 [2] docume

Owner
adolli
d发t音/写代码的假UI/日本语苦手/吃很多/与别人有1小时时差/空调外机免费吹/画画/pubg/PhP/Object-C/maltab/wind0ws/前面那些一个都不会/2022元旦快乐
adolli
vcluster - Create fully functional virtual Kubernetes clusters - Each cluster runs inside a Kubernetes namespace and can be started within seconds

Website • Quickstart • Documentation • Blog • Twitter • Slack vcluster - Virtual Clusters For Kubernetes Lightweight & Low-Overhead - Based on k3s, bu

Loft Labs 2.3k Jan 4, 2023
cluster-api-state-metrics (CASM) is a service that listens to the Kubernetes API server and generates metrics about the state of custom resource objects related of Kubernetes Cluster API.

Overview cluster-api-state-metrics (CASM) is a service that listens to the Kubernetes API server and generates metrics about the state of custom resou

Daimler Group 61 Oct 27, 2022
PolarDB Stack is a DBaaS implementation for PolarDB-for-Postgres, as an operator creates and manages PolarDB/PostgreSQL clusters running in Kubernetes. It provides re-construct, failover swtich-over, scale up/out, high-available capabilities for each clusters.

PolarDB Stack开源版生命周期 1 系统概述 PolarDB是阿里云自研的云原生关系型数据库,采用了基于Shared-Storage的存储计算分离架构。数据库由传统的Share-Nothing,转变成了Shared-Storage架构。由原来的N份计算+N份存储,转变成了N份计算+1份存储

null 23 Nov 8, 2022
Dominik Robert 0 Jan 4, 2022
Kubedock is a minimal implementation of the docker api that will orchestrate containers on a Kubernetes cluster, rather than running containers locally.

Kubedock Kubedock is an minimal implementation of the docker api that will orchestrate containers on a kubernetes cluster, rather than running contain

Vincent van Dam 79 Nov 11, 2022
kubetnl tunnels TCP connections from within a Kubernetes cluster to a cluster-external endpoint, e.g. to your local machine. (the perfect complement to kubectl port-forward)

kubetnl kubetnl (kube tunnel) is a command line utility to tunnel TCP connections from within a Kubernetes to a cluster-external endpoint, e.g. to you

null 5 Dec 16, 2022
A Terraform module to manage cluster authentication (aws-auth) for an Elastic Kubernetes (EKS) cluster on AWS.

Archive Notice The terraform-aws-modules/eks/aws v.18.20.0 release has brought back support aws-auth configmap! For this reason, I highly encourage us

Aidan Melen 28 Dec 4, 2022
The OCI Service Operator for Kubernetes (OSOK) makes it easy to connect and manage OCI services from a cloud native application running in a Kubernetes environment.

OCI Service Operator for Kubernetes Introduction The OCI Service Operator for Kubernetes (OSOK) makes it easy to create, manage, and connect to Oracle

Oracle 24 Sep 27, 2022
Tackle Add-on to discover information from a source repository

Tackle Add-ons - Discovery - Languages This add-on explores the source code repository and finds the languages using GitHub Linguist. It's common that

Fabien Dupont 0 Dec 24, 2021
A long-running Go program that watches a Youtube playlist for new videos, and downloads them using yt-dlp or other preferred tool.

ytdlwatch A long-running Go program that watches a Youtube playlist for new videos, and downloads them using yt-dlp or other preferred tool. Ideal for

Raine Virta 9 Jul 25, 2022