Skip to content

Commit

Permalink
Pull request OT-CONTAINER-KIT#10: Sync redis-operator from upstream @…
Browse files Browse the repository at this point in the history
… v0.13.0

Merge in OSS/redis-operator from ~ATHOMPSON/redis-operator:sync-upstream-0.13 to cs-main

* commit '4e0dafa8227f0ed1ff9966000a477c29fa99af57': (38 commits)
  Handle nil probe
  Bumps prometheus/client_golang to address vuln
  Adds CODEOWNERS for our internal branch
  [Development][Update]Updated information for v0.13.0 (OT-CONTAINER-KIT#374)
  Create CODE_OF_CONDUCT.md
  [feature]add tls for redis-standlone (OT-CONTAINER-KIT#372)
  Update README.md
  Create package.json
  Revamped documentation for better knowledge base (OT-CONTAINER-KIT#370)
  [Development][Change] Change ctrl time for errors (OT-CONTAINER-KIT#369)
  Added logic for updating followers replicas (OT-CONTAINER-KIT#367)
  Updated the security context for controller manager (OT-CONTAINER-KIT#366)
  Renamed the external config to additional config (OT-CONTAINER-KIT#365)
  fix: lost replications when followerReplicas bigger than leaderReplicas (OT-CONTAINER-KIT#361)
  [Development][Add] Added update strategy for statefulset (OT-CONTAINER-KIT#358)
  Update pipeline.yaml
  Added build arg for arm64 support (OT-CONTAINER-KIT#356)
  [Development][Add] Added option to pause reconcilations (OT-CONTAINER-KIT#353)
  Changed publish branch
  Removed docs from path of build
  ...
  • Loading branch information
devkmsg committed Feb 8, 2023
2 parents 8e2bbee + 4e0dafa commit 167c0d6
Show file tree
Hide file tree
Showing 7,524 changed files with 359,510 additions and 9,894 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 2 additions & 2 deletions .azure-pipelines/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ extends:
ApplicationName: redis-operator
QuayImageName: opstree/redis-operator
GithubImageName: ot-container-kit/redis-operator/redis-operator
BuildDocs: true
AppVersion: "0.10.0"
BuildDocs: false
AppVersion: "v0.13.0"
GolangVersion: "1.17"
25 changes: 25 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
Please read https://github.com/OT-CONTAINER-KIT/redis-operator/blob/master/CONTRIBUTING.md before submitting
your pull request. Please fill in each section below to help us better prioritize your pull request. Thanks!
-->

**Description**

<!-- Please provide a summary of the change here. -->

<!-- Please link to all GitHub issue that this pull request implements(i.e. Fixes #123) -->
Fixes #ISSUE

**Type of change**

<!-- Please delete options that are not relevant. -->

* Bug fix (non-breaking change which fixes an issue)
* New feature (non-breaking change which adds functionality)
* Breaking change (fix or feature that would cause existing functionality to not work as expected)

**Checklist**

- [ ] Testing has been performed
- [ ] No functionality is broken
- [ ] Documentation updated
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ testbin/*
*.swp
*.swo
*~
.vscode

docs/build
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
### v0.13.0
##### November 10, 2022

#### :beetle: Bug Fixes

- Fixed multiple follower logic for redis cluster

#### :tada: Features

- Updated all examples for Redis v7
- Revamped documentation with the latest information
- Added pause option for reconcilations
- Added support for arm64
- Added update strategy for statefulset
- Added logic for updating follower replicas
- Added TLS feature for standalone

### v0.12.0
##### October 12, 2022

#### :beetle: Bug Fixes

- PDB (Pod disruption budget) creation issue
- Fixed cluster recovery logic
- Fixed IP check and conversion logic
- Persistence issue fix

#### :tada: Features

- Added pvc, pv clusterrole fix
- Support for defining serviceAccount
- Closing of redis client connection
- Added finalizer for statefulset
- Added Prometheus service annotation
- Added support for Redis 7 with DNS hostname

### v0.11.0
##### July 5, 2022

Expand Down
128 changes: 128 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
opensource@opstree.com.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
174 changes: 174 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# CONTRIBUTING

## Prerequisites

- [Kubernetes Cluster](https://kubernetes.io)
- [Git](https://git-scm.com/downloads)
- [Go](https://golang.org/dl/)
- [Docker](https://docs.docker.com/install/)
- [Operator SDK](https://github.com/operator-framework/operator-sdk/releases)
- [Make](https://www.gnu.org/software/make/manual/make.html)
- [Eksctl](https://eksctl.io/)

## Local Kubernetes Cluster

For development and testing of operator on local system, we need to set up a [Minikube](https://minikube.sigs.k8s.io/docs/start/) or local Kubernetes cluster.

Minikube is a single node Kubernetes cluster that generally gets used for the development and testing on Kubernetes. For creating a Minkube cluster we need to simply run:

```shell
$ minikube start --vm-driver virtualbox
...
😄 minikube v1.0.1 on linux (amd64)
🤹 Downloading Kubernetes v1.14.1 images in the background ...
🔥 Creating kvm2 VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
📶 "minikube" IP address is 192.168.39.240
🐳 Configuring Docker as the container runtime ...
🐳 Version of container runtime is 18.06.3-ce
⌛ Waiting for image downloads to complete ...
✨ Preparing Kubernetes environment ...
🚜 Pulling images required by Kubernetes v1.14.1 ...
🚀 Launching Kubernetes v1.14.1 using kubeadm ...
⌛ Waiting for pods: apiserver proxy etcd scheduler controller dns
🔑 Configuring cluster permissions ...
🤔 Verifying component health .....
💗 kubectl is now configured to use "minikube"
🏄 Done! Thank you for using minikube!
```

## Cloud Kubernetes Cluster

For cloud based Kubernetes cluster we can use any type of platforms like [Amazon Web Service](https://aws.amazon.com/), [Azure Cloud](https://azure.microsoft.com/en-in/), or [Google Cloud Platform](https://cloud.google.com/). We have provided an [eks-cluster.yaml](./example/eks-cluster.yaml) file for creating an Elastic Kubernetes Service(EKS) using [eksctl](https://eksctl.io/).

`eksctl` is a cli tool to create a Kubernetes cluster on EKS by a single command. It supports creation of Ipv4 and Ipv6 based Kubernetes clusters for development.

```shell
$ eksctl create cluster -f example/eks-cluster.yaml
...
2022-10-30 19:47:44 [ℹ] eksctl version 0.114.0
2022-10-30 19:47:44 [ℹ] using region us-west-2
2022-10-30 19:47:45 [ℹ] setting availability zones to [us-west-2d us-west-2c us-west-2a]
2022-10-30 19:47:45 [ℹ] subnets for us-west-2d - public:192.168.0.0/19 private:192.168.96.0/19
2022-10-30 19:47:45 [ℹ] subnets for us-west-2c - public:192.168.32.0/19 private:192.168.128.0/19
2022-10-30 19:47:45 [ℹ] subnets for us-west-2a - public:192.168.64.0/19 private:192.168.160.0/19
2022-10-30 19:47:45 [ℹ] nodegroup "ng-1" will use "" [AmazonLinux2/1.22]
2022-10-30 19:47:45 [ℹ] using SSH public key "/Users/abhishekdubey/.ssh/id_rsa.pub" as "eksctl-operator-testing-nodegroup-ng-1-8b:2b:b2:fc:4c:7f:9c:0d:54:14:70:39:25:b5:6d:60"
2022-10-30 19:47:47 [ℹ] using Kubernetes version 1.22
2022-10-30 19:47:47 [ℹ] creating EKS cluster "operator-testing" in "us-west-2" region with managed nodes
2022-10-30 19:47:47 [ℹ] 1 nodegroup (ng-1) was included (based on the include/exclude rules)
2022-10-30 19:47:47 [ℹ] will create a CloudFormation stack for cluster itself and 0 nodegroup stack(s)
2022-10-30 19:47:47 [ℹ] will create a CloudFormation stack for cluster itself and 1 managed nodegroup stack(s)
2022-10-30 19:47:47 [ℹ] if you encounter any issues, check CloudFormation console or try 'eksctl utils describe-stacks --region=us-west-2 --cluster=operator-testing'
2022-10-30 19:47:47 [ℹ] Kubernetes API endpoint access will use default of {publicAccess=true, privateAccess=false} for cluster "operator-testing" in "us-west-2"
2022-10-30 19:47:47 [ℹ] CloudWatch logging will not be enabled for cluster "operator-testing" in "us-west-2"
2022-10-30 19:47:47 [ℹ] you can enable it with 'eksctl utils update-cluster-logging --enable-types={SPECIFY-YOUR-LOG-TYPES-HERE (e.g. all)} --region=us-west-2 --cluster=operator-testing'
2022-10-30 19:47:47 [ℹ]
2 sequential tasks: { create cluster control plane "operator-testing",
2 sequential sub-tasks: {
5 sequential sub-tasks: {
wait for control plane to become ready,
associate IAM OIDC provider,
no tasks,
restart daemonset "kube-system/aws-node",
1 task: { create addons },
},
create managed nodegroup "ng-1",
}
}
2022-10-30 19:47:47 [ℹ] building cluster stack "eksctl-operator-testing-cluster"
2022-10-30 19:47:50 [ℹ] deploying stack "eksctl-operator-testing-cluster"
2022-10-30 20:01:17 [ℹ] daemonset "kube-system/aws-node" restarted
2022-10-30 20:01:18 [ℹ] creating role using recommended policies
2022-10-30 20:01:20 [ℹ] deploying stack "eksctl-operator-testing-addon-vpc-cni"
2022-10-30 20:01:20 [ℹ] waiting for CloudFormation stack "eksctl-operator-testing-addon-vpc-cni"
2022-10-30 20:01:52 [ℹ] waiting for CloudFormation stack "eksctl-operator-testing-addon-vpc-cni"
2022-10-30 20:02:24 [ℹ] waiting for CloudFormation stack "eksctl-operator-testing-addon-vpc-cni"
2022-10-30 20:02:26 [ℹ] creating addon
2022-10-30 20:02:37 [ℹ] addon "vpc-cni" active
2022-10-30 20:02:39 [ℹ] building managed nodegroup stack "eksctl-operator-testing-nodegroup-ng-1"
```
For setting up the Ipv4 or Ipv6 cluster with eksctl, we need to modify this configuration in the [eks-cluster.yaml](./example/eks-cluster.yaml):
```yaml
kubernetesNetworkConfig:
ipFamily: IPv4
# ipFamily: IPv6
```
## Operator structure
The structure for Redis operator includes different module's directory. The codebase include these major directories:
```shell
redis-operator/
|-- api
| |-- v1beta1
|-- bin
|-- config
| |-- certmanager
| |-- crd
| | |-- bases
| | |-- patches
| |-- default
| |-- manager
| |-- prometheus
| |-- rbac
| |-- samples
| |-- scorecard
| |-- bases
| |-- patches
|-- controllers
|-- hack
|-- k8sutils
```
As part of the development, generally, we modify the codebase in API, controllers, and k8sutils. The API modules hold the interface and structure for CRD definition, the controllers are the watch controllers that create, update, and delete the resources. The k8sutils is a module in which all the Kubernetes resources(Statefulsets, Services, etc.) codebase is present.
### Building Operator
For building operator, we can execute make command to create binary and docker image:
```shell
$ make manager
$ make docker-build
```
For any change inside the `api` module, we need to recreate the CRD schema because of interface changes. To generate the CRD manifest and RBAC policies updated by operator:
```shell
$ make manifests
```
### Deploying Operator
The operator deployment can be done via `helm` cli, we just need to define the custom image name and tag for testing the operator functionality:
```shell
$ helm upgrade redis-operator ot-helm/redis-operator \
--install --namespace ot-operators --set redisOperator.imageName=<custom-url> \
--set redisOperator.imageTag=<customTag>
```
```shell
# For deploying standalone redis
$ helm upgrade redis ot-helm/redis --namespace ot-operators
# For deploying cluster redis
$ helm upgrade redis-cluster ot-helm/redis-cluster \n
--set redisCluster.clusterSize=3 --install --namespace ot-operators \
--set pdb.enabled=false --set redisCluster.tag=v7.0.5-beta
```
## Docker Image Development
Development of redis docker image is maintained inside a different repository - https://github.com/OT-CONTAINER-KIT/redis. To make any change or suggestion related to Redis docker image, please refer to this repository and make required changes.
In the repository, we have `Dockerfile` for [Redis](https://github.com/OT-CONTAINER-KIT/redis/blob/master/Dockerfile) and [Redis Exporter](https://github.com/OT-CONTAINER-KIT/redis/blob/master/Dockerfile.exporter)
For building the docker image for redis and redis exporter, there are simple make commands:
```shell
$ make build-redis
$ make build-redis-exporter
```
Loading

0 comments on commit 167c0d6

Please sign in to comment.