sorintlab / stolon

PostgreSQL cloud native High Availability and more.
https://talk.stolon.io
Apache License 2.0
4.66k stars 447 forks source link

Run the Kubernetes example on Minikube #682

Closed JWDobken closed 5 years ago

JWDobken commented 5 years ago

I have minikube (version: v1.1.0) running locally with more than default resources (started with minikube --memory 8192 --cpus 2 start).

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.3", GitCommit:"721bfa751924da8d1680787490c54b9179b1fed0", GitTreeState:"clean", BuildDate:"2019-02-04T04:48:03Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.2", GitCommit:"66049e3b21efe110454d67df4fa62b08ea79a19b", GitTreeState:"clean", BuildDate:"2019-05-16T16:14:56Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}

Setup

I changes the proxy service to a NodePort type in stolon-proxy-service.yaml:

...
spec:
  type: NodePort
...

Now I create the roles, the role-bindings, the sentinels, the secret, the keepers, the proxy and the proxy servers as described in the readme:

$kubectl create -f role.yaml
role.rbac.authorization.k8s.io/stolon created
$kubectl create -f role-binding.yaml 
rolebinding.rbac.authorization.k8s.io/stolon created
$kubectl create -f stolon-sentinel.yaml
deployment.extensions/stolon-sentinel created
$kubectl create -f secret.yaml
secret/stolon created
$kubectl create -f stolon-keeper.yaml
statefulset.apps/stolon-keeper created
$kubectl create -f stolon-proxy.yaml
deployment.extensions/stolon-proxy created
$kubectl create -f stolon-proxy-service.yaml
service/stolon-proxy-service created

Connecting to the proxy service

Get the service port:

$kubectl get svc
NAME                   TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
kubernetes             ClusterIP   10.96.0.1       <none>        443/TCP          37m
stolon-proxy-service   NodePort    10.100.104.41   <none>        5432:30751/TCP   19m

Now, I preferably connect to the database with the psql connection as described in the Readme:

$psql --host $(minikube ip) --port 30751 postgres -U stolon -W
Password: 
psql: server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.

The proxy simply doesn't respond properly:

$curl $(minikube service stolon-proxy-service --url)
curl: (56) Recv failure: Connection reset by peer

However, the service list of minikube shows the NodePort is available:

$minikube service list
|-------------|----------------------|-----------------------------|
|  NAMESPACE  |         NAME         |             URL             |
|-------------|----------------------|-----------------------------|
| default     | kubernetes           | No node port                |
| default     | stolon-proxy-service | http://192.168.99.111:30751 |
| kube-system | default-http-backend | http://192.168.99.111:30001 |
| kube-system | kube-dns             | No node port                |
| kube-system | kubernetes-dashboard | No node port                |
|-------------|----------------------|-----------------------------|

All pods are running and ready:

$kubectl get po
NAME                              READY   STATUS    RESTARTS   AGE
stolon-keeper-0                   1/1     Running   0          43m
stolon-keeper-1                   1/1     Running   0          42m
stolon-proxy-5f977f8f88-8pxlj     1/1     Running   0          42m
stolon-proxy-5f977f8f88-z24q4     1/1     Running   0          42m
stolon-sentinel-c59758bcb-csx9n   1/1     Running   0          43m
stolon-sentinel-c59758bcb-zdchj   1/1     Running   0          43m

The logs of the proxy don't contain any unusual:

$kubectl logs stolon-proxy-5f977f8f88-8pxlj
...
2019-07-10T10:00:18.172Z        INFO    cmd/proxy.go:193        no clusterdata available, closing connections to master
2019-07-10T10:00:23.177Z        INFO    cmd/proxy.go:193        no clusterdata available, closing connections to master
2019-07-10T10:00:28.181Z        INFO    cmd/proxy.go:193        no clusterdata available, closing connections to master
2019-07-10T10:00:33.185Z        INFO    cmd/proxy.go:193        no clusterdata available, closing connections to master
2019-07-10T10:00:38.190Z        INFO    cmd/proxy.go:193        no clusterdata available, closing connections to master
Mattzr commented 5 years ago

Hi,

Getting exactly the same issues on my local kubernetes node provision by docker (mac). Also happening with in docker-ee.

sgotti commented 5 years ago

@JWDobken the proxy logs says that you haven't initialized the stolon cluster yet (stolonctl init as explained in the k8s example.