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/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}" \ 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 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/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 99% rename from deploy/crds/redis_v1beta1_rediscluster_crd.yaml rename to deploy/common/redis_v1beta1_rediscluster_crd.yaml index 15bd4d0..cca602e 100644 --- a/deploy/crds/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 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/cluster/redis_v1beta1_rediscluster_cr.yaml b/deploy/example/redis_v1beta1_rediscluster_cr.yaml similarity index 95% rename from deploy/cluster/redis_v1beta1_rediscluster_cr.yaml rename to deploy/example/redis_v1beta1_rediscluster_cr.yaml index a9d9294..873bb9e 100644 --- a/deploy/cluster/redis_v1beta1_rediscluster_cr.yaml +++ b/deploy/example/redis_v1beta1_rediscluster_cr.yaml @@ -7,4 +7,4 @@ metadata: name: test spec: # Add fields here - size: 3 + size: 3 \ No newline at end of file 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 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