当前位置:网站首页>How to use etcd to realize distributed /etc directory
How to use etcd to realize distributed /etc directory
2022-07-01 16:51:00 【Juicedata】
etcd yes Kubernetes The preferred data storage system in , The name comes from “/etc” and ”distributed“,“/etc” yes Linux Directory where configuration files are stored , but etcd It's a Key-Value Key value database , Cannot store file .
background
etcd It is a key value database with both consistency and high availability , Simple 、 Security 、 Fast 、 trusted , At present, it is Kubernetes Primary data storage . Let's start with a paragraph etcd Official explanation of the name .
The name “etcd” originated from two ideas, the unix “/etc” folder and “d"istributed systems. The “/etc” folder is a place to store configuration data for a single system whereas etcd stores configuration information for large scale distributed systems. Hence, a “d"istributed “/etc” is “etcd”.
The above paragraph comes from etcd Official website ,etcd Imaginatively put etc (Linux Where the system is usually used to store configuration files ) And distributed ( Distributed ) The two concepts are combined , However , because etcd adopt HTTP API Provide services , therefore ” regret ” We can't realize a real distributed /etc Catalog . Next we will introduce , How to use JuiceFS, help etcd Achieve a truly distributed /etc Catalog .
Then you can use it etcd Achieve true distribution /etc Well ? The following methods can be tested .
We use an open source distributed file system JuiceFS for /etc Provide POSIX Access capability of file interface , and JuiceFS have access to etcd As Metadata engine , Store the directory tree in the file system 、 Metadata such as file name , coordination JuiceFS CSI Driver, It can be used as Persistent Volume, stay Kubernetes Multiple application instances share configuration files in the platform , This is exactly distributed /etc 了 .
The following will be from what is JuiceFS、 Why? JuiceFS It can be distributed /etc And how to realize distributed /etc And so on , about etcd How to use JuiceFS Realize the sharing of configuration files in multiple application instances .
What is? JuiceFS

JuiceFS Is an open source cloud native distributed file system , Designing for cloud environments , Provide complete POSIX、HDFS and S3 API Compatibility .JuiceFS The architecture of adopts a layered plug-in design , Metadata engines have been opened to Redis、MySQL、PostgreSQL、TiKV Such as database support , And in v1.0-beta3 Officially supported in version etcd As a metadata engine . The data storage engine interfaces with any object storage system , stay v1.0-rc1 China also supports etcd As a storage engine , It is suitable for configuration files with small storage capacity .
Why? JuiceFS It can be distributed /etc
According to the layered architecture design mentioned above, we can see ,JuiceFS Store the metadata of the file in the database , File data is stored in object storage , Thus, users can access the same tree file system structure on different nodes , And achieve the purpose of sharing files . With JuiceFS Blessing of distributed file system , We can put the configuration file in the file system , Then in each application JuiceFS Mount into it /etc Catalog , And then realize real distributed "/etc". The whole process is shown in the following figure .

How to achieve distributed /etc
Next, let's say nginx Application, for example , about etcd How to use JuiceFS, Make more than one nginx Instances share the same configuration , Implement distributed /etc.
Deploy etcd
stay Kubernetes Environment , It is suggested to build an independent etcd Service supply JuiceFS Use , Instead of using the default in the cluster etcd service , Avoid affecting when file system access pressure is high Kubernetes The stability of clusters .
install etcd You can refer to the official documents , Build multi node etcd colony ; You can also use Bitnami Provided etcd Of chart Installation package .
In case of data sensitivity , Can be opened etcd Encrypted communication function , Encrypted transmission of data . Reference resources etcd Provided by the project Sample script .
stay JuiceFS Prepare the configuration file in
Install well etcd After cluster , Two lines of command initialize a JuiceFS file system .
$ juicefs format etcd://$IP1:2379,$IP2:2379,$IP3:2379/jfs --storage etcd --bucket etcd://$IP1:2379,$IP2:2379,$IP3:2379/data pics$ juicefs mount etcd://$IP1:2379,$IP2:2379,$IP3:2379/jfs /mnt/jfs take JuiceFS volume Mount to /mnt/jfs After the directory , You can directly place nginx.conf file .
stay Kubernetes Use in JuiceFS
First create a Secret, Configure... In it etcd Connection information :
apiVersion: v1kind: Secretmetadata: name: juicefs-secret namespace: kube-systemtype: OpaquestringData: name: test metaurl: etcd://$IP1:2379,$IP2:2379,$IP3:2379/jfs storage: etcd bucket: etcd://$IP1:2379,$IP2:2379,$IP3:2379/data Both metadata engine and object storage use etcd, among $IP1、$IP2、$IP3 by etcd The client of IP. Then create a PV and PVC( You can refer to file ). And then you can do it in Nginx Application , take PVC Mount to /etc, as follows :
apiVersion: apps/v1kind: Deploymentmetadata: name: nginx-appspec: … volumes: - name: config persistentVolumeClaim: claimName: etcd containers: - image: nginx volumeMounts: - mountPath: /etc/nginx name: config …Nginx The application will read when it starts /etc/nginx Under the nginx.conf The configuration file , That is, read what we put in JuiceFS Medium nginx.conf Configuration file , and nginx.conf The document is passed JuiceFS volume Shared .
summary
etcd As a cloud native key value database , Used to store Kubernetes Service configuration information in the platform , It has become the standard of fact . But the configuration file management of many upper applications is still inconvenient , This article shares JuiceFS How to make etcd Become distributed "/etc" Methods , help etcd Completed the original dream .
Activity Notice
It will be held this Saturday Meetup “ A hybrid cloud / Practice and Prospect of multi cloud storage architecture ”, welcome Click here to sign up .
边栏推荐
- 數據庫系統原理與應用教程(006)—— 編譯安裝 MySQL5.7(Linux 環境)
- The supply of chips has turned to excess, and the daily output of Chinese chips has increased to 1billion, which will make it more difficult for foreign chips
- 用手机在同花顺上开户靠谱吗?这样有没有什么安全隐患
- SystemVerilog-结构体(二)
- [live broadcast appointment] database obcp certification comprehensive upgrade open class
- Zabbix2.2监控之系统及应用日志监控报警
- Tutorial on principles and applications of database system (006) -- compiling and installing MySQL 5.7 (Linux Environment)
- Germany if was crowned with many awards. How strong is this pair of headphones? In depth evaluation of yinpo GTW 270 hybrid
- C語言輸入/輸出流和文件操作
- Endeavouros mobile hard disk installation
猜你喜欢

How to solve the keyboard key failure of notebook computer

Germany if was crowned with many awards. How strong is this pair of headphones? In depth evaluation of yinpo GTW 270 hybrid

SystemVerilog-结构体(二)

独家消息:阿里云悄然推出RPA云电脑,已与多家RPA厂商开放合作

Authentication processing in interface testing framework

How to solve the problem that the battery icon of notebook computer does not display

Principes et applications du système de base de données (006) - - compilation et installation de MySQL 5.7 (environnement Linux)

What is the effect of choosing game shield safely in the game industry?
![[pyg] document summary and project experience (continuously updated](/img/b4/75da8c3e657069be4e3e3bfd5b2dc0.png)
[pyg] document summary and project experience (continuously updated

Installation and use of sqoop
随机推荐
FPN network details
Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022
China nylon 11 industry research and future forecast report (2022 Edition)
Buuctf gold III
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
Zabbix2.2监控之系统及应用日志监控报警
Germany if was crowned with many awards. How strong is this pair of headphones? In depth evaluation of yinpo GTW 270 hybrid
Exclusive news: Alibaba cloud quietly launched RPA cloud computer and has opened cooperation with many RPA manufacturers
Template Engine Velocity Foundation
[nodemon] app crashed - waiting for file changes before starting... resolvent
How to optimize repeated if err in go language= Nil template code?
How to use F1 to F12 correctly on laptop keyboard
How to repair the laptop that cannot connect to the wireless network
How does go use symmetric encryption?
Red team Chapter 8: blind guess the difficult utilization process of the package to upload vulnerabilities
Tutorial on the principle and application of database system (003) -- MySQL installation and configuration: manually configure MySQL (Windows Environment)
【Kotlin】高阶函数介绍
[live broadcast appointment] database obcp certification comprehensive upgrade open class
【直播预约】数据库OBCP认证全面升级公开课
Is the programmer's career really short?