Search code examples
kubernetesgoogle-cloud-platforminfluxdb

How to locally access influx db deployed on GCP kubernetes


Influxdb 1.8 is deployed on kubernets using helm charts. influx db is deployed as Stateful Set that exposes a service with one running pods. Am able to ssh into running pods using kubectl exec command and its running fine. I can also see databases using influx cli after logging into pods

But i need to access this influx db on my local system to execute queries directly from my system using curl command. Deployed influxdb has no external IP/DNS. It ha internal endpoint that usually starts with 10...*

Can anybody guide me on how can i access influxdb on my local system using curl command?


Solution

  • You can use the kubectl port-forward command. You can use it to either map a Pod or a Service TCP port to a port on your local machine:

    > kubectl port-forward service/your-influxdb-service 8086:8086
                                                          ^    ^
                                                          |    |
                                                 local port    remote/service port
    

    While that command is running, kubectl will forward all connections to your local port 8086 to the same port of your InfluxDB service. All traffic will be funneled through kubectl and your API server, so this is not exactly suited for high-throughput scenarios, but should be sufficient for occasional debugging and testing.