-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from controlplane-com/redis-cluster-dns-fix
fixing redis cluster to use dns instead of ip
- Loading branch information
Showing
12 changed files
with
184 additions
and
27 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v2 | ||
name: redis | ||
description: A single replica Redis helm chart for Control Plan | ||
type: application | ||
version: 0.1.0 | ||
appVersion: "1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
## Redis example | ||
|
||
This example creates a Redis cluster with 6 nodes on the Control Plane Platform and can be further customized as needed. | ||
|
||
### Steps to run this example: | ||
|
||
**HELM** | ||
|
||
The [Helm CLI](https://helm.sh/docs/intro/install/#through-package-managers) and [Control Plane CLI](https://docs.controlplane.com/reference/cli#install-npm) must be installed. | ||
|
||
1. Clone this repo and update the [values.yaml](redis-clsuter/values.yaml) file as needed. | ||
|
||
2. Run the command below from this directory. | ||
|
||
```bash | ||
cpln helm install redis-cluster --gvc mygvc | ||
``` | ||
Note: Typically, it takes 5 minutes for all replicas of the workload to become ready and for the cluster to be created. | ||
|
||
### Accessing redis-cluster | ||
|
||
Workloads are allowed to access Redis Cluster based on the `firewallConfig` you specify. You can learn more about in our [documentation](https://docs.controlplane.com/reference/workload#internal). | ||
|
||
Improtant: To access workloads listening on a TCP port, the client workload must be in the same GVC. Thus, the Redis cluster is accessible to clients running within the same GVC. | ||
|
||
#### Option 1: | ||
|
||
Syntax: <WORKLOAD_NAME> | ||
``` | ||
redis-cli -c -h redis-cluster -p 6379 set mykey "test" | ||
redis-cli -c -h redis-cluster -p 6379 get mykey | ||
``` | ||
#### Option 2: (By replica) | ||
|
||
Syntax: <REPLICA_NAME>.<WORKLOAD_NAME> | ||
``` | ||
redis-cli -c -h redis-cluster-0.redis-cluster -p 6379 set mykey "test" | ||
redis-cli -c -h redis-cluster-1.redis-cluster -p 6379 get mykey | ||
redis-cli -c -h redis-cluster-2.redis-cluster -p 6379 get mykey | ||
redis-cli -c -h redis-cluster-3.redis-cluster -p 6379 get mykey | ||
redis-cli -c -h redis-cluster-4.redis-cluster -p 6379 get mykey | ||
redis-cli -c -h redis-cluster-5.redis-cluster -p 6379 get mykey | ||
``` | ||
|
||
### Cleanup | ||
|
||
**HELM** | ||
|
||
```bash | ||
cpln helm uninstall redis-cluster | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{{- if .Values.volumeset }} | ||
kind: volumeset | ||
name: volumeset-{{ .Values.name }} | ||
description: volumeset-{{ .Values.name }} | ||
tags: {} | ||
spec: | ||
fileSystemType: {{ .Values.volumeset.volume.fileSystemType }} | ||
initialCapacity: {{ .Values.volumeset.volume.initialCapacity }} | ||
performanceClass: {{ .Values.volumeset.volume.performanceClass }} | ||
snapshots: | ||
createFinalSnapshot: {{ .Values.volumeset.snapshots.createFinalSnapshot }} | ||
retentionDuration: {{ .Values.volumeset.snapshots.retentionDuration }} | ||
schedule: {{ .Values.volumeset.snapshots.schedule }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
kind: workload | ||
name: {{ .Values.name }} | ||
gvc: {{ .Values.cpln.gvc }} | ||
description: {{ .Values.name }} | ||
spec: | ||
type: stateful | ||
containers: | ||
- name: {{ .Values.name }} | ||
cpu: '{{ .Values.cpu }}' | ||
memory: {{ .Values.memory }} | ||
env: | ||
- name: CUSTOM_REDIS_PORT | ||
value: '{{ .Values.port }}' | ||
image: {{ .Values.image.repository }} | ||
livenessProbe: | ||
exec: | ||
command: | ||
- /bin/bash | ||
- '-c' | ||
- redis-cli ping | ||
failureThreshold: 10 | ||
initialDelaySeconds: 25 | ||
periodSeconds: 5 | ||
successThreshold: 1 | ||
timeoutSeconds: 4 | ||
readinessProbe: | ||
exec: | ||
command: | ||
- /bin/bash | ||
- '-c' | ||
- redis-cli ping | ||
failureThreshold: 10 | ||
initialDelaySeconds: 20 | ||
periodSeconds: 5 | ||
successThreshold: 1 | ||
timeoutSeconds: 4 | ||
inheritEnv: {{ .Values.inheritEnv }} | ||
ports: | ||
- number: {{ .Values.port }} | ||
protocol: tcp | ||
volumes: | ||
{{- if .Values.volumeset }} | ||
- path: /data | ||
recoveryPolicy: retain | ||
uri: 'cpln://volumeset/volumeset-{{ .Values.name }}' | ||
{{- else }} | ||
[] | ||
{{- end }} | ||
defaultOptions: | ||
autoscaling: | ||
maxConcurrency: 0 | ||
maxScale: 1 | ||
metric: disabled | ||
minScale: 1 | ||
scaleToZeroDelay: 300 | ||
target: 100 | ||
capacityAI: {{ .Values.capacityAI}} | ||
debug: false | ||
suspend: false | ||
timeoutSeconds: 5 | ||
{{- if .Values.firewall }} | ||
firewallConfig: | ||
{{- if or (hasKey .Values.firewall "external_inboundAllowCIDR") (hasKey .Values.firewall "external_outboundAllowCIDR") }} | ||
external: | ||
inboundAllowCIDR: {{- if .Values.firewall.external_inboundAllowCIDR }}{{ .Values.firewall.external_inboundAllowCIDR | splitList "," | toYaml | nindent 8 }}{{- else }} []{{- end }} | ||
outboundAllowCIDR: {{- if .Values.firewall.external_outboundAllowCIDR }}{{ .Values.firewall.external_outboundAllowCIDR | splitList "," | toYaml | nindent 8 }}{{- else }} []{{- end }} | ||
{{- end }} | ||
{{- if hasKey .Values.firewall "internal_inboundAllowType" }} | ||
internal: | ||
inboundAllowType: {{ default "[]" .Values.firewall.internal_inboundAllowType }} | ||
{{- end }} | ||
{{- end }} | ||
localOptions: [] | ||
rolloutOptions: | ||
maxSurgeReplicas: 25% | ||
maxUnavailableReplicas: '1' | ||
minReadySeconds: 0 | ||
scalingPolicy: OrderedReady | ||
securityOptions: | ||
filesystemGroupId: 1001 | ||
supportDynamicTags: {{ .Values.supportDynamicTags }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Default values for redis-cluster. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
|
||
image: | ||
repository: docker.io/redis:7.2 | ||
|
||
name: redis-dev-empty | ||
port: 6379 | ||
diskCapacity: 20 # In Gigabytes | ||
memory: 250Mi # EX. 3000Mi = 3Gi | ||
cpu: 200m # vCPU or milicores with; EX. 1.5 = 1500m | ||
inheritEnv: false | ||
capacityAI: false | ||
firewall: | ||
internal_inboundAllowType: "same-org" # Options: same-org / same-gvc(Recommended) | ||
# external_inboundAllowCIDR: 0.0.0.0/0 # Provide a comma-separated list | ||
# external_outboundAllowCIDR: "0.0.0.0/0" # "111.222.333.444/16,111.222.444.333/32" # Provide a comma-separated list | ||
supportDynamicTags: false | ||
timeoutSeconds: 30 | ||
volumeset: {} | ||
# volume: | ||
# initialCapacity: 25 # In Gigabytes. For high-throughput-ssd minimum is '1000' | ||
# fileSystemType: ext4 # ext4 / xfs | ||
# performanceClass: general-purpose-ssd # high-throughput-ssd / general-purpose-ssd | ||
# snapshots: | ||
# createFinalSnapshot: 'true' | ||
# retentionDuration: 7d | ||
# schedule: '0 1 * * *' |