You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.8 KiB

  1. # Using with lightclient
  2. We have an awesome cluster running, let's try to test this out without
  3. relying on executing commands on the cluster. Rather, we can connect to the
  4. rpc interface with the `light-client` package and execute commands locally,
  5. or even proxy our webapp to the kubernetes backend.
  6. ## Setup
  7. In order to get this working, we need to know a few pieces of info,
  8. the chain id of tendermint, the chain id of basecoin, and an account
  9. with a bit of cash....
  10. ### Tendermint Chain ID
  11. `kubectl exec -c tm tm-0 -- curl -s http://tm-1.basecoin:46657/status | json_pp | grep network`
  12. set TM_CHAIN with the value there
  13. ### Basecoin Chain ID
  14. `kubectl exec -c app tm-1 -- grep -A1 chainID /app/genesis.json`
  15. set BC_CHAIN with the value there
  16. ### Expose tendermint rpc
  17. We need to be able to reach the tendermint rpc interface from our shell.
  18. `kubectl port-forward tm-0 46657:46657`
  19. ### Start basecoin-proxy
  20. Using this info, let's connect our proxy and get going
  21. `proxy-basecoin -tmchain=$TM_CHAIN -chain=$BC_CHAIN -rpc=localhost:46657`
  22. ## Basecoin accounts
  23. Well, we can connect, but we don't have a registered account yet...
  24. Let's look around, then use the cli to send some money from one of
  25. the validators to our client's address so we can play.
  26. **TODO** we can add some of our known accounts (from `/keys`) into
  27. the genesis file, so we can skip all the kubectl money fiddling here.
  28. We will want to start with money on some known non-validators.
  29. ### Getting validator info (kubectl)
  30. The basecoin app deployment starts with 1000 "blank" coin in an account of
  31. each validator. Let's get the address of the first validator
  32. `kubectl exec -c app tm-1 -- grep address /app/key.json`
  33. Store this info as VAL1_ADDR
  34. ### Querying state (proxy)
  35. The proxy can read any public info via the tendermint rpc, so let's check
  36. out this account.
  37. `curl localhost:8108/query/account/$VAL1_ADDR`
  38. Now, let's make out own account....
  39. `curl -XPOST http://localhost:8108/keys/ -d '{"name": "k8demo", "passphrase": "1234567890"}'`
  40. (or pick your own user and password). Remember the address you get here. You can
  41. always find it out later by calling:
  42. `curl http://localhost:8108/keys/k8demo`
  43. and store it in DEMO_ADDR, which is empty at first
  44. `curl localhost:8108/query/account/$DEMO_ADDR`
  45. ### "Stealing" validator cash (kubectl)
  46. Run one command, that will be signed, now we have money
  47. `kubectl exec -c app tm-0 -- basecoin tx send --to <k8demo-address> --amount 500`
  48. ### Using our money
  49. Returning to our remote shell, we have a remote account with some money.
  50. Let's see that.
  51. `curl localhost:8108/query/account/$DEMO_ADDR`
  52. Cool. Now we need to send it to a second account.
  53. `curl -XPOST http://localhost:8108/keys/ -d '{"name": "buddy", "passphrase": "1234567890"}'`
  54. and store the resulting address in BUDDY_ADDR
  55. **TODO** finish this