github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/deploy/redis/scripts/redis-proxy-setup.sh (about) 1 #!/bin/sh 2 set -ex 3 {{- $clusterName := $.cluster.metadata.name }} 4 {{- $namespace := $.cluster.metadata.namespace }} 5 {{- /* find redis-proxy component */}} 6 {{- $proxy_component := fromJson "{}" }} 7 {{- $redis_component := fromJson "{}" }} 8 {{- range $i, $e := $.cluster.spec.componentSpecs }} 9 {{- if eq $e.componentDefRef "redis-proxy" }} 10 {{- $proxy_component = $e }} 11 {{- else if eq $e.componentDefRef "redis" }} 12 {{- $redis_component = $e }} 13 {{- end }} 14 {{- end }} 15 {{- /* build proxy config */}} 16 echo "alpha:" > /etc/proxy/nutcracker.conf 17 echo " listen: 127.0.0.1:22121" >> /etc/proxy/nutcracker.conf 18 echo " hash: fnv1a_64" >> /etc/proxy/nutcracker.conf 19 echo " distribution: ketama" >> /etc/proxy/nutcracker.conf 20 echo " auto_eject_hosts: true" >> /etc/proxy/nutcracker.conf 21 echo " redis: true" >> /etc/proxy/nutcracker.conf 22 echo " server_retry_timeout: 2000" >> /etc/proxy/nutcracker.conf 23 echo " server_failure_limit: 1" >> /etc/proxy/nutcracker.conf 24 echo " servers:" >> /etc/proxy/nutcracker.conf 25 echo " - {{ $clusterName }}-{{ $redis_component.name }}.{{ $namespace }}.svc:6379:1 {{ $clusterName }}" >> /etc/proxy/nutcracker.conf