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

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

内容简介: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);
	}
})();

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

查看所有标签

猜你喜欢:

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

黑客秘笈

黑客秘笈

[美]彼得·基姆 / 徐文博、成明遥 / 人民邮电出版社 / 2015-7-1 / 45.00

所谓的渗透测试,就是借助各种漏洞扫描工具,通过模拟黑客的攻击方法,来对网络安全进行评估。 本书采用大量真实案例和集邮帮助的建议讲解了在渗透测试期间会面临的一些障碍,以及相应的解决方法。本书共分为10章,其内容涵盖了本书所涉的攻击机器/工具的安装配置,网络扫描,漏洞利用,人工地查找和搜索Web应用程序的漏洞,攻陷系统后如何获取更重要的信息,社工方面的技巧,物理访问攻击,规避杀毒软件的方法,破解......一起来看看 《黑客秘笈》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

MD5 加密
MD5 加密

MD5 加密工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换