当前位置:网站首页>[tutorial] build your first application on coreos
[tutorial] build your first application on coreos
2022-07-03 17:53:00 【Brother Xing plays with the clouds】
【 Editor's words 】 The author uses his own Mac Take notebook as an example , Introduced how to in CoreOS Installation on WordPress application , There is not much theoretical explanation , All are practical tutorials , I want to know quickly CoreOS Of the students reading .
I'm sure you've heard of CoreOS, But have you actually deployed an application on it ? Many people may not have deployed . stay CoreOS Building an application on is very difficult and frustrating ( translator's note :frustrating, Used this word , It seems really difficult ). Because the documents are scattered , And you have to learn all the relevant skills before you start , Include etcd、systemd、Docker. If you are lazy like me , Just want to try CoreOS Instead of making a mountain out of a molehill , Then let me help you . Next we will be in CoreOS Create a simple WordPress Application and MySQL database .
If you're using Mac, You can control by installing command line tools CoreOS
fleetctl and etcdctl Is the original control CoreOS colony Tools for , The installation steps are as follows :
- brew install go etcdctl git clone https://github.com/coreos/fleet.git
- $ cd fleet
- $ ./build
- $ mv bin/fleetctl /usr/local/bin/
Install a local CoreOS colony , And run
Vagrant It's very simple .
- $ git clone https://github.com/CenturyLinkLabs/coreos-vagrant $ cd coreos-vagrant/cluster
- $ vagrant up --provision
Now there is one on your notebook by the smallest 3 individual CoreOS System composition colony . It's very simple , Now let's use fleetctl Let's check .
- $ fleetctl list-machines MACHINE IP METADATA
- 09fd0a88...10.0.2.15-
- 77763947...10.0.2.15-
- f31c383c...10.0.2.15-
fantastic , Run up .
Use fleet stay CoreOS colony Deployment application
Now you have a CoreOS colony 了 . Next fleetctl Commands can make you CoreOS Deploy applications on cluster nodes , But use fleet Write service file . Of course , You don't need to write it yourself . You can use simple YAML Format to generate Services (service) file .
$ sudo gem install bundler fig2coreos
$ cat fig.yml-
- web:
- image: ctlc/wordpress
- ports:
- - 80:80
- environment:
- DB_USER: root
- DB_PASSWORD: qa1N76pWAri9
- links:
- - db
- db:
- image: ctlc/mysql
- ports:
- - 3306:3306
- environment:
- MYSQL_DATABASE: wordpress
- MYSQL_ROOT_PASSWORD: qa1N76pWAri9
-
- $ fig2coreos myapp fig.yml coreos-files
- $ cd coreos-files
- $ ls
- db-discovery.1.service
- db.1.service
- web-discovery.1.service
- web.1.service
fleetctl Client tools use etcd Key value storage to determine what it wants to access The server And there are etcd The server runs The server . Here's how it works in CoreOS Deploy your application in the cluster .
$ fleetctl start db.1.service
$ fleetctl list-units
UNIT LOAD ACTIVE SUB DESC MACHINE
db.1.service loaded active running Run db_1 9c008961.../10.0.2.15
$ fleetctl start web.1.service
$ fleetctl list-units
UNIT LOAD ACTIVE SUB DESC MACHINE
db.1.service loaded active running Run db_1 9c008961.../10.0.2.15
web.1.service loaded active running Run web_1 9c008961.../10.0.2.15 Now your program is running , But the service has not been registered etcd. Fortunately, ,fig2coreos The service file has been automatically generated for us .
$ fleetctl start db-discovery.1.service
$ fleetctl start web-discovery.1.service
$ fleetctl list-units
UNIT LOAD ACTIVE SUB DESC MACHINE
db-discovery.1.service loaded active running Announce db_1 9c008961.../10.0.2.15
db.1.service loaded active running Run db_1 9c008961.../10.0.2.15
web-discovery.1.service loaded active running Announce web_1 9c008961.../10.0.2.15
web.1.service loaded active running Run web_1 9c008961.../10.0.2.15
$ etcdctl ls --recursive
/services
/services/web
/services/web/web_1
/services/db
/services/db/db_1
$ etcdctl get /services/web/web_1
{ "host": "core-03", "port": 80, "version": "52c7248a14" }
$ etcdctl get /services/db/db_1
{ "host": "core-03", "port": 3306, "version": "52c7248a14" }Deployment completed
That's it , done . stay Vagrant 1.5 Use Vagrant Cloud account number , You can visit your WordPress application . Here's the picture :
$ cd ~/coreos-vagrant/cluster/Find out which machine is listening to you 80 port :
$ etcdctl get /services/web/web_1
{ "host": "core-03", "port": 80, "version": "52c7248a14" }
$ vagrant share core-03 --http 80==> core-03: Detecting network information for machine...
core-03: Local machine address: 192.168.65.2
core-03: Local HTTP port: 80
core-03: Local HTTPS port: disabled
==> core-03: Checking authentication and authorization...==> core-03: Creating Vagrant Share session...
core-03: Share will be at: quick-iguana-4689==> core-03: Your Vagrant Share is running! Name: quick-iguana-4689==> core-03: URL: http://quick-iguana-4689.vagrantshare.comConclusion
Now you can use CoreOS Do a lot of things , But at least now you have finished the basic work , If you plan to use multi host in the production environment Coreos colony . You need to add ambassador Containers . in fact , You can go through ambassador Container connection etc The server , We will publish another blog post next week .
original text : http://newlabs.wpengine.com/building-your-first-app-on-coreos/ author : Lucas Carlson translation : http://dockerone.com/article/66
边栏推荐
- 模块九作业
- Wechat applet for the first time
- Records of long objects and long judgments in the stream of list
- Ml (machine learning) softmax function to realize the classification of simple movie categories
- 1164 Good in C
- ArrayList analysis 3: delete elements
- Discussion sur la logique de conception et de mise en oeuvre du processus de paiement
- The gbase 8A database does not support the DB2 function value (column_name, 0) cluster syntax
- ArrayList分析3 : 删除元素
- 自动渗透测试工具核心功能简述
猜你喜欢

The third day of writing C language by Yabo people

TCP congestion control details | 3 design space

Investigation on the operation prospect of the global and Chinese Anti enkephalinase market and analysis report on the investment strategy of the 14th five year plan 2022-2028

Research Report on market demand and investment planning for the development of China's office chair industry, 2022-2028

AcWing 271. 杨老师的照相排列【多维DP】

一入“远程”终不悔,几人欢喜几人愁。| 社区征文

Internet hospital his management platform source code, online consultation, appointment registration smart hospital applet source code

Baiwen.com 7 days Internet of things smart home learning experience punch in the next day

PHP MySQL preprocessing statement

基于人脸识别的课堂考勤系统 tkinter+openpyxl+face_recognition
随机推荐
Research Report on competitive strategy Outlook Analysis and investment strategic planning of China's smart home equipment industry, 2022-2028
Life perception 1
Internet hospital his management platform source code, online consultation, appointment registration smart hospital applet source code
Analysis report on production and marketing demand and investment forecast of China's PVC industry from 2021 to 2026
PR second time
Y is always discrete and can't understand, how to solve it? Answer: read it several times
PHP MySQL reads data
1164 Good in C
Applet with multiple tabs and Swipers + paging of each tab
How to install PHP on Ubuntu 20.04
Discussion sur la logique de conception et de mise en oeuvre du processus de paiement
[教程]在 CoreOS 上构建你的第一个应用
[mathematical logic] equivalent calculus and reasoning calculus of predicate logic (individual word | predicate | quantifier | predicate logic formula | two basic formulas | proposition symbolization
[combinatorics] recursive equation (the non-homogeneous part is an exponential function and the bottom is the characteristic root | example of finding a special solution)
Research Report on investment trends and development planning of China's thermal insulation material industry, 2022-2028
ArrayList analysis 3: delete elements
How to read the source code [debug and observe the source code]
Global and Chinese health care OEM and ODM market status survey and investment planning recommendations report 2022-2028
Redis core technology and practice - learning notes (IX): slicing cluster
The difference between i++ and ++i: tell their differences easily