当前位置:网站首页>[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.com
Conclusion
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
边栏推荐
- PHP MySQL create database
- Research Report on market demand and investment planning for the development of China's office chair industry, 2022-2028
- Fedora 21 installs lamp host server
- Enterprise custom form engine solution (XI) -- form rule engine 1
- Five problems of database operation in commodity supermarket system
- WebView module manages the application window interface to realize the logical control and management operation of multiple windows (Part 1)
- vs2013已阻止安装程序,需安装IE10
- Vs2013 has blocked the installer, and ie10 needs to be installed
- Remote office tools sharing | community essay solicitation
- [combinatorics] recursive equation (summary of the solution process of recursive equation | homogeneous | double root | non-homogeneous | characteristic root is 1 | exponential form | the bottom is th
猜你喜欢
一入“远程”终不悔,几人欢喜几人愁。| 社区征文
1164 Good in C
PHP MySQL create database
[combinatorics] generating function (summation property)
Vs2013 has blocked the installer, and ie10 needs to be installed
QT adjust win screen brightness and sound size
Type conversion, variable
MySQL grouping query
聊聊支付流程的設計與實現邏輯
Redis core technology and practice - learning notes (IX): slicing cluster
随机推荐
Assembly for unloading Loadfrom() loaded assembly - unloading the assembly loaded with assembly LoadFrom()
The gbase 8A database does not support the DB2 function value (column_name, 0) cluster syntax
Draw some simple graphics with MFC
Kotlin的協程:上下文
Hongmeng third training
SSL / bio pour OpenSSL Get FD
自动渗透测试工具核心功能简述
Kotlin的协程:上下文
Introduction to PHP MySQL
Postfix 技巧和故障排除命令
Keepalived setting does not preempt resources
Inheritance of ES6 class
Create a new file from templates with bash script - create new file from templates with bash script
PR second time
First day of rhcsa study
【统信UOS】扫描仪设备管理驱动安装
分布式的任务分发框架-Gearman
How to install PHP on Ubuntu 20.04
STM32 realizes 74HC595 control
Servlet specification Part II