Kubernetes + coreos/etcd setup in Google Cloud

253 views
Skip to first unread message

Mohammad Farooqui

unread,
Feb 13, 2018, 7:55:22 PM2/13/18
to etcd-dev
Hi All,

I am trying to use 'coreos/etcd' product in one of my projects.

What I am using :
1 - Google Cloud
2 - Google Cloud Hosted Kubernetes
3 - Coreos/etcd
4 - Spring boot web application

Spring boot application will call internally Coreos/etcd cluster/LB.

Steps what I did:
1 - I configured Kubernetes with 1 cluster and 3 nodes.
2 - I run the below Docker image (quay.io/coreos/etcd:v3.2):

kubectl run etcd --replicas=3 --image=quay.io/coreos/etcd:v3.2 --port=2379
kubectl expose deployment etcd --type=LoadBalancer
3 - After run above, I checked PODs in Google Cloud:
*********@kubernetes-app-194818:~/gopath_bkp/bin$ kubectl get pods
NAME                           READY     STATUS    RESTARTS   AGE
etcd-1508109573-2rw85          1/1       Running   0          4m
etcd-1508109573-dm0w9          1/1       Running   0          4m
etcd-1508109573-vkskm          1/1       Running   0          4m
hello-server-732511812-glgqt   1/1       Running   0          1h

4 - Running Services:
*******@kubernetes-app-194818:~/gopath_bkp/bin$ kubectl get services
NAME           TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)          AGE
etcd           LoadBalancer   10.31.248.57    104.198.225.37   2379:31022/TCP   4m
hello-server   LoadBalancer   10.31.240.232   35.192.213.33    8080:32686/TCP   1h
kubernetes     ClusterIP      10.31.240.1     <none>           443/TCP          3d

5: ETCD YAML file
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: 2018-02-13T22:54:42Z
  labels:
run: etcd
  name: etcd
  namespace: default
  resourceVersion: "359365"
  selfLink: /api/v1/namespaces/default/services/etcd
  uid: e0e9981e-1110-11e8-b62d-42010a800084
spec:
  clusterIP: 10.31.248.57
  externalTrafficPolicy: Cluster
  ports:
  - nodePort: 31022
port: 2379
protocol: TCP
targetPort: 2379
  selector:
run: etcd
  sessionAffinity: None
  type: LoadBalancer
status:
  loadBalancer:
ingress:
- ip: 104.198.225.37


If I am trying to access http://104.198.225.37:2379/version then getting an error like 'This site can’t be reached 104.198.225.37 refused to connect.
In the same way when I am hitting http://35.192.213.33:8080/ then I am getting the proper response.

Can you please help and let me know the issue and how I can fix this?

Thanks,
Mohammad Farooqui

Sam Batschelet

unread,
Feb 13, 2018, 10:02:28 PM2/13/18
to etcd-dev


On Tuesday, February 13, 2018 at 7:55:22 PM UTC-5, Mohammad Farooqui wrote:

kubectl run etcd --replicas=3 --image=quay.io/coreos/etcd:v3.2 --port=2379
kubectl expose deployment etcd --type=LoadBalancer

Pretty sure this will only deploy 3 etcd nodes with default settings listening on localhost 2379. They will not know about each other and thus will not form cluster or listen to external ip. I think you should read etcd clustering guide to learn about how etcd cluster configs should look. Next take a look at this example:  kubernetes deployment config for etcd. Also since you have Kubernetes already maybe you should try etcd-operator? This would perhaps lower the learning curve and make management easier. I hope this helps.

-Sam

Mohammad Farooqui

unread,
Feb 14, 2018, 1:44:18 PM2/14/18
to etcd-dev
Thank you, Sam, do we have some setup guidelines for Google (GCP) + Kubernetes + ETCD?

Also, I checked below for one etcd node: 

*****@kubernetes-app-194818:~$ kubectl get pods
NAME                           READY     STATUS    RESTARTS   AGE
etcd-1508109573-2rw85          1/1       Running   0          4h
etcd-1508109573-dm0w9          1/1       Running   0          4h
etcd-1508109573-vkskm          1/1       Running   0          4h
hello-server-732511812-glgqt   1/1       Running   0          6h
*****@kubernetes-app-194818:~$ kubectl get pod etcd-1508109573-2rw85
NAME                    READY     STATUS    RESTARTS   AGE
etcd-1508109573-2rw85   1/1       Running   0          5h
******@kubernetes-app-194818:~$ kubectl exec -it etcd-1508109573-2rw85 /bin/sh
/ # netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:2379          0.0.0.0:*               LISTEN      1/etcd
tcp        0      0 127.0.0.1:2380          0.0.0.0:*               LISTEN      1/etcd
/ # 
Reply all
Reply to author
Forward
0 new messages