Koding Kite How do I deploy it?

Source: Internet
Author: User
Tags etcd gocode

1. Download Kite and Kontrol code

git projects are introduced, here is the latest code download, if it is used in production environment, note download stable version from release

Go get github.com/koding/kite
2. Installing Kontrol and initializing

Install Kontrol:

Go get Github.com/koding/kite/kontrol/kontrol

Note: The Kontrol executable generated here is under $GOPATH/bin/directory

Generate keys for the Kite key:

OpenSSL genrsa-out key.pem 2048openssl rsa-in key.pem-pubout > Key_pub.pem

Set environment variables (which sets the basic environment variable, can also be modified by Kontrol):

kontrol_port=6000  kontrol_username= "KONTROL" kontrol_storage= "Etcd" #注意这里, there is a pit, the default is ETCD, but no indication of installation and deployment Kontrol_ Kontrolurl= "Http://127.0.0.1:6000/kite" kontrol_publickeyfile= "$youpath/certs/key_pub.pem" Kontrol_ privatekeyfile= "$youpath/certs/key.pem"

Generate initial Kite key:

$GOPATH/bin/kontrol-initial
execution results are as follows
~/gocode/bin $./kontrol-initial2015-07-29 09:57:25 [Kontrol] WARNING  Key pair storage is not set. Using in memory cache2015-07-29 09:57:25 [Kontrol] INFO     registered machine on User:kontrolkite.key are written to ~/.K Ite/kite.key. You can see it with:kitectl showkey
3. Download Run ETCD

Download the compiled binary directly from https://github.com/coreos/etcd/releases/tag/v2.1.1

Note: This is just a run-through program that deploys a single machine for testing

[email protected]:~/gocode/kitetest/etcd-v2.1.1 $./etcd 2015/07/29 15:20:28 etcdmain:setting Maximum number of CPUs to 1, total number of available CPUs is 82015/07/29 15:20:28 etcdmain:no Data-dir provided, using default Data-dir. /default.etcd2015/07/29 15:20:28 etcdmain:listening for peers on Http://localhost:23802015/07/29 15:20:28 Etcdmain: Listening for peers in Http://localhost:70012015/07/29 15:20:28 etcdmain:listening for client requests on Http://localhos T:23792015/07/29 15:20:28 etcdmain:listening for client requests on HTTP://LOCALHOST:40012015/07/29 15:20:28 Etcdserver : name = Default2015/07/29 15:20:28 etcdserver:data dir = default.etcd2015/07/29 15:20:28 etcdserver:member dir = defaul T.etcd/member2015/07/29 15:20:28 etcdserver:heartbeat = 100ms2015/07/29 15:20:28 etcdserver:election = 1000ms2015/07/ 15:20:28 etcdserver:snapshot count = 100002015/07/29 15:20:28 etcdserver:advertise client URLs = http://localhost:237 9,http://localhost:40012015/07/29 15:20: etcdserver:initial Advertise Peer URLs = Http://localhost:2380,http://localhost:70012015/07/29 15:20:28 etcdserver : initial cluster = Default=http://localhost:2380,default=http://localhost:70012015/07/29 15:20:28 etcdserver:  Starting member CE2A822CEA30BFCA in cluster 7E27652122E8B2AE2015/07/29 15:20:28 RAFT:CE2A822CEA30BFCA became follower at Term 02015/07/29 15:20:28 Raft:newraft CE2A822CEA30BFCA [peers: [], term:0, commit:0, applied:0, lastindex:0, Lastte Rm:0]2015/07/29 15:20:28 RAFT:CE2A822CEA30BFCA became follower at term 12015/07/29 15:20:28 etcdserver:starting server. .. [version:2.1.1, cluster version:to_be_decided]2015/07/29 15:20:28 etcdserver:cannot Monitor file descriptor usage (Cann OT get Fdusage on Darwin) 2015/07/29 15:20:28 etcdserver:added Local member CE2A822CEA30BFCA [http://localhost:2380 http:/ /LOCALHOST:7001] to cluster 7E27652122E8B2AE2015/07/29 15:20:29 RAFT:CE2A822CEA30BFCA was starting a new election at term 12015/07/29 15:20:29 Raft:ce2a822ceA30BFCA became candidate at term 22015/07/29 15:20:29 RAFT:CE2A822CEA30BFCA received vote from CE2A822CEA30BFCA at term 2 2015/07/29 15:20:29 RAFT:CE2A822CEA30BFCA became leader at term 22015/07/29 15:20:29 RAFT:RAFT.NODE:CE2A822CEA30BFCA el Ected leader CE2A822CEA30BFCA at term 22015/07/29 15:20:29 etcdserver:setting up the initial cluster version to 2.1.02015 /07/29 15:20:29 etcdserver:published {name:default clienturls:[http://localhost:2379 http://localhost:4001]} to Cluster 7E27652122E8B2AE2015/07/29 15:20:29 etcdserver:set The initial cluster version to 2.1.0



4. Start Kontrol
~/gocode/bin $./kontrol-ip=127.0.0.1-port=60002015-07-29 15:23:20 [Kontrol] WARNING  Key pair storage is not set. Using in memory cache2015-07-29 15:23:20 [Kontrol] INFO     New listening:127.0.0.1:60002015-07-29 15:23:20 [Kontrol] in FO     Serving ...



Now can start, here the connection Etcd is with the default port 4001, if deployed on different machines, the configuration needs to be modified.

Kontrol is used as follows:

usage of/kontrol:-initial=false:change value of  Initial.  -ip=: Change value of IP.  -kontrolurl=http://127.0.0.1:6000/kite:change value of Kontrolurl.  -machines=[]: Change value of machines.  -port=6000:change value of port.  -postgres-dbname=: Change value of Postgres-dbname.  -postgres-host=localhost:change value of Postgres-host.  -postgres-password=: Change value of Postgres-password.  -postgres-port=5432:change value of Postgres-port.  -postgres-username=: Change value of Postgres-username.  -privatekeyfile=/users/qpzhang/gocode/kitetest/key.pem:change value of Privatekeyfile.  -publickeyfile=/users/qpzhang/gocode/kitetest/key_pub.pem:change value of Publickeyfile.  -registerurl=: Change value of Registerurl.  -tlscertfile=: Change value of Tlscertfile.  -tlskeyfile=: Change value of Tlskeyfile.  -username=kontrol:change value of username. -version=0.0.1:change value of version. 



5. Starting the kite of the sampleDownload the code from Https://github.com/koding/kite/tree/master/examples for testing, here is the test

Math_register.go and Exp2-query.go

First start the service provider and register with the Kontrol:

~/gocode/kitetest $./math_register 2015-07-29 15:29:00 [math] INFO dialing ' Kontrol ' Kite:http://127.0.0.1:6000/kite2 015-07-29 15:29:00 [Math] DEBUG Client transport is set to ' WebSocket ' 2015-07-29 15:29:00 [math] INFO Connected to  Kontrol 2015-07-29 15:29:00 [math] INFO registering to Kontrol with url:http://localhost:6667/kite2015-07-29 15:29:00 [Math] Debug telling method [Register] on Kite [kontrol]2015-07-29 15:29:00 [math] Debug Sending: {"method": "Register", "Arg Uments ": [{" Kite ": {" name ":" Math "," username ":" Kontrol "," id ":" 284df2a9-427f-4a31-7f80-883a2e15d042 "," Environment " : "Unknown", "region": "Unknown", "Version": "1.0.0", "hostname": "Qpzhangdemac-mini.local"}, "Authentication": {"type" : "Kitekey", "Key": " Eyjhbgcioijsuzi1niisinr5cci6ikpxvcj9.eyjpyxqioje0mzgxntq1odusimlzcyi6imtvbnryb2wilcjqdgkioiiyodrkzjjhos00mjdmltrhmzetn2y4 Mc04odnhmmuxnwqwndiilcjrb250cm9ss2v5ijoils0tls1crudjtibqvujmsumgs0vzls0tls1cbk1jsujjakfoqmdrcwhrauc5dzbcqvffrkfbt0nbuthbt Uljqknns0nbuuvbmulrcnfhdU50snvzsjk0m0l3rlrcbni0mulprmxqegurk0yymi9crzbuoe55ctc5umo1be5imumvmi81s0dvwfbttwgrdfrnymqzweozz01zszraowrcbnkxnno0ew5nsk Tmwhzwdfphuxp1unhjzlc3y2dmcwtnoefzzejptuxhv3rtb1jpakzsbmirtzlnk250k3l1s2jcblrmnw1kmdzjsfiytk5eylm3ywvkaddju0xxvtjysxrsbel 6zwrhykfzzvqvs1j0zjbjd3nlthzga21rdgrqtfbcbklluzuzmvbialrjthorq0fhtkfpt2pjemdsyysrb0hiwutbcgzlzll1dk5fewdbcmdkullymm1su0s0 Qjvwk3vcbjjewdzvdmfla0nenkf2tmmxwknkewzrymx0vdjpovhntfvjsnh6zm5vsulvdtdav3hudjdstgxzstjaas9czfhcblhrsurbuufcxg4tls0tluvor Cbqvujmsumgs0vzls0tls0ilcjrb250cm9svvjmijoiahr0cdovlzeyny4wljaumto2mdawl2tpdguilcjzdwiioijrb250cm9sin0.ufzkgk1vvuctkrzqx4 Cr6s8dogqsb3puwgie3bzzlgzhiwudsok6wjadjjl5kv154qf5ht9g3kwozmjfe82nditqseqvzazi1ukkzszzobcj94wqv4r-tazcdk_ Bx3nituwnmctfbcoddvcylvem83bldtonf2au387irmehnaptoi61f3d5o7k1mvouvr-hsn39jtplljpdgnsxbs5ut-dbbnit76545m-odvqp83rtob45ahp _xrynzbguvizqryekr-xvgaay5_ckb419-r1d1zoycrmnzqjlyzguk_s_a0f2x_hufij_gcjyp2nzy_uezvnvubfmndqaetc56g "}," Responsecallback ":" [Function] "," Withargs ": [{" url ":" http://localhost: 6667/kite "}]}]," callbacks ": {" 0 ": [0," Responsecallback "]}}2015-07-29 15:29:00 [math] DEBUG Received: {" method ":" Kite.heartbeat "," arguments ": [{" Kite ": {" name ":" Kontrol "," username ":" Kontrol "," id ":" b49f6b65-b152-420c-5e0b-4919b0b1825f "," Environment ":" Unknown "," region ":" Unknown "," Version ":" 0.0.1 "," hostname ": "Qpzhangdemac-mini.local"}, "Authentication": null, "Responsecallback": "[Function]", "Withargs": [Ten, "[Function]"]} ], "callbacks": {"0": [0, "Responsecallback"], "1": [0, "Withargs", 1]}}2015-07-29 15:29:00 [math] DEBUG Received: {"method ": 0," arguments ": [{" error ": null," result ": {" url ":" Http://localhost:6667/kite "," HeartbeatInterval ": 0}]," Callbacks ": {}}2015-07-29 15:29:00 [math] INFO registered to Kontrol with Url:http://localhost:6667/kite and Kite Quer Y:/kontrol/unknown/math/1.0.0/unknown/qpzhangdemac-mini.local/284df2a9-427f-4a31-7f80-883a2e15d0422015-07-29 15:29:00 [Math] Info New listening:0.0.0.0:66672015-07-29 15:29:00 [math] info serving ...



then start the caller:
~/gocode/kitetest $./exp2-query
2015-07-29 15:29:06 [EXP2] INFO     dialing ' Kontrol ' kite:http://127.0.0.1:6000/kite2015-07-29 15:29:06 [EXP2] info< c4/>connected to Kontrol 2015-07-29 15:29:07 [EXP2] INFO     dialing ' math ' kite:http://localhost:6667/kite2015-07-29 15:29:08 [EXP2] INFO     math:message from math: "We have requested square of 7" Input:7  result:49



You will then see the math_register output log:
2015-07-29 15:29:07 [math] Debug New session:ywydsey8iqkwfs3ckohh2015-07-29 15:29:08 [math] Debug Received: {"Meth Od ":" Square "," arguments ": [{" Kite ": {" name ":" Exp2 "," username ":" Kontrol "," id ":" A6a11fab-d476-4275-4770-a42ad6698c3d "," Environment ":" Unknown "," region ":" Unknown "," Version ":" 1.0.0 "," hostname ": "Qpzhangdemac-mini.local"}, "Authentication": {"type": "token", "Key": " Eyjhbgcioijsuzi1niisinr5cci6ikpxvcj9.eyjhdwqioiiva29udhjvbc91bmtub3dul21hdggilcjlehaioje0mzgzmjc4mdysimlhdci6mtqzode1ndk0 Niwiaxnzijoia29udhjvbcisimp0asi6ijmymta4zwizltg5mwitngexzi03zjq3ltq0mdu4ytczywiyzsisim5izii6mtqzode1ndg4niwic3viijoia29ud Hjvbcj9.crireqe5hvnxbefvygsawdphyeax7cakkqjjbwno4f7ki5slaqjget65heyizfmnqjbalqzhktvjexuwya8b7ade4y15ht9yhudk8hrnbpzgq5nhc Mozjlvpkeijkp02emsg8wfnbxogld3okcajpgzn0b6knrfsmsyne9mdx5u7vesho4jxtzlny9zotttggejzqvlxi8wqtxge_ 6o0imko2xl5pvokyrnolmnnkmykyrytj2mh58vvkqaqoktikgrgmsdqbzndoxx4x1rewdshcpn_ 1c38sv1aw3cvfbjryrxhgf25g5dmqx98jc7ipclckwtv9rkkus88lcvnpa "}," Responsecallback ":" [Function]"," Withargs ": [7]}]," callbacks ": {" 0 ": [0," Responsecallback "]}}2015-07-29 15:29:08 [math] DEBUG Session" Ywydsey8iqkwfs3ckohh "is identified as"/kontrol/unknown/exp2/1.0.0/unknown/qpzhangdemac-mini.local/ A6a11fab-d476-4275-4770-a42ad6698c3d "Call received, sending result



At this point, the framework has run up.

But it's all in this machine.

"What about the kite architecture?" "How is The kite code written?" "Kite How to build a distributed system?" Are there any problems? 】

The follow-up slowly studied.


Koding Kite How do I deploy it?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.