Home > Mobile >  Expose Redis as Openshift route
Expose Redis as Openshift route

Time:12-12

I deployed a Redis standalone in Openshift (CRC) using bitnami helm chart (https://github.com/bitnami/charts/tree/main/bitnami/redis)

I used these parameters:

helm repo add my-repo https://charts.bitnami.com/bitnami

helm upgrade --install redis-ms my-repo/redis \
--set master.podSecurityContext.enabled=false \
--set master.containerSecurityContext.enabled=false \
--set auth.enabled=false \
--set image.debug=true \
--set architecture=standalone

I can see a Redis Master node pod "Ready to accept connections" Then I create a Route to expose redis outside the cluster:

kind: Route
apiVersion: route.openshift.io/v1
metadata:
  name: redis  
spec:
  host: redis-ms.apps-crc.testing
  to:
    kind: Service
    name: redis-ms-master
  port:
    targetPort: tcp-redis
  wildcardPolicy: None

But when I try to connect to "redis-ms.apps-crc.testing:80" I got:

"Unknown reply: H"

While if I use oc port-forward --namespace redis-ms svc/redis-ms-master 6379:6379 and then I connect to "localhost:6379" it works

CodePudding user response:

OpenShift Routes are limited to HTTP(S) traffic, due to how the router sends traffic with SNI.

An Ingress Controller is configured to accept external requests and proxy them based on the configured routes. This is limited to HTTP, HTTPS using SNI, and TLS using SNI, which is sufficient for web applications and services that work over TLS with SNI.

If you need to expose non-HTTP traffic, like a database or Redis instance in your case, you can expose this Service directly as a LoadBalancer type Service. This would look something like below for your Redis Service

apiVersion: v1
kind: Service
metadata:
  name: redis-ms-master
spec:
  ports:
  - name: tcp-redis
    port: 6379 
    targetPort: redis
  type: LoadBalancer 
  selector:
    name: app.kubernetes.io/component: master 

Additionally, it actually looks like that specific helm chart supports setting this as a configuration option, master.service.type.

  • Related