当前位置:网站首页>[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
边栏推荐
- Interviewer: why is the value nil not equal to nil?
- 1146_ SiCp learning notes_ exponentiation
- Life perception 1
- 【统信UOS】扫描仪设备管理驱动安装
- TCP congestion control details | 3 design space
- 一入“远程”终不悔,几人欢喜几人愁。| 社区征文
- Discussion sur la logique de conception et de mise en oeuvre du processus de paiement
- 毕业总结
- Postfix 技巧和故障排除命令
- PHP MySQL inserts data
猜你喜欢
Micro service component sentinel console call
Research Report on market demand and investment planning for the development of China's office chair industry, 2022-2028
Discussion sur la logique de conception et de mise en oeuvre du processus de paiement
Vs2013 has blocked the installer, and ie10 needs to be installed
面试官:值为 nil 为什么不等于 nil ?
Tensorboard quick start (pytoch uses tensorboard)
Codeforces Round #803 (Div. 2) C. 3SUM Closure
Redis core technology and practice - learning notes (VIII) sentinel cluster: sentinel hung up
Leetcode 538 converts binary search tree into cumulative tree -- recursive method and iterative method
互聯網醫院HIS管理平臺源碼,在線問診,預約掛號 智慧醫院小程序源碼
随机推荐
Notes on problems -- watching videos on edge will make the screen green
As soon as we enter "remote", we will never regret, and several people will be happy and several people will be sad| Community essay solicitation
Mathematical formula (test)
TCP congestion control details | 3 design space
Redis core technology and practice - learning notes (VI) how to achieve data consistency between master and slave Libraries
ES6类的继承
[combinatorics] recursive equation (special solution example 1 Hannover tower complete solution process | special solution example 2 special solution processing when the characteristic root is 1)
聊聊支付流程的设计与实现逻辑
PHP MySQL preprocessing statement
Remote office tools sharing | community essay solicitation
Managing multiple selections with MVVM - managing multiple selections with MVVM
Redis core technology and practice - learning notes (VIII) sentinel cluster: sentinel hung up
面试官:值为 nil 为什么不等于 nil ?
远程办公工具分享|社区征文
Leetcode 669 pruning binary search tree -- recursive method and iterative method
PUT vs. POST for Uploading Files - RESTful API to be Built Using Zend Framework
PR second time
Analysis report on production and marketing demand and investment forecast of China's PVC industry from 2021 to 2026
聊聊支付流程的设计与实现逻辑
Introduction to SolidWorks gear design software tool geartrax