Skip to content

Commit

Permalink
Merge branch 'master' into mm-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
drivebyer authored Dec 16, 2024
2 parents d342f6e + cda99a4 commit ad4a3c6
Show file tree
Hide file tree
Showing 75 changed files with 1,404 additions and 1,071 deletions.
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: daily
interval: monthly
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
interval: monthly
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ permissions:
contents: read

env:
GOLANG_VERSION: 1.21
GOLANG_VERSION: 1.23.4
APPLICATION_NAME: redis-operator
DockerImagName: docker.io/opstree/redis-operator
BuildDocs: true
Expand All @@ -32,7 +32,7 @@ jobs:
- name: Run GolangCI-Lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.54.0
version: v1.62.2

gotest:
needs:
Expand All @@ -50,7 +50,7 @@ jobs:
- name: Run Go Tests with coverage
run: go test ./... -coverprofile=coverage.txt -covermode=atomic
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
file: ./coverage.txt
fail_ci_if_error: false
Expand Down Expand Up @@ -216,7 +216,7 @@ jobs:
- name: Install Cosign
uses: sigstore/[email protected]
- name: Install chainsaw
uses: kyverno/[email protected].11
uses: kyverno/[email protected].12
with:
verify: true
- name: Check install
Expand Down
4 changes: 1 addition & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ linters:
- gofmt
- gofumpt
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
Expand All @@ -39,15 +38,14 @@ linters:
- tenv
- thelper
- tparallel
- typecheck
- unconvert
- unused
- wastedassign
- whitespace

run:
timeout: 15m
go: "1.21"
go: "1.23.4"
tests: true
show-stats: true
skip-files:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.21 AS builder
FROM golang:1.23-alpine as builder
ARG BUILDOS
ARG BUILDPLATFORM
ARG BUILDARCH
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [2020] [Opstree Solutions]
Copyright [2024] [Opstree Solutions]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ GOBIN=$(shell go env GOBIN)
endif

CONTAINER_ENGINE ?= docker
PLATFORMS="linux/arm64,linux/amd64"

all: manager

Expand Down Expand Up @@ -78,15 +79,15 @@ generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

docker-create:
${CONTAINER_ENGINE} buildx create --platform "linux/amd64,linux/arm64" --use
${CONTAINER_ENGINE} buildx create --platform $(PLATFORMS) --use

# Build the docker image
docker-build:
${CONTAINER_ENGINE} buildx build --platform="linux/arm64,linux/amd64" -t ${IMG} .
${CONTAINER_ENGINE} buildx build --platform=$(PLATFORMS) -t ${IMG} .

# Push the docker image
docker-push:
${CONTAINER_ENGINE} buildx build --push --platform="linux/arm64,linux/amd64" -t ${IMG} .
${CONTAINER_ENGINE} buildx build --push --platform="$(PLATFORMS)" -t ${IMG} .


# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
Expand Down Expand Up @@ -114,7 +115,7 @@ bundle: manifests kustomize
# Build the bundle image.
.PHONY: bundle-build
bundle-build:
${CONTAINER_ENGINE} buildx build --platform="linux/arm64,linux/amd64" -f bundle.Dockerfile -t $(BUNDLE_IMG) .
${CONTAINER_ENGINE} buildx build --platform="$(PLATFORMS)" -f bundle.Dockerfile -t $(BUNDLE_IMG) .

# Generate bundle manifests and metadata, then validate generated files.
.PHONY: codegen
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

A Golang based redis operator that will make/oversee Redis standalone and cluster mode setup on top of the Kubernetes. It can create a redis cluster setup with best practices on Cloud as well as the Bare metal environment. Also, it provides an in-built monitoring capability using redis-exporter.

For documentation, please refer to https://ot-redis-operator.netlify.app/
For documentation, please refer to <https://ot-redis-operator.netlify.app/>

Organizations that are using Redis Operator to manage their redis workload can be found [here](./USED_BY_ORGANIZATIONS.md). If your organization is also using Redis Operator, please free to add by creating a [pull request](https://github.com/OT-CONTAINER-KIT/redis-operator/pulls)

Expand Down Expand Up @@ -68,11 +68,15 @@ Redis operator requires a Kubernetes cluster of version `>=1.18.0`. If you have
The following table shows the compatibility between the Operator Version, Redis Image, Sentinel Image, and Exporter Image:

| Operator Version | Redis Image | Sentinel Image | Exporter Image |
|------------------|-------------|----------------|----------------|
| v0.15.0 | v7.0.12 | v7.0.12 | v1.48.0 |
| v0.15.0 | v7.0.11 | v7.0.11 | v1.48.0 |
| v0.14.0 | v7.0.7 | v7.0.7 | v1.48.0 |
| v0.13.0 | v6.2.5 | nil | v1.48.0 |
| ---------------- | ----------- | -------------- | -------------- |
| v0.18.1 | v7.0.12 | v7.0.12 | v1.44.0 |
| v0.18.0 | v7.0.12 | v7.0.12 | v1.44.0 |
| v0.17.0 | v7.0.12 | v7.0.12 | v1.44.0 |
| v0.16.0 | v7.0.12 | v7.0.12 | v1.44.0 |
| v0.15.1 | v7.0.12 | v7.0.12 | v1.44.0 |
| v0.15.0 | v7.0.11 | v7.0.11 | v1.44.0 |
| v0.14.0 | v7.0.7 | v7.0.7 | v1.44.0 |
| v0.13.0 | v6.2.5 | nil | v1.44.0 |

## Quickstart

Expand Down Expand Up @@ -102,7 +106,7 @@ Creating redis cluster, standalone, replication and sentinel setup.
```shell
# Create redis cluster setup
$ helm upgrade redis-cluster ot-helm/redis-cluster \
--set redisCluster.clusterSize=3 --install \
--set redisCluster.clusterSize=3 --install \
--namespace ot-operators
```

Expand Down
14 changes: 14 additions & 0 deletions api/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ type KubernetesConfig struct {
MinReadySeconds *int32 `json:"minReadySeconds,omitempty"`
}

func (in *KubernetesConfig) GetServiceType() string {
if in.Service == nil {
return "ClusterIP"
}
return in.Service.ServiceType
}

func (in *KubernetesConfig) GetServiceAnnotations() map[string]string {
if in.Service == nil {
return nil
}
return in.Service.ServiceAnnotations
}

// ServiceConfig define the type of service to be created and its annotations
// +k8s:deepcopy-gen=true
type ServiceConfig struct {
Expand Down
44 changes: 24 additions & 20 deletions api/v1beta2/redisreplication_types.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
package v1beta2

import (
common "github.com/OT-CONTAINER-KIT/redis-operator/api"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type RedisReplicationSpec struct {
Size *int32 `json:"clusterSize"`
KubernetesConfig KubernetesConfig `json:"kubernetesConfig"`
RedisExporter *RedisExporter `json:"redisExporter,omitempty"`
RedisConfig *RedisConfig `json:"redisConfig,omitempty"`
Storage *Storage `json:"storage,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`
SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"`
PriorityClassName string `json:"priorityClassName,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
Tolerations *[]corev1.Toleration `json:"tolerations,omitempty"`
TLS *TLSConfig `json:"TLS,omitempty"`
ACL *ACLConfig `json:"acl,omitempty"`
ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty" protobuf:"bytes,11,opt,name=readinessProbe"`
LivenessProbe *corev1.Probe `json:"livenessProbe,omitempty" protobuf:"bytes,12,opt,name=livenessProbe"`
InitContainer *InitContainer `json:"initContainer,omitempty"`
Sidecars *[]Sidecar `json:"sidecars,omitempty"`
ServiceAccountName *string `json:"serviceAccountName,omitempty"`
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty" protobuf:"varint,4,opt,name=terminationGracePeriodSeconds"`
EnvVars *[]corev1.EnvVar `json:"env,omitempty"`
Size *int32 `json:"clusterSize"`
KubernetesConfig KubernetesConfig `json:"kubernetesConfig"`
RedisExporter *RedisExporter `json:"redisExporter,omitempty"`
RedisConfig *RedisConfig `json:"redisConfig,omitempty"`
Storage *Storage `json:"storage,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`
SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"`
PriorityClassName string `json:"priorityClassName,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
Tolerations *[]corev1.Toleration `json:"tolerations,omitempty"`
TLS *TLSConfig `json:"TLS,omitempty"`
PodDisruptionBudget *common.RedisPodDisruptionBudget `json:"pdb,omitempty"`
ACL *ACLConfig `json:"acl,omitempty"`
ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty" protobuf:"bytes,11,opt,name=readinessProbe"`
LivenessProbe *corev1.Probe `json:"livenessProbe,omitempty" protobuf:"bytes,12,opt,name=livenessProbe"`
InitContainer *InitContainer `json:"initContainer,omitempty"`
Sidecars *[]Sidecar `json:"sidecars,omitempty"`
ServiceAccountName *string `json:"serviceAccountName,omitempty"`
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty" protobuf:"varint,4,opt,name=terminationGracePeriodSeconds"`
EnvVars *[]corev1.EnvVar `json:"env,omitempty"`
}

func (cr *RedisReplicationSpec) GetReplicationCounts(t string) int32 {
Expand All @@ -41,6 +43,8 @@ type RedisReplicationStatus struct {
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +kubebuilder:printcolumn:name="Master",type="string",JSONPath=".status.masterNode"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

// Redis is the Schema for the redis API
type RedisReplication struct {
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions charts/redis-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v2
name: redis-cluster
description: Provides easy redis setup definitions for Kubernetes services, and deployment.
version: 0.16.1
appVersion: "0.16.1"
version: 0.16.4
appVersion: "0.16.4"
home: https://github.com/ot-container-kit/redis-operator
sources:
- https://github.com/ot-container-kit/redis-operator
Expand Down
1 change: 1 addition & 0 deletions charts/redis-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ helm delete <my-release> --namespace <namespace>
| redisCluster.minReadySeconds | int | `0` | |
| redisCluster.name | string | `""` | |
| redisCluster.persistenceEnabled | bool | `true` | |
| redisCluster.recreateStatefulSetOnUpdateInvalid | bool | `false` | Some fields of statefulset are immutable, such as volumeClaimTemplates. When set to true, the operator will delete the statefulset and recreate it. Default is false. |
| redisCluster.redisSecret.secretKey | string | `""` | |
| redisCluster.redisSecret.secretName | string | `""` | |
| redisCluster.resources | object | `{}` | |
Expand Down
1 change: 1 addition & 0 deletions charts/redis-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ env:
{{- define "initContainer.properties" -}}
{{- with .Values.initContainer }}
{{- if .enabled }}
enabled: {{ .enabled }}
image: {{ .image }}
{{- if .imagePullPolicy }}
imagePullPolicy: {{ .imagePullPolicy }}
Expand Down
9 changes: 6 additions & 3 deletions charts/redis-cluster/templates/redis-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ kind: RedisCluster
metadata:
name: {{ .Values.redisCluster.name | default .Release.Name }}
labels: {{- include "common.labels" . | nindent 4 }}
annotations:
{{ if .Values.redisCluster.recreateStatefulSetOnUpdateInvalid }}
redis.opstreelabs.in/recreate-statefulset: "true"
{{ end }}
spec:
clusterSize: {{ .Values.redisCluster.clusterSize }}
persistenceEnabled: {{ .Values.redisCluster.persistenceEnabled }}
clusterVersion: {{ .Values.redisCluster.clusterVersion }}

redisLeader: {{- include "redis.role" .Values.redisCluster.leader | nindent 4 }}
replicas: {{ .Values.redisCluster.leader.replicas }}
{{- if .Values.externalConfig.enabled }}
Expand Down Expand Up @@ -75,10 +78,10 @@ spec:
secretName: {{ .Values.acl.secret.secretName | quote }}
{{- end }}
{{- if and .Values.sidecars (ne .Values.sidecars.name "") (ne .Values.sidecars.image "") }}
sidecars: {{ include "sidecar.properties" | nindent 4 }}
sidecars: {{ include "sidecar.properties" . | nindent 4 }}
{{- end }}
{{- if and .Values.initContainer .Values.initContainer.enabled (ne .Values.initContainer.image "") }}
initContainer: {{ include "initContainer.properties" | nindent 4 }}
initContainer: {{ include "initContainer.properties" . | nindent 4 }}
{{- end }}
{{- if .Values.env }}
env: {{ toYaml .Values.env | nindent 4 }}
Expand Down
3 changes: 3 additions & 0 deletions charts/redis-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ redisCluster:
# cpu: 100m
# memory: 128Mi
minReadySeconds: 0
# -- Some fields of statefulset are immutable, such as volumeClaimTemplates.
# When set to true, the operator will delete the statefulset and recreate it. Default is false.
recreateStatefulSetOnUpdateInvalid: false
leader:
replicas: 3
serviceType: ClusterIP
Expand Down
4 changes: 2 additions & 2 deletions charts/redis-replication/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v2
name: redis-replication
description: Provides easy redis setup definitions for Kubernetes services, and deployment.
version: 0.16.3
appVersion: "0.16.3"
version: 0.16.6
appVersion: "0.16.6"
type: application
engine: gotpl
maintainers:
Expand Down
1 change: 1 addition & 0 deletions charts/redis-replication/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ helm delete <my-release> --namespace <namespace>
| redisReplication.imagePullSecrets | list | `[]` | |
| redisReplication.minReadySeconds | int | `0` | |
| redisReplication.name | string | `""` | |
| redisReplication.recreateStatefulSetOnUpdateInvalid | bool | `false` | Some fields of statefulset are immutable, such as volumeClaimTemplates. When set to true, the operator will delete the statefulset and recreate it. Default is false. |
| redisReplication.redisSecret.secretKey | string | `""` | |
| redisReplication.redisSecret.secretName | string | `""` | |
| redisReplication.resources | object | `{}` | |
Expand Down
1 change: 1 addition & 0 deletions charts/redis-replication/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ app.kubernetes.io/component: middleware
{{- define "initContainer.properties" -}}
{{- with .Values.initContainer }}
{{- if .enabled }}
enabled: {{ .enabled }}
image: {{ .image }}
{{- if .imagePullPolicy }}
imagePullPolicy: {{ .imagePullPolicy }}
Expand Down
8 changes: 6 additions & 2 deletions charts/redis-replication/templates/redis-replication.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ kind: RedisReplication
metadata:
name: {{ .Values.redisReplication.name | default .Release.Name }}
labels: {{- include "common.labels" . | nindent 4 }}
annotations:
{{ if .Values.redisReplication.recreateStatefulSetOnUpdateInvalid }}
redis.opstreelabs.in/recreate-statefulset: "true"
{{ end }}
spec:
clusterSize: {{ .Values.redisReplication.clusterSize }}
kubernetesConfig:
Expand Down Expand Up @@ -77,10 +81,10 @@ spec:
secretName: {{ .Values.acl.secret.secretName | quote }}
{{- end }}
{{- if and .Values.initContainer .Values.initContainer.enabled (ne .Values.initContainer.image "") }}
initContainer: {{ include "initContainer.properties" | nindent 4 }}
initContainer: {{ include "initContainer.properties" . | nindent 4 }}
{{- end }}
{{- if and .Values.sidecars (ne .Values.sidecars.name "") (ne .Values.sidecars.image "") }}
sidecars: {{ include "sidecar.properties" | nindent 4 }}
sidecars: {{ include "sidecar.properties" . | nindent 4 }}
{{- end }}
{{- if and .Values.serviceAccountName (ne .Values.serviceAccountName "") }}
serviceAccountName: "{{ .Values.serviceAccountName }}"
Expand Down
5 changes: 4 additions & 1 deletion charts/redis-replication/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ redisReplication:
ignoreAnnotations: []
# - "redis.opstreelabs.in/ignore"
minReadySeconds: 0

# -- Some fields of statefulset are immutable, such as volumeClaimTemplates.
# When set to true, the operator will delete the statefulset and recreate it. Default is false.
recreateStatefulSetOnUpdateInvalid: false

# Overwite name for resources
# name: ""

Expand Down
Loading

0 comments on commit ad4a3c6

Please sign in to comment.