Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with exec credentials on the latest kubernetes-model #1332

Closed
janario opened this issue Jan 29, 2019 · 4 comments
Closed

Error with exec credentials on the latest kubernetes-model #1332

janario opened this issue Jan 29, 2019 · 4 comments

Comments

@janario
Copy link
Contributor

janario commented Jan 29, 2019

After update the kubernetes-client from 4.1.0 to 4.1.1 the exec credentials (used by aws eks) is not working

It used to get it from the map of other properties https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Config.java#L511

But on the latest version o kubernetes-model, AuthInfo, exec is well mapped and additionalProperties doesn't have it anymore

@rohanKanojia
Copy link
Member

@janario : What error are you facing? It could be because of #1280

@janario
Copy link
Contributor Author

janario commented Jan 29, 2019

The exception:

io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: GET at: <url>/api/v1/pods. Message: Forbidden! User <roleArn> doesn't have permission. pods is forbidden: User "system:anonymous" cannot list pods at the cluster scope.
	at io.fabric8.kubernetes.client.dsl.base.OperationSupport.requestFailure(OperationSupport.java:478) ~[kubernetes-client-4.1.1.jar:na]
	at io.fabric8.kubernetes.client.dsl.base.OperationSupport.assertResponseCode(OperationSupport.java:415) ~[kubernetes-client-4.1.1.jar:na]
	at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:381) ~[kubernetes-client-4.1.1.jar:na]
	at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:344) ~[kubernetes-client-4.1.1.jar:na]
	at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:328) ~[kubernetes-client-4.1.1.jar:na]
	at io.fabric8.kubernetes.client.dsl.base.BaseOperation.listRequestHelper(BaseOperation.java:193) ~[kubernetes-client-4.1.1.jar:na]
	at io.fabric8.kubernetes.client.dsl.base.BaseOperation.list(BaseOperation.java:618) ~[kubernetes-client-4.1.1.jar:na]
	at io.fabric8.kubernetes.client.dsl.base.BaseOperation.list(BaseOperation.java:68) ~[kubernetes-client-4.1.1.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
	at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
	at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) ~[na:1.8.0_181]
	at java.util.concurrent.FutureTask.run(FutureTask.java) ~[na:1.8.0_181]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_181]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_181]
	at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_181]

My exec user is something like:

- name: <arn>
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1alpha1
      args:
      - token
      - -i
      - <cluster>
      command: aws-iam-authenticator
      env:
      - name: AWS_PROFILE
        value: <profile>

And I'm doing something simple like PodList list = client.pods().inNamespace("janario").list();

As I debug it https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Config.java#L511

currentAuthInfo.getAdditionalProperties().get("exec"); is returning null because exec used to be mapped as JsonAnySetter for other properties

I think it should be changed to something like ExecConfig exec = currentAuthInfo.getExec() and generate the token

ExecConfig has all the required fields command, env...

@antonalechnovic
Copy link

antonalechnovic commented Jan 29, 2019

having the same issue, funny though, when you downgrade to 4.1.0 you get :
Unrecognized field "expirationTimestamp" from #1280

but it does get ExecConfig correctly and it isn't null unlike in 4.1.1

@janario
Copy link
Contributor Author

janario commented Jan 29, 2019

4.1.0 is working fine for me, We don't have expirationTimestamp in our json (not sure why, maybe our iam configs or the version of aws-iam-authenticator). Anyway that was fixed at #1280


About this one, I've made a pull request and I re-enabled a test-case, please @rohanKanojia could you take a look? :-)
#1333

Thanks guys

btw, it is an awesome library, I really like it ;-) this was just a small bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants