Redislabs-Solution-Architects / Redis-Enterprise-on-GKE-Anthos

Learn about the serverless experience for your enterprise applications with Cloud Run for Anthos
Apache License 2.0
1 stars 3 forks source link

Obtain the database port in a dynamic fashion. #2

Open TobyHFerguson opened 3 years ago

TobyHFerguson commented 3 years ago

At the moment the redis database's port is edited into the services.yaml file using a sed script and some kubectl get stuff.

What I want to do is to simply reference the dynamically created port number.

See here for ideas

TobyHFerguson commented 3 years ago

This moodle reference shows how to obtain the port from the database secret:

image

TobyHFerguson commented 3 years ago

I need more than the port, I need the hostname. This article showed me how I can use the $() construct to concatenate strings. I think the following might work:

          - name: REDIS_PORT
            valueFrom:
              secretKeyRef:
                name: redis-enterprise-database
                key: port
          - name: REDIS_HOST
            valueFrom:
              secretKeyRef:
                name: redis-enterprise-database
                key: service_name              
          - name: REDIS_ADDR
            value: "$(REDIS_HOST):$(REDIS_PORT)"