|
1 | 1 | ## Stolon Client (stolonctl)
|
2 | 2 |
|
3 |
| -`stolonctl` is the stolon client which controls the stolon cluster(s) |
| 3 | +`stolonctl` is the stolon client which controls the stolon cluster(s). |
4 | 4 |
|
5 |
| -It needs to communicate with the cluster store (providing `--store-backend` and related option) on which the requested cluster name (`--cluster-name`) is running. |
| 5 | +Since `stolonctl`needs to communicate with the cluster backend store, it requires providing the requested cluster name (`--cluster-name`), its store backend type (`--store-backend`), and how to reach the store, such as: |
| 6 | +* For etcdv2, etcdv3 or consul as store, a comma separated list of endpoints (`--store--endpoints`). |
| 7 | +* For kubernetes as store, the kind of kubernetes resources (`--kube-resource-kind`). See below. |
6 | 8 |
|
7 |
| -To avoid repeating for every command (or inside scripts) all the options you can export them as environment variables. Their name will be the same as the option name converted in uppercase, with `_` replacing `-` and prefixed with `STOLONCTL_`. |
| 9 | +`stolonctl` example for checking the status of a cluster named "stolon-cluster" using "etcdv3" as a store backend: |
| 10 | +``` |
| 11 | +$ stolonctl --cluster-name=stolon-cluster --store-backend=etcdv3 --store-endpoints=http://etcd-0:2379,http://etcd-1:2379,http://etcd-2:2379 status |
| 12 | +``` |
| 13 | + |
| 14 | +Note: To avoid repeating the arguments on every command (or inside scripts), all the options can be exported as environment variables. Their name will be the same as the option name converted in uppercase, with `_` replacing `-` and prefixed with `STOLONCTL_`. |
8 | 15 |
|
9 |
| -Ex. |
| 16 | +For example: |
10 | 17 | ```
|
11 | 18 | STOLONCTL_STORE_BACKEND
|
12 | 19 | STOLONCTL_STORE_ENDPOINTS
|
13 | 20 | STOLONCTL_CLUSTER_NAME
|
14 | 21 | ```
|
15 | 22 |
|
| 23 | +### Running in Kubernetes |
| 24 | + |
| 25 | +`stolonctl` behaves like [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) when choosing how to access the kubernetes API server(s): |
| 26 | +* When run inside a pod it uses the pod service account to connect to the k8s API servers. |
| 27 | +* When run externally it honors the $KUBECONFIG environment variable to connect. It is thus possible to use the default `~/.kube/config` file or an overriden kube-config file path, context and namespace to set the `stolonctl` options `--kubeconfig`, `--kube-context` and `--kube-namespace`. |
| 28 | + |
| 29 | +`stolonctl` example for checking the status of a cluster named "kube-stolon" using "kubernetes" as a store backend and "configmap" as the resource kind where the `stolonctl` command is invoked via one of the stolon proxy pods: |
| 30 | +``` |
| 31 | +$kubectl exec -i -t stolon-proxy-669f7b54fd-9psm2 -- stolonctl --cluster-name=kube-stolon --store-backend=kubernetes --kube-resource-kind=configmap status |
| 32 | +``` |
| 33 | + |
| 34 | +Same `stolonctl` command as a one shot: |
| 35 | +``` |
| 36 | +kubectl run -i -t stolonctl --image=sorintlab/stolon:master-pg9.6 --restart=Never --rm -- /usr/local/bin/stolonctl --cluster-name=kube-stolon --store-backend=kubernetes --kube-resource-kind=configmap status |
| 37 | +``` |
| 38 | + |
16 | 39 | ### See also
|
17 | 40 |
|
18 | 41 | [stolonctl command invocation](commands/stolonctl.md)
|
0 commit comments