An endb adapter for using kubernetes's etcd as the storage engine

栏目: IT技术 · 发布时间: 4年前

内容简介:This is a third-party adapter forThis allows us to use the etcd instance used by kubernetes itself to store our data.It creates a custom resource type called

endb-k8s

This is a third-party adapter for endb to use kubernetes as a backing store.

This allows us to use the etcd instance used by kubernetes itself to store our data.

It creates a custom resource type called EtcdData , and all data is saved in objects of this type.

Usage

The default exported value is a function that initializes a store.

The function accepts an optional options object with the following fields:

  • kubeconfig : passed directly to k8s.KubeConfig.loadFromOptions
  • skipApplyingCRD : if true, the crd will be assumed to exist and be correct, and will not be applied on application start.

Kubernetes permission model

In kubernetes, by default the service account is not allowed to change anything.

We need to enable the following permissions using an RBAC role:

  1. PATCH ing CustomResourceDefinition.

    If you don't want to give your app this permission, you can create the crd directly by running kubectl apply -f crd.json with the crd.json provided in this project. Then, pass the option skipApplyingCRD: true in the options object

  2. Full access to the endbdata.hubc.app data type.

    This permission model allows you to create read-only and read-write roles by using kubernetes's built-in RBAC.

Usage example

const Endb = require('endb');
const k8s = require('endb-k8s');

(async () => {
	try {
		const endb = new Endb({ store: await k8s(), namespace: 'endb-test' });

		await endb.set('dor', 'test');
		await endb.set('hello', 'world');
		console.log(`Hello ${await endb.get('hello')}`);
		console.log(await endb.all());
		console.log(await endb.has('dor'));
		console.log(await endb.has('not dor'));
	} catch (e) {
		console.error(e);
	}
})();

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

统计自然语言处理基础

统计自然语言处理基础

Chris Manning、Hinrich Schütze / 苑春法、李伟、李庆中 / 电子工业出版社 / 2005-1 / 55.00元

《统计自然语言处理基础:国外计算机科学教材系列》是一本全面系统地介绍统计自然语言处理技术的专著,被国内外许多所著名大学选为计算语言学相关课程的教材。《统计自然语言处理基础:国外计算机科学教材系列》涵盖的内容十分广泛,分为四个部分,共16章,包括了构建自然语言处理软件工具将用到的几乎所有理论和算法。全书的论述过程由浅入深,从数学基础到精确的理论算法,从简单的词法分析到复杂的语法分析,适合不同水平的读......一起来看看 《统计自然语言处理基础》 这本书的介绍吧!

html转js在线工具
html转js在线工具

html转js在线工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具