etcd-operator/README.md

119 строки
2.6 KiB
Markdown
Исходник Обычный вид История

2016-08-05 03:12:08 +03:00
# kube-etcd-controller
2016-08-10 03:58:05 +03:00
Managed etcd clusters on Kubernetes:
- creation
- destroy
- resize
- recovery
- backup
- rolling upgrade
2016-08-10 04:13:58 +03:00
## Requirements
Kubernetes 1.4+
2016-08-05 03:12:08 +03:00
## Initialize the TPR
(TODO: auto create TPR when deploy the controller)
```bash
2016-08-05 03:35:46 +03:00
$ cat example/etcd-clusters-tpr.yaml
2016-08-05 03:12:08 +03:00
```
```yaml
apiVersion: extensions/v1beta1
kind: ThirdPartyResource
description: "Managed etcd clusters"
metadata:
name: "etcd-cluster.coreos.com"
versions:
- name: v1
- name: v2
```
```bash
2016-08-05 03:35:46 +03:00
$ kubectl create -f example/etcd-clusters-tpr.yaml
2016-08-05 03:33:10 +03:00
2016-08-05 03:35:46 +03:00
$ kubectl get thirdpartyresources
2016-08-05 03:12:08 +03:00
NAME DESCRIPTION VERSION(S)
etcd-cluster.coreos.com Managed etcd clusters v1,v2
```
2016-08-05 03:30:46 +03:00
## Deploy kube-etcd-controller
```bash
2016-08-10 03:20:01 +03:00
$ kubectl create -f example/etcd-controller.yaml
2016-08-05 03:30:46 +03:00
```
2016-08-05 03:12:08 +03:00
## Create an etcd cluster
```bash
2016-08-05 03:35:46 +03:00
$ cat example/example-etcd-cluster.yaml
2016-08-05 03:12:08 +03:00
```
```yaml
apiVersion: "coreos.com/v1"
kind: "EtcdCluster"
metadata:
name: "example-etcd-cluster"
size: 3
```
```bash
2016-08-05 03:35:46 +03:00
$ kubectl create -f example/example-etcd-cluster.yaml
2016-08-05 03:12:08 +03:00
```
```bash
2016-08-05 03:35:46 +03:00
$ kubectl get pods
2016-08-10 00:20:42 +03:00
NAME READY STATUS RESTARTS AGE
example-etcd-cluster-0000 1/1 Running 0 5s
example-etcd-cluster-0001 1/1 Running 0 5s
example-etcd-cluster-0002 1/1 Running 0 5s
2016-08-05 03:12:08 +03:00
```
```bash
2016-08-05 03:35:46 +03:00
$ kubectl get services
2016-08-10 00:20:42 +03:00
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
example-etcd-cluster-0000 10.0.125.56 <none> 2380/TCP 49s
example-etcd-cluster-0001 10.0.189.13 <none> 2380/TCP 49s
example-etcd-cluster-0002 10.0.87.110 <none> 2380/TCP 49s
2016-08-10 00:23:45 +03:00
kubernetes 10.0.0.1 <none> 443/TCP 8m
2016-08-05 03:12:08 +03:00
```
```bash
2016-08-10 00:20:42 +03:00
$ kubectl log example-etcd-cluster-0000
2016-08-05 03:35:46 +03:00
...
2016-08-05 00:33:32.453768 I | api: enabled capabilities for version 3.0
2016-08-05 00:33:32.454178 N | etcdmain: serving insecure client requests on 0.0.0.0:2379, this is strongly discouraged!
2016-08-05 03:12:08 +03:00
```
2016-08-10 00:20:42 +03:00
2016-08-10 03:58:05 +03:00
## Destroy an existing etcd cluster
2016-08-10 00:20:42 +03:00
```bash
$ kubectl delete -f example/example-etcd-cluster.yaml
```
```bash
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
```
2016-08-10 03:45:48 +03:00
## Try cluster reocvery
Simulate a pod failure by simply delete it
```bash
$ kubectl delete pod example-etcd-cluster-0000
```
etcd controller will recover the failure by creating a new pod `example-etcd-cluster-0003`
```bash
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
example-etcd-cluster-0001 1/1 Running 0 5s
example-etcd-cluster-0002 1/1 Running 0 5s
example-etcd-cluster-0003 1/1 Running 0 5s
```