diff --git a/Makefile b/Makefile index 5e9091d..49829ea 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ package := github.com/inditextech/$(name) # Image URL to use for building/pushing image targets when using `pro` deployment profile. IMG ?= redkey-operator:$(VERSION) IMG_WEBHOOK ?= redkey-operator-webhook:$(VERSION) +IMG_ROBIN ?= redkey-robin:$(VERSION) # CN for the webhook certificate CN ?= inditex.dev @@ -376,11 +377,19 @@ delete-operator: ## Delete the operator pod (redkey-operator) in order to have apply-rkcl: ## Apply the sample RedKey Cluster manifest. $(info $(M) creating sample RedKey cluster) - $(KUSTOMIZE) build config/samples | $(SED) 's/namespace: redkey-operator/namespace: ${NAMESPACE}/' | kubectl apply -f - + $(KUSTOMIZE) build config/samples/ephemeral | $(SED) 's/namespace: redkey-operator/namespace: ${NAMESPACE}/' | $(SED) 's,image: redkey-robin:0.1.0,image: ${IMG_ROBIN},' | kubectl apply -f - delete-rkcl: ## Delete the sample RedKey Cluster manifest. $(info $(M) deleting sample RedKey cluster) - $(KUSTOMIZE) build config/samples | $(SED) 's/namespace: redkey-operator/namespace: ${NAMESPACE}/' | kubectl delete -f - + $(KUSTOMIZE) build config/samples/ephemeral | $(SED) 's/namespace: redkey-operator/namespace: ${NAMESPACE}/' | $(SED) 's,image: redkey-robin:0.1.0,image: ${IMG_ROBIN},' | kubectl delete -f - + +apply-debug-rkcl: ## Apply the sample RedKey Cluster manifest for Robin debugging. + $(info $(M) creating sample RedKey cluster) + $(KUSTOMIZE) build config/samples/robin-debug | $(SED) 's/namespace: redkey-operator/namespace: ${NAMESPACE}/' | $(SED) 's,image: redkey-robin:0.1.0,image: ${IMG_DEBUG},' | kubectl apply -f - + +delete-debug-rkcl: ## Delete the sample RedKey Cluster manifest for Robin debugging. + $(info $(M) deleting sample RedKey cluster) + $(KUSTOMIZE) build config/samples/robin-debug | $(SED) 's/namespace: redkey-operator/namespace: ${NAMESPACE}/' | $(SED) 's,image: redkey-robin:0.1.0,image: ${IMG_DEBUG},' | kubectl delete -f - apply-all: docker-build docker-push process-manifests install deploy apply-rkcl diff --git a/config/samples/kustomization.yaml b/config/samples/ephemeral/kustomization.yaml similarity index 100% rename from config/samples/kustomization.yaml rename to config/samples/ephemeral/kustomization.yaml diff --git a/config/samples/ephemeral/redis_v1_redkeycluster-ephemeral.yaml b/config/samples/ephemeral/redis_v1_redkeycluster-ephemeral.yaml new file mode 100644 index 0000000..5e9a093 --- /dev/null +++ b/config/samples/ephemeral/redis_v1_redkeycluster-ephemeral.yaml @@ -0,0 +1,142 @@ +apiVersion: redis.inditex.dev/v1 +kind: RedKeyCluster +metadata: + labels: + app.kubernetes.io/name: redkey-cluster-operator + app.kubernetes.io/managed-by: kustomize + name: redis-cluster-ephemeral +spec: + replicas: 3 + ephemeral: true + accessModes: + - ReadWriteOnce + deletePVC: false + image: redis:8-bookworm + purgeKeysOnRebalance: true + labels: + team: team-a + custom: labels + config: | + maxmemory 90mb + maxmemory-samples 5 + maxmemory-policy allkeys-lru + protected-mode no + appendonly no + save "" + resources: + limits: + cpu: 100m + memory: 128Mi + robin: + config: | + metadata: + namespace: redkey-operator + redis: + standalone: false + reconciler: + interval_seconds: 30 + operation_cleanup_interval_seconds: 30 + cluster: + namespace: redkey-operator + name: redis-cluster-ephemeral + replicas: 3 + replicas_per_master: 0 + status: 'Unknown' + ephemeral: true + health_probe_interval_seconds: 60 + healing_time_seconds: 60 + max_retries: 10 + back_off: 10s + metrics: + interval_seconds: 60 + redis_info_keys: + - keyspace_hits + - evicted_keys + - connected_clients + - total_commands_processed + - keyspace_misses + - expired_keys + - redis_version + - used_memory_rss + - maxmemory + - used_cpu_sys + - used_cpu_sys_children + - used_cpu_user + - used_cpu_user_children + - total_net_input_bytes + - total_net_output_bytes + - aof_base_size + - aof_current_size + - mem_aof_buffer + template: + spec: + containers: + - image: redkey-robin:0.1.0 + name: robin + imagePullPolicy: Always + ports: + - containerPort: 8080 + name: prometheus + protocol: TCP + volumeMounts: + - mountPath: /opt/conf/configmap + name: redis-cluster-ephemeral-robin-config + resources: + requests: + cpu: 500m + memory: 100Mi + limits: + cpu: 1 + memory: 200Mi + volumes: + - configMap: + defaultMode: 420 + name: redis-cluster-ephemeral-robin + name: redis-cluster-ephemeral-robin-config + # override: + # service: + # metadata: + # annotations: + # traffic.inditex.dev/weight: "101" + # labels: + # inditex.dev/test: "test" + # spec: + # ports: + # - name: prometheus + # port: 9090 + # targetPort: 9090 + # protocol: TCP + # selector: + # inditex.dev/test: "test" + # statefulSet: + # metadata: + # annotations: + # traffic.inditex.dev/weight: "10" + # spec: + # template: + # metadata: + # labels: + # inditex.dev/test: "test" + # spec: + # tolerations: + # - key: "test" + # operator: "Equal" + # value: "test" + # effect: "NoSchedule" + # topologySpreadConstraints: + # - maxSkew: 1 + # topologyKey: kubernetes.io/hostname + # whenUnsatisfiable: DoNotSchedule + # labelSelector: + # matchLabels: + # app: foo + # matchLabelKeys: + # - pod-template-hash + # containers: + # - name: nginx + # image: nginx + # - name: redis + # env: + # - name: test + # value: test + # terminationGracePeriodSeconds: 10 diff --git a/config/samples/robin-debug/kustomization.yml b/config/samples/robin-debug/kustomization.yml new file mode 100644 index 0000000..2b28666 --- /dev/null +++ b/config/samples/robin-debug/kustomization.yml @@ -0,0 +1,13 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +patches: +- path: ./robin-patch.yaml + target: + kind: RedKeyCluster + name: redis-cluster-ephemeral + +resources: +- ../ephemeral + +namespace: redkey-operator \ No newline at end of file diff --git a/config/samples/redis_v1_redkeycluster-ephemeral.yaml b/config/samples/robin-debug/redis_v1_redkeycluster-ephemeral.yaml similarity index 100% rename from config/samples/redis_v1_redkeycluster-ephemeral.yaml rename to config/samples/robin-debug/redis_v1_redkeycluster-ephemeral.yaml diff --git a/config/samples/robin-debug/robin-patch.yaml b/config/samples/robin-debug/robin-patch.yaml new file mode 100644 index 0000000..b65bbbf --- /dev/null +++ b/config/samples/robin-debug/robin-patch.yaml @@ -0,0 +1,17 @@ +- op: add + path: /spec/robin/template/spec/containers/0/command + value: + - "sleep" + - "18000" +- op: replace + path: /spec/robin/template/spec/containers/0/imagePullPolicy + value: Always +- op: add + path: /spec/robin/template/spec/containers/0/ports + value: + - containerPort: 8080 + name: prometheus + protocol: TCP + - containerPort: 40000 + name: debug + protocol: TCP \ No newline at end of file diff --git a/debug.Dockerfile b/debug.Dockerfile index 0f390e8..e60d3e9 100644 --- a/debug.Dockerfile +++ b/debug.Dockerfile @@ -6,5 +6,8 @@ FROM golang:1.24.6 RUN go install github.com/go-delve/delve/cmd/dlv@v1.25 +# Install redis-cli by adding the redis package (required to debug Redkey Robin) +RUN apt update -y && apt install -y redis-tools curl procps + WORKDIR / EXPOSE 40000 \ No newline at end of file