From 6bf918964a0c7c042e6525367b38e1a32842910a Mon Sep 17 00:00:00 2001 From: Cameron Braid Date: Fri, 3 Apr 2020 22:44:51 +1100 Subject: [PATCH 1/6] added kustomization support --- deploy/cluster/kustomization.yaml | 7 +++++++ deploy/cluster/operator.yaml | 2 +- deploy/cluster/redis_v1beta1_rediscluster_cr.yaml | 10 ---------- deploy/common/kustomization.yaml | 5 +++++ .../redis_v1beta1_rediscluster_crd.yaml | 0 deploy/{ => common}/service_account.yaml | 0 deploy/namespace/kustomization.yaml | 7 +++++++ deploy/namespace/operator.yaml | 2 +- deploy/namespace/redis_v1beta1_rediscluster_cr.yaml | 7 ------- 9 files changed, 21 insertions(+), 19 deletions(-) create mode 100644 deploy/cluster/kustomization.yaml delete mode 100644 deploy/cluster/redis_v1beta1_rediscluster_cr.yaml create mode 100644 deploy/common/kustomization.yaml rename deploy/{crds => common}/redis_v1beta1_rediscluster_crd.yaml (100%) rename deploy/{ => common}/service_account.yaml (100%) create mode 100644 deploy/namespace/kustomization.yaml delete mode 100644 deploy/namespace/redis_v1beta1_rediscluster_cr.yaml diff --git a/deploy/cluster/kustomization.yaml b/deploy/cluster/kustomization.yaml new file mode 100644 index 0000000..94019fa --- /dev/null +++ b/deploy/cluster/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- ../common/ +- cluster_role.yaml +- cluster_role_binding.yaml +- operator.yaml diff --git a/deploy/cluster/operator.yaml b/deploy/cluster/operator.yaml index de97c8f..385d9ff 100644 --- a/deploy/cluster/operator.yaml +++ b/deploy/cluster/operator.yaml @@ -16,7 +16,7 @@ spec: containers: - name: redis-operator # Replace this with the built image name - image: REPLACE_IMAGE + image: redis-operator command: - redis-operator imagePullPolicy: Always diff --git a/deploy/cluster/redis_v1beta1_rediscluster_cr.yaml b/deploy/cluster/redis_v1beta1_rediscluster_cr.yaml deleted file mode 100644 index a9d9294..0000000 --- a/deploy/cluster/redis_v1beta1_rediscluster_cr.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: redis.kun/v1beta1 -kind: RedisCluster -metadata: - annotations: - # if your operator run as cluster-scoped, add this annotations - redis.kun/scope: cluster-scoped - name: test -spec: - # Add fields here - size: 3 diff --git a/deploy/common/kustomization.yaml b/deploy/common/kustomization.yaml new file mode 100644 index 0000000..e2bd2a1 --- /dev/null +++ b/deploy/common/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- redis_v1beta1_rediscluster_crd.yaml +- service_account.yaml \ No newline at end of file diff --git a/deploy/crds/redis_v1beta1_rediscluster_crd.yaml b/deploy/common/redis_v1beta1_rediscluster_crd.yaml similarity index 100% rename from deploy/crds/redis_v1beta1_rediscluster_crd.yaml rename to deploy/common/redis_v1beta1_rediscluster_crd.yaml diff --git a/deploy/service_account.yaml b/deploy/common/service_account.yaml similarity index 100% rename from deploy/service_account.yaml rename to deploy/common/service_account.yaml diff --git a/deploy/namespace/kustomization.yaml b/deploy/namespace/kustomization.yaml new file mode 100644 index 0000000..8a3a081 --- /dev/null +++ b/deploy/namespace/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- ../common/ +- operator.yaml +- role.yaml +- role_binding.yaml diff --git a/deploy/namespace/operator.yaml b/deploy/namespace/operator.yaml index 64c3438..a98f2f6 100644 --- a/deploy/namespace/operator.yaml +++ b/deploy/namespace/operator.yaml @@ -16,7 +16,7 @@ spec: containers: - name: redis-operator # Replace this with the built image name - image: REPLACE_IMAGE + image: redis-operator command: - redis-operator imagePullPolicy: Always diff --git a/deploy/namespace/redis_v1beta1_rediscluster_cr.yaml b/deploy/namespace/redis_v1beta1_rediscluster_cr.yaml deleted file mode 100644 index a00da54..0000000 --- a/deploy/namespace/redis_v1beta1_rediscluster_cr.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: redis.kun/v1beta1 -kind: RedisCluster -metadata: - name: test -spec: - # Add fields here - size: 3 From e639cb21dc2479fcc0a077797aeea5bc536d937f Mon Sep 17 00:00:00 2001 From: Cameron Braid Date: Fri, 3 Apr 2020 22:48:35 +1100 Subject: [PATCH 2/6] added example back --- deploy/example/redis_v1beta1_rediscluster_cr.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 deploy/example/redis_v1beta1_rediscluster_cr.yaml diff --git a/deploy/example/redis_v1beta1_rediscluster_cr.yaml b/deploy/example/redis_v1beta1_rediscluster_cr.yaml new file mode 100644 index 0000000..873bb9e --- /dev/null +++ b/deploy/example/redis_v1beta1_rediscluster_cr.yaml @@ -0,0 +1,10 @@ +apiVersion: redis.kun/v1beta1 +kind: RedisCluster +metadata: + annotations: + # if your operator run as cluster-scoped, add this annotations + redis.kun/scope: cluster-scoped + name: test +spec: + # Add fields here + size: 3 \ No newline at end of file From e0d56b2813f3dbb4f8192cb63be6bc1d3a0169d2 Mon Sep 17 00:00:00 2001 From: Cameron Braid Date: Sun, 5 Apr 2020 23:39:56 +1000 Subject: [PATCH 3/6] fix Dockerfile COPY commands the COPY args are source... dest, so "COPY go.mod ./ go.sum ./" coppies ./ to ./ which is unintended as for "COPY pkg ./ cmd ./ version ./" the pkg and cmd args are redundant --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 31f75d3..d96834f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,10 +13,10 @@ ARG GIT_SHA=0000000 WORKDIR /src -COPY go.mod ./ go.sum ./ +COPY go.mod go.sum ./ RUN GOPROXY=https://goproxy.cn,direct go mod download -COPY pkg ./ cmd ./ version ./ +COPY ./ ./ RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ${GOBIN}/${PROJECT_NAME} \ -ldflags "-X ${REPO_PATH}/pkg/version.Version=${VERSION} -X ${REPO_PATH}/pkg/version.GitSHA=${GIT_SHA}" \ From 0ddaee755f11000f37fea99fb3e79a2a3d1ddafe Mon Sep 17 00:00:00 2001 From: Cameron Braid Date: Sun, 5 Apr 2020 23:41:15 +1000 Subject: [PATCH 4/6] set replica-announce-ip on pods so that operator works with istio service mesh wihtout this the redis IP is identified as 127.0.0.1 --- pkg/client/redis/client.go | 4 ++++ pkg/controller/service/check.go | 4 ++++ pkg/controller/service/heal.go | 6 +++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/client/redis/client.go b/pkg/client/redis/client.go index ee5882d..246f922 100644 --- a/pkg/client/redis/client.go +++ b/pkg/client/redis/client.go @@ -272,6 +272,10 @@ func (c *client) SetCustomRedisConfig(ip string, configs map[string]string, auth rClient := rediscli.NewClient(options) defer rClient.Close() + if err := c.applyRedisConfig("replica-announce-ip", ip, rClient); err != nil { + return err + } + for param, value := range configs { //param, value, err := c.getConfigParameters(config) //if err != nil { diff --git a/pkg/controller/service/check.go b/pkg/controller/service/check.go index e4d1554..5288eb2 100644 --- a/pkg/controller/service/check.go +++ b/pkg/controller/service/check.go @@ -62,6 +62,10 @@ func (r *RedisClusterChecker) CheckRedisConfig(redisCluster *redisv1beta1.RedisC return err } + if _, ok := configs["replica-announce-ip"]; !ok { + return fmt.Errorf("configs conflict, expect: replica-announce-ip to be set") + } + // TODO when custom config use unit like mb gb, will return configs conflict for key, value := range redisCluster.Spec.Config { if value != configs[key] { diff --git a/pkg/controller/service/heal.go b/pkg/controller/service/heal.go index 78d4a51..c3b6270 100644 --- a/pkg/controller/service/heal.go +++ b/pkg/controller/service/heal.go @@ -124,9 +124,9 @@ func (r *RedisClusterHealer) SetSentinelCustomConfig(ip string, rc *redisv1beta1 // SetRedisCustomConfig will call redis to set the configuration given in config func (r *RedisClusterHealer) SetRedisCustomConfig(ip string, rc *redisv1beta1.RedisCluster, auth *util.AuthConfig) error { - if len(rc.Spec.Config) == 0 && len(auth.Password) == 0 { - return nil - } + // if len(rc.Spec.Config) == 0 && len(auth.Password) == 0 { + // return nil + // } //if len(auth.Password) != 0 { // rc.Spec.Config["requirepass"] = auth.Password From 5fbaa401118ef046b87ad1dc2b0a7c53fb60e507 Mon Sep 17 00:00:00 2001 From: Cameron Braid Date: Thu, 22 Dec 2022 20:41:41 +1100 Subject: [PATCH 5/6] change from apiextensions.k8s.io/v1beta1 to apiextensions.k8s.io/v1 --- deploy/common/redis_v1beta1_rediscluster_crd.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/common/redis_v1beta1_rediscluster_crd.yaml b/deploy/common/redis_v1beta1_rediscluster_crd.yaml index 15bd4d0..cca602e 100644 --- a/deploy/common/redis_v1beta1_rediscluster_crd.yaml +++ b/deploy/common/redis_v1beta1_rediscluster_crd.yaml @@ -1,4 +1,4 @@ -apiVersion: apiextensions.k8s.io/v1beta1 +apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: redisclusters.redis.kun From 654fa2d88404ce7246c8dfa799af35f850dad2cd Mon Sep 17 00:00:00 2001 From: octane Date: Tue, 27 Dec 2022 14:32:51 +1100 Subject: [PATCH 6/6] feat: jx3 --- .lighthouse/jenkins-x/pullrequest.yaml | 28 ++++++++++++++++++++++++++ .lighthouse/jenkins-x/release.yaml | 27 +++++++++++++++++++++++++ .lighthouse/jenkins-x/triggers.yaml | 16 +++++++++++++++ OWNERS | 4 ++++ OWNERS_ALIASES | 6 ++++++ 5 files changed, 81 insertions(+) create mode 100644 .lighthouse/jenkins-x/pullrequest.yaml create mode 100644 .lighthouse/jenkins-x/release.yaml create mode 100644 .lighthouse/jenkins-x/triggers.yaml create mode 100644 OWNERS create mode 100644 OWNERS_ALIASES diff --git a/.lighthouse/jenkins-x/pullrequest.yaml b/.lighthouse/jenkins-x/pullrequest.yaml new file mode 100644 index 0000000..cd9d735 --- /dev/null +++ b/.lighthouse/jenkins-x/pullrequest.yaml @@ -0,0 +1,28 @@ +apiVersion: tekton.dev/v1beta1 +kind: PipelineRun +metadata: + name: pullrequest +spec: + pipelineSpec: + tasks: + - name: from-build-pack + resources: {} + taskSpec: + metadata: {} + stepTemplate: + workingDir: /workspace/source + env: + - name: "NEXUS_AUTH" + valueFrom: + secretKeyRef: + name: drivenow-maven-settings + key: NEXUS_AUTH + - name: "KANIKO_ARGS" + value: "--build-arg=NEXUS_AUTH" + + steps: + - image: uses:lighthouse:drivenow/jx3-pipelines/docker-helm-promote-pr/pullrequest.yaml@master + podTemplate: {} + serviceAccountName: tekton-bot + timeout: 240h0m0s +status: {} diff --git a/.lighthouse/jenkins-x/release.yaml b/.lighthouse/jenkins-x/release.yaml new file mode 100644 index 0000000..811c7da --- /dev/null +++ b/.lighthouse/jenkins-x/release.yaml @@ -0,0 +1,27 @@ +apiVersion: tekton.dev/v1beta1 +kind: PipelineRun +metadata: + name: release +spec: + pipelineSpec: + tasks: + - name: from-build-pack + resources: {} + taskSpec: + metadata: {} + stepTemplate: + workingDir: /workspace/source + env: + - name: "NEXUS_AUTH" + valueFrom: + secretKeyRef: + name: drivenow-maven-settings + key: NEXUS_AUTH + - name: "KANIKO_ARGS" + value: "--build-arg=NEXUS_AUTH" + steps: + - image: uses:lighthouse:drivenow/jx3-pipelines/docker-helm-promote-pr/release.yaml@master + podTemplate: {} + serviceAccountName: tekton-bot + timeout: 240h0m0s +status: {} diff --git a/.lighthouse/jenkins-x/triggers.yaml b/.lighthouse/jenkins-x/triggers.yaml new file mode 100644 index 0000000..3c02be7 --- /dev/null +++ b/.lighthouse/jenkins-x/triggers.yaml @@ -0,0 +1,16 @@ +apiVersion: config.lighthouse.jenkins-x.io/v1alpha1 +kind: TriggerConfig +spec: + presubmits: + - name: pr + context: "pr" + always_run: true + optional: false + source: pullrequest.yaml + postsubmits: + - name: release + context: "release" + source: release.yaml + branches: + - ^main$ + - ^master$ \ No newline at end of file diff --git a/OWNERS b/OWNERS new file mode 100644 index 0000000..1de074f --- /dev/null +++ b/OWNERS @@ -0,0 +1,4 @@ +approvers: +- cameronbraid +reviewers: +- cameronbraid diff --git a/OWNERS_ALIASES b/OWNERS_ALIASES new file mode 100644 index 0000000..d8f5d48 --- /dev/null +++ b/OWNERS_ALIASES @@ -0,0 +1,6 @@ +aliases: +- cameronbraid +best-approvers: +- cameronbraid +best-reviewers: +- cameronbraid