I'm trying to run a cloudquery k8s sync for an on-prem kubernetes cluster and it is failing

Hi, I’m trying to run a cloudquery k8s sync for an on-prem kubernetes cluster and it is failing with below error. kindly I’ve given the source and destination yaml files that we have used for syncing cloudquery

Command used: cloudquery sync source.yml destination.yml --log-console --log-level error --log-format json

source.yml

kind: source
spec:
  name: "k8s"
  path: "cloudquery/k8s"
  version: "v6.1.2"
  registry: cloudquery
  destinations: ["postgresql"]
  tables: ["*"]
  spec:
    kubeconfig_path: "./kubeconfig.yaml"  
    contexts: []  

destnation.yml

kind: destination
spec:
  name: "postgresql"
  path: "cloudquery/postgresql"
  version: "v7.1.2"
  write_mode: "overwrite-delete-stale"
  migrate_mode: "safe"
  spec:
    connection_string: "postgresql://xxxxxxxx"

Cloudquery CLI Version: v5.20.5

Error:

{"level":"error","module":"cli","invocation-id":"xxxxxxxxx","grpc.code":"Internal","grpc.component":"server","grpc.error":"rpc error: code = Internal desc = failed to init plugin: failed to initialize client: failed to build k8s RES config for context \"default\": unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined","grpc.method":"Init","grpc.method_type":"unary","grpc.service":"cloudquery.plugin.v3.Plugin","grpc.start_time":"2025-07-01T19:49:30+05:30","grpc.time_ms":"5.058","message":"finished call","peer.address":"@","protocol":"grpc","time":"2025-07-01T14:19:30Z"}
Error: failed to sync v3 source k8s: failed to init source k8s: rpc error: code = Internal desc = failed to init plugin: failed to initialize client: failed to build k8s RES config for context "default": unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined
{"level":"error","module":"cli","invocation-id":"=xxxxxxxx","error":"failed to sync v3 source k8s: failed to init source k8s: rpc error: code = Internal desc = failed to init plugin: failed to initialize client: failed to build k8s RES config for context \"default\": unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined","time":"2025-07-01T14:19:30Z","message":"exiting with error"}

Any quick help would be appreciated.

Thank you!!!

Hi @Prabhanjali :waving_hand: , based on the error this seems like an authentication issue.
Can you verify you’ve configured access to k8s correctly?
You can verify this by running kubectl config view to see the configuration and kubectl get namespaces to ensure authentication works.

Additionally the CLI and integrations versions you’re using are quite, latest CLI version is 6.21.0, latest k8s version is v7.9.4 and latest Postgres version is v8.8.9

You can read more about k8s authentication in Kubernetes Plugin documentation | CloudQuery and about self hosting CloudQuery in Deployment Overview | CloudQuery

Looking at the plugin’s code and the error you received, there should be an additional log warning Failed to create k8s client, fallback to use the in-cluster config with another error details on the initial connection attempt.
Can you share the full sync logs (please redact any private information)?

Hi, It worked now.

Thanks for the help.

2 Likes