Friday, May 25, 2018

A simple Elasticsearch index


Create and populate a simple Elasticsearch index

curl -XPUT http://dev01:9200/test \
   -H 'Content-type:application/json' -d'{"
      settings":  {
         "number_of_shards":1,
         "number_of_replicas":1
      },
      "mappings": {
         "type": {
            "properties": {
               "f1": {
                  "type":"string"
               },
               "f2": {
                  "type":"string"
               },
               "f3": {
                  "type":"string"
               }
            }
          }
        }
      }'

Wednesday, May 23, 2018

Kubernetes development with minikube


Minikube's default memory parameters are fine for running small stacks, but more complex deployments, such as those including telemetry components like Prometheus or ELK, will demand larger resource allocations.

$ minikube delete
$ minikube start

Show Kubernetes dashboard on minikube:

$ minikube dashboard --url

without --url, the command above command launches a local browser.

List services in minikube:

$ minikube service list
|-------------|----------------------|-----------------------------|
|  NAMESPACE  |         NAME         |             URL             |
|-------------|----------------------|-----------------------------|
| default     | kubernetes           | No node port                |
| kube-system | kube-dns             | No node port                |
| kube-system | kubernetes-dashboard | http://192.168.99.102:30000 |
|-------------|----------------------|-----------------------------|

Minikube ports are bound to local IP addresses exposed by VM virtual net adapters. When accessing the minkube host remotely, you can either use a SSH tunnel, or use NAT in your VM runtime. For VirtualBox, e.g.:

$ vboxmanage controlvm "minikube" natpf1 "k8s,tcp,,30000,,30000"

To inspect the resulting change, check the NAT rules for the NIC:

$ vboxmanage showvminfo minikube
[...]
NIC 1:           MAC: 080027D238E5, Attachment: NAT, Cable connected: on, Trace: off [...]
[...]

NIC 1 Rule(2):   name = k8s, protocol = tcp, host ip = , host port = 30000, guest ip = , guest port = 30000
NIC 1 Rule(3):   name = ssh, protocol = tcp, host ip = 127.0.0.1, host port = 35283, guest ip = , guest port = 22