question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Having trouble running example

See original GitHub issue

I get 403 Forbidden when running Example.java. I tried setting KUBECONFIG to the absolute path of my ~/.kube/config file. I’m able to run kubectl get pods --all-namespaces. Is there something I’m missing?

null for gcp
Exception in thread "main" io.kubernetes.client.ApiException: Forbidden
	at io.kubernetes.client.ApiClient.handleResponse(ApiClient.java:882)
	at io.kubernetes.client.ApiClient.execute(ApiClient.java:798)
	at io.kubernetes.client.apis.CoreV1Api.listPodForAllNamespacesWithHttpInfo(CoreV1Api.java:18462)
	at io.kubernetes.client.apis.CoreV1Api.listPodForAllNamespaces(CoreV1Api.java:18440)
	at io.kubernetes.client.examples.Example.main(Example.java:40)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
neuromantik33commented, Jan 9, 2018

Ok I figured it out 😃 So I noticed that my kubectl uses basic auth to connect to the cluster

$ kubectl get ns -v=7
I0109 18:22:33.143878   27156 loader.go:357] Config loaded from file /home/nestrada/.kube/config
...
I0109 18:22:33.153456   27156 round_trippers.go:414] GET https://35.189.xxx.xxx/api/v1/namespaces
I0109 18:22:33.153463   27156 round_trippers.go:421] Request Headers:
I0109 18:22:33.156114   27156 round_trippers.go:424]     Accept: application/json
I0109 18:22:33.156167   27156 round_trippers.go:424]     User-Agent: kubectl/v1.8.4 (linux/amd64) kubernetes/9befc2b
I0109 18:22:33.156212   27156 round_trippers.go:424]     Authorization: Basic REDACTED
I0109 18:22:33.202874   27156 round_trippers.go:439] Response Status: 200 OK in 46 milliseconds
NAME          STATUS    AGE
default       Active    67d

Yet after digging around in the master branch It seems to have been corrected but not in the 1.0.0-beta1 release. However the correction is not complete. Since my defaultConfig uses basic auth over https, it has a username, password and client certificate but no access token. My workaround was to create one without the factory method.

def username, password, endpoint // Defined elsewhere
def auth = "${username}:${password}".getBytes('ISO-8859-1')
def client = new ApiClient().with {
    basePath = "https://$endpoint"
    verifyingSsl = true
    sslCaCert = getClass().getResourceAsStream('/cluster.cert')
    apiKeyPrefix = 'Basic'
    apiKey = encoder.encodeToString(auth)
    it
}

And it works 😃

A more deeper question would be why create many Authentication methods (ApiKeyAuth, HttpBasicAuth, OAuth) if all API calls hardcode the BearerToken key requiring API only?

Anyhow hope this helps anyone else struggling with GKE 😃

3reactions
lwandercommented, Dec 8, 2017

Thanks - I don’t think the client fully supports the gcp authenticator (at the very minimum token refresh isn’t implemented). It looks like you’re running on GKE, so you could try

gcloud config set container/use_client_certificate True
gcloud container clusters get-credentials my-cluster

To get a credential format the client accepts in the meantime.

Read more comments on GitHub >

github_iconTop Results From Across the Web

11 Common Running Mistakes to Avoid - Verywell Fit
11 Common Running Mistakes to Avoid · Wearing the Wrong Shoes · Doing Too Much, Too Soon · Overstriding · Having Bad Upper...
Read more >
Why some runs feel harder and 3 useful tips you need to know
If you've poured your mental energy into work, you'll have less for running. And this can be a big reason why some runs...
Read more >
How to Run Properly (4 Steps for Beginners to Start Running)
Learn how to run in our step-by-step guide. We'll show you proper running technique so when the zombies come, you don't get eaten....
Read more >
HAVING TROUBLE RUNNING TESTS AND EXAMPLES
I am a new user of pysph, I have followed the procedure given in pysph for the installation of the packages. However, when...
Read more >
The Big Problem With Road Running (5 Solutions) - YouTube
Road running is a staple for most of us but how good is it actually for us and our running ? Because it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found