diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..95cdc41 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 Cees-Jan Kiewiet + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 3a2a065..646e52d 100644 --- a/README.md +++ b/README.md @@ -1 +1,47 @@ -# k8s-redis-db-asignment-operator \ No newline at end of file +# Kuberneter Redis Database Assignment Operator + +[![Github Actions](https://github.com/WyriHaximusNet/docker-kubernetes-redis-db-assignment-operator/workflows/Continuous%20Integration/badge.svg)](https://github.com/wyrihaximusnet/docker-kubernetes-redis-db-assignment-operator/actions) +[![Docker hub](https://img.shields.io/badge/Docker%20Hub-00a5c9.svg?logo=docker&style=flat&color=00a5c9&labelColor=00a5c9&logoColor=white)](https://hub.docker.com/r/wyrihaximusnet/kubernetes-redis-db-assignment-operator/) +[![Docker hub](https://img.shields.io/docker/pulls/wyrihaximusnet/kubernetes-redis-db-assignment-operator.svg?color=00a5c9&labelColor=03566a)](https://hub.docker.com/r/wyrihaximusnet/kubernetes-redis-db-assignment-operator/) +[![Docker hub](https://img.shields.io/microbadger/image-size/wyrihaximusnet/kubernetes-redis-db-assignment-operator/7.4-zts-alpine3.12.svg?color=00a5c9&labelColor=03566a)](https://hub.docker.com/r/wyrihaximusnet/kubernetes-redis-db-assignment-operator/) + +## Usage + +Suggested usage is to use [`Helm`](https://hub.helm.sh/charts/wyrihaximusnet/redis-db-assignment-operator) to install this operator: + +```bash +helm repo add WyriHaximusNet https://helm.wyrihaximus.net/ +helm repo update +helm upgrade redis-db-assignment-operator WyriHaximusNet/redis-db-assignment-operator --install --wait --atomic --namespace=redis +``` + +After the Helm install following definition will create a redis-database resource on your cluster. The operator picks +it up and finds a redis database that isn't in use according to the operators internal state. + +```yaml +apiVersion: wyrihaximus.net/v1 +kind: RedisDatabase +metadata: + name: example +spec: + secret: + name: example-redis-database + service: + read: redis://redis-follower.redis.svc.cluster.local:6379/ + write: redis://redis-leader.redis.svc.cluster.local:6379/ +``` + +The resulting secret looks like this: + +```yaml +apiVersion: v1 +kind: Secret +type: Opaque +metadata: + name: example-redis-database + namespace: default +data: + DATABASE: BASE64_ENCODED + READ: BASE64_ENCODED + WRITE: BASE64_ENCODED +``` diff --git a/crd/v1-example.yaml b/crd/v1-example.yaml new file mode 100644 index 0000000..86a0b4d --- /dev/null +++ b/crd/v1-example.yaml @@ -0,0 +1,10 @@ +apiVersion: wyrihaximus.net/v1 +kind: RedisDatabase +metadata: + name: example +spec: + secret: + name: example-redis-database + service: + read: redis://redis-follower.redis.svc.cluster.local:6379/ + write: redis://redis-leader.redis.svc.cluster.local:6379/ diff --git a/crd/v1.yaml b/crd/v1.yaml new file mode 100644 index 0000000..15823d6 --- /dev/null +++ b/crd/v1.yaml @@ -0,0 +1,44 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: redis-databases.wyrihaximus.net +spec: + group: wyrihaximus.net + scope: Namespaced + names: + plural: redis-databases + singular: redis-database + kind: RedisDatabase + categories: [ redis ] + versions: + - name: v1 + served: true + storage: true + schema: + openAPIV3Schema: + type: object + properties: + spec: + type: object + required: [secret, service] + properties: + secret: + type: object + required: [name] + properties: + name: + type: string + nullable: false + description: The name of the secret to create with the connection details + service: + type: object + required: [read, write] + properties: + read: + type: string + nullable: false + description: Read access service + write: + type: string + nullable: false + description: Write access service