-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from spotahome/improve-documentation
Improve docs. Add examples. Fix typos.
- Loading branch information
Showing
9 changed files
with
190 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,48 @@ | ||
# Development | ||
|
||
## Folder structure | ||
|
||
### Code folder structure | ||
* **api**: definition of the RedisFailover CRD. | ||
* **client**: autogenerated client to interact with redis-failovers. | ||
* **cmd**: contains the starting point of the application. | ||
* **log**: wrapper of logrus, created to be able to mock it. | ||
* **metrics**: exposer of status of the failovers created. | ||
* **mocks**: contains the mocked interfaces for testing the application. | ||
* **operator**: the main logic. Manages the requests from k8s and creates/updates/deletes the pieces as needed. | ||
* **service**: services/clients to interact with k8s and redises. | ||
* **vendor**: vendored packages used by the application. | ||
|
||
- **api**: definition of the RedisFailover CRD. | ||
- **client**: autogenerated client to interact with redis-failovers. | ||
- **cmd**: contains the starting point of the application. | ||
- **log**: wrapper of logrus, created to be able to mock it. | ||
- **metrics**: exposer of status of the failovers created. | ||
- **mocks**: contains the mocked interfaces for testing the application. | ||
- **operator**: the main logic. Manages the requests from k8s and creates/updates/deletes the pieces as needed. | ||
- **service**: services/clients to interact with k8s and redises. | ||
- **vendor**: vendored packages used by the application. | ||
|
||
### Non-code folder structure | ||
* **charts**: helm chart to deploy the operator. | ||
* **docker**: Dockerfiles to generate redis-failover docker images. | ||
* **example**: yaml files with spec of redis-failover. | ||
* **hack**: scripts to generate the redis-failover api-client. | ||
* **scripts**: scripts used to build and run the app. | ||
|
||
- **charts**: helm chart to deploy the operator. | ||
- **docker**: Dockerfiles to generate redis-failover docker images. | ||
- **example**: yaml files with spec of redis-failover. | ||
- **hack**: scripts to generate the redis-failover api-client. | ||
- **scripts**: scripts used to build and run the app. | ||
|
||
## Make development commands | ||
|
||
You can do the following commands with make: | ||
* Build the development container. | ||
`make docker-build` | ||
* Generate mocks. | ||
`make go-generate` | ||
* Generate client | ||
`make update-codegen` | ||
* Run tests. | ||
`make test` | ||
* Build the executable file. | ||
`make build` | ||
* Run the app. | ||
`make run` | ||
* Access the docker instance with a shell. | ||
`make shell` | ||
* Install dependencies | ||
`make get-deps` | ||
* Update dependencies | ||
`make update-deps` | ||
* Build the app image. | ||
`make image` | ||
|
||
- Build the development container. | ||
`make docker-build` | ||
- Generate mocks. | ||
`make go-generate` | ||
- Generate client | ||
`make update-codegen` | ||
- Run tests. | ||
`make test` | ||
- Build the executable file. | ||
`make build` | ||
- Run the app. | ||
`make run` | ||
- Access the docker instance with a shell. | ||
`make shell` | ||
- Install dependencies | ||
`make get-deps` | ||
- Update dependencies | ||
`make update-deps` | ||
- Build the app image. | ||
`make image` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
# Controller logic | ||
|
||
## Creation pipeline | ||
|
||
The Redis-Operator creates Redis Failovers, with all the needed pieces. So, when a event arrives from Kubernetes (add or sync), the following steps are executed: | ||
* Ensure: checks that all the pieces needed are created. It is important to notice that if a change is performed manually on the objects created, the operator will override them. This is done to ensure a healthy status. It will create the following: | ||
* Redis configmap | ||
* Redis statefulset | ||
* Redis service (if exporter enabled) | ||
* Sentinel configmap | ||
* Sentinel deployment | ||
* Sentinel service | ||
* Check & Heal: will connect to every Redis and Sentinel and will ensure that they are working as they are supposed to do. If this is not the case, it will reconfigure the nodes to move them to the desire state. It will check the following: | ||
* Number of Redis is equal as the set on the RF spec | ||
* Number of Sentinel is equal as the set on the RF spec | ||
* Only one Redis working as a master | ||
* All Redis slaves have the same master | ||
* All Redis slaves are connected to the master | ||
* All Sentinels points to the same Redis master | ||
* Sentinel has not death nodes | ||
* Sentinel knows the correct slave number | ||
|
||
Most of the problems that may occur will be treated and tried to fix by the controller, except the case that there are a [split-brain](https://en.wikipedia.org/wiki/Split-brain_(computing)). **If happens to be a split-brain, an error will be logged waiting for manual fix**. | ||
- Ensure: checks that all the pieces needed are created. It is important to notice that if a change is performed manually on the objects created, the operator will override them. This is done to ensure a healthy status. It will create the following: | ||
- Redis service (if exporter enabled) | ||
- Redis configmap | ||
- Redis shutdown configmap | ||
- Redis statefulset | ||
- Sentinel service | ||
- Sentinel configmap | ||
- Sentinel deployment | ||
- Check & Heal: will connect to every Redis and Sentinel and will ensure that they are working as they are supposed to do. If this is not the case, it will reconfigure the nodes to move them to the desire state. It will check the following: | ||
- Number of Redis is equal as the set on the RF spec | ||
- Number of Sentinel is equal as the set on the RF spec | ||
- Only one Redis working as a master | ||
- All Redis slaves have the same master | ||
- All Redis slaves are connected to the master | ||
- All Sentinels points to the same Redis master | ||
- Sentinel has not death nodes | ||
- Sentinel knows the correct slave number | ||
- Ensure Redis has the custom configuration set | ||
- Ensure Sentinel has the custom configuration set | ||
|
||
Most of the problems that may occur will be treated and tried to fix by the controller, except the case that there are a [split-brain](<https://en.wikipedia.org/wiki/Split-brain_(computing)>). **If happens to be a split-brain, an error will be logged waiting for manual fix**. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: storage.spotahome.com/v1alpha2 | ||
kind: RedisFailover | ||
metadata: | ||
name: redisfailover | ||
spec: | ||
sentinel: | ||
replicas: 3 | ||
resources: | ||
requests: | ||
cpu: 100m | ||
limits: | ||
memory: 100Mi | ||
redis: | ||
replicas: 3 | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 100Mi | ||
limits: | ||
cpu: 400m | ||
memory: 500Mi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: storage.spotahome.com/v1alpha2 | ||
kind: RedisFailover | ||
metadata: | ||
name: redisfailover | ||
spec: | ||
sentinel: | ||
replicas: 3 | ||
customConfig: | ||
- "down-after-milliseconds 2000" | ||
- "failover-timeout 3000" | ||
redis: | ||
replicas: 3 | ||
customConfig: | ||
- "maxclients 100" | ||
- "hz 50" | ||
- "timeout 60" |
Oops, something went wrong.