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);
	}
})();

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

查看所有标签

猜你喜欢:

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

Effective JavaScript

Effective JavaScript

赫尔曼 (David Herman) / 黄博文、喻杨 / 机械工业出版社 / 2014-1-1 / CNY 49.00

Effective 系列丛书经典著作,亚马逊五星级畅销书,Ecma 的JavaScript 标准化委员会著名专家撰写,JavaScript 语言之父、Mozilla CTO —— Brendan Eich 作序鼎力推荐!作者凭借多年标准化委员会工作和实践经验,深刻辨析JavaScript 的内部运作机制、特性、陷阱和编程最佳实践,将它们高度浓缩为极具实践指导意义的 68 条精华建议。 本书共......一起来看看 《Effective JavaScript》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具