Skip to content
operational 4.69 KiB
Newer Older
* COMMENT -*- mode: org -*-
#+Date: 2019-04-02
Time-stamp: <2019-04-03>
#+STARTUP: content
* notes                                                               :entry:
** 2019-04-02 how to deploy get-client-ip?				:doc:
- update code as necessary.
  update version in get-client-ip.cabal
- build project using stack.
  stack build
- test the app
  stack exec get-client-ip
  env SERVE_HISTORY_PAGE=1 stack exec get-client-ip
  env SERVE_HISTORY_PAGE=1 HISTORY_SIZE=3 stack exec get-client-ip

  curl http://127.0.0.1:8081/
- build docker image
  ./build-docker-image.sh

  push docker image according to the output message.
- update docker image version in k8s app yaml
  ~/sysadmin/de02-kubernetes/apps/get-client-ip.yaml
- deploy k8s app
  http_proxy=127.0.0.1:8123
  kubectl apply -f ~/sysadmin/de02-kubernetes/apps/get-client-ip.yaml
- commit changes to git.
  project git.
  k8s app yaml git. ~/sysadmin/de02-kubernetes/

- problem
  - how to use proxy with kubectl apply?
    #+BEGIN_SRC sh
      sylecn@ryzen5:~/haskell/get-client-ip$ env https_proxy=127.0.0.1:8123 kubectl apply -f ~/sysadmin/de02-kubernetes/apps/get-client-ip.yaml
      unable to recognize "/home/sylecn/sysadmin/de02-kubernetes/apps/get-client-ip.yaml": Get https://88.99.191.174:6443/api?timeout=32s: Forbidden port
      unable to recognize "/home/sylecn/sysadmin/de02-kubernetes/apps/get-client-ip.yaml": Get https://88.99.191.174:6443/api?timeout=32s: Forbidden port
      unable to recognize "/home/sylecn/sysadmin/de02-kubernetes/apps/get-client-ip.yaml": Get https://88.99.191.174:6443/api?timeout=32s: Forbidden port
      sylecn@ryzen5:~/haskell/get-client-ip$ http_proxy=127.0.0.1:8123 kubectl apply -f ~/sysadmin/de02-kubernetes/apps/get-client-ip.yaml
      unable to recognize "/home/sylecn/sysadmin/de02-kubernetes/apps/get-client-ip.yaml": Get https://88.99.191.174:6443/api?timeout=32s: Forbidden port
      unable to recognize "/home/sylecn/sysadmin/de02-kubernetes/apps/get-client-ip.yaml": Get https://88.99.191.174:6443/api?timeout=32s: Forbidden port
      unable to recognize "/home/sylecn/sysadmin/de02-kubernetes/apps/get-client-ip.yaml": Get https://88.99.191.174:6443/api?timeout=32s: Forbidden port
    #+END_SRC

* later                                                               :entry:
* current                                                             :entry:
** 
* done                                                                :entry:
** 2019-04-03 v1.2.0 bug, should show last 10 calls. not all calls.
- add env var HISTORY_SIZE, default 10.
- dev
  - how to make {-# ANN module "HLint: ignore Redundant do" #-} work with
    OverloadedStrings extension?
    {-# ANN module ("HLint: ignore Redundant do" :: String) #-}
- fixed in v1.2.1

** 2019-04-02 make get-client-ip build docker image and deploy on gocd.
- uploading docker image from ryzen5 host is not good.
  oh, this image is public and on docker hub.

  see ~/sysadmin/de02-kubernetes/apps/get-client-ip.yaml
  it's using a public image.
- 
** 2019-04-02 show last 10 calls to get-client-ip.
provide a web page that shows last 10 calls
https://myip.emacsos.com/_calls

|    client-ip | time                       | user-agent        |
|--------------+----------------------------+-------------------|
| 49.67.97.101 | 02/Apr/2019:13:58:24 +0800 | Python-urllib/2.7 |

This allow me to get sheni's IP without login to de01 to see nginx log.

- dev
  - a in RAM buffer will do.
    but there are multiple instances deployed on k8s.
    use k8s redis service then.
  - use an async action to insert record to redis. allow it to fail.
    if redis is not running, that action just do nothing except leave a error
    msg log.
  - I don't want to introduce redis to the app. maybe just save in ram. user
    can call GET /_calls multiple times to see results from all nodes.
  - which data type to use as the ring buffer?

    haskell - Purely functional (persistent) ring buffer - Stack Overflow
    https://stackoverflow.com/questions/52898190/purely-functional-persistent-ring-buffer
    Data.Sequence

    fixed length circular buffer in haskell - Stack Overflow
    https://stackoverflow.com/questions/6510175/fixed-length-circular-buffer-in-haskell
    vector: Efficient Arrays

    I will use Data.Sequence.
  - do I need to make it thread safe? is persistent data types safe by
    default?

    yes. because it always return a new Seq object.
  - put it in a MVar.
  - why import getCurrentTime fail?
    import Date.Time.Clock (getCurrentTime)
    I have time in pkg list.

    it's typo. "Date" vs "Data"!!
  - build html response
    blaze
    lucid

    Lucid: templating DSL for HTML
    https://chrisdone.com/posts/lucid/
  - 

* wontfix                                                             :entry: