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

ServiceAccount binding not being generated in deployment #1758

Closed
nightswimmings opened this issue Sep 16, 2022 · 8 comments
Closed

ServiceAccount binding not being generated in deployment #1758

nightswimmings opened this issue Sep 16, 2022 · 8 comments
Assignees
Labels
bug Something isn't working demoable Issues which can be demoed during the Sprint review meeting
Milestone

Comments

@nightswimmings
Copy link

nightswimmings commented Sep 16, 2022

Describe the bug

Even though documentation states https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin#serviceaccount-generation
that one can bind the deployment to a serviceaccount by using

<configuration>
    <resources>
      <serviceAccount>my-existing-serviceaccount</serviceAccount>
    </resources>
</configuration>

I just observed that there's no trace of such setting on the generated deployment.yml resource

The create approach, first described in the documentation, works fine but I have a preexisting serviceaccount so i dont want to generate it. I also tried using skpiCreate on the enricher with everything defined with ServiceAccounts, but still it fails

Eclipse JKube version

1.9.1

Component

Kubernetes Maven Plugin

Apache Maven version

3.6.1

Gradle version

No response

Steps to reproduce

Use a 1.9.1 JKube configuration with

 <configuration>
      <resources>
          <serviceAccount>existing-serviceaccount</serviceAccount>

the generated kubernates.yml/deployment.yml dont include serviceAccount on the spec

Expected behavior

deployment should contain the template.spec.serviceAccountName property with the value as per the definition in the POM plugin configuration section

Runtime

Kubernetes (vanilla)

Kubernetes API Server version

other (please specify in additional context)

Environment

macOS, other (please specify in additional context)

Eclipse JKube Logs

No response

Sample Reproducer Project

No response

Additional context

One can see the omission by inspecting generated descriptors, no need to test the integration with kubernetes

@nightswimmings nightswimmings added the bug Something isn't working label Sep 16, 2022
@rohanKanojia
Copy link
Member

rohanKanojia commented Sep 16, 2022

Are you generating Deployment using JKube zero configuration mode or using your own fragment? For me, it seems to work for zero configuration mode but not when I'm using a Deployment fragment.

I also tried using skpiCreate on the enricher with everything defined with ServiceAccounts, but still it fails

Are you sure about this? We have an integration test to verify this ServiceAccountIT

@nightswimmings
Copy link
Author

nightswimmings commented Sep 19, 2022

I am using my own deployment.yaml fragment. Currenlty to work it out I am using
a manual serviceAccountName property in my deployment.yml, with the enricher config as <skipCreate>true</skipCreate>, otherwise, even if the serviceaccount is not generated from pom declaration it still generates the serviceAccount descriptor

@manusa manusa added this to the 1.10.0 milestone Sep 20, 2022
@sunix sunix assigned sunix and unassigned sunix Oct 26, 2022
@rohanKanojia rohanKanojia self-assigned this Nov 3, 2022
@rohanKanojia
Copy link
Member

I've observed ServiceAccountEnricher seems to only consider <resources> > <serviceAccounts> option not <serviceAccount> . <serviceAccount> only seems to be consumed while generating opinionated Deployments. This configuration seems to be working when using a deployment fragment:

          <configuration>
            <resources>
              <serviceAccounts>
                <serviceAccount>
                  <name>my-existing-serviceaccount</name>
                  <deploymentRef>${project.artifactId}</deploymentRef>
                </serviceAccount>
              </serviceAccounts>
            </resources>
        ...

We need to make changes to ServiceAccountEnricher to consider <serviceAccount> option as well.

@manusa
Copy link
Member

manusa commented Nov 3, 2022

We might want to deal with the ResourceConfig pojo and maybe remove the getServiceAccount getter, or evaluate how both configurations should be merged.

rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 3, 2022
…ountEnricher from handlers (eclipse-jkube#1758)

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 4, 2022
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 4, 2022
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 4, 2022
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 7, 2022
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 7, 2022
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 8, 2022
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 8, 2022
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 8, 2022
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@manusa manusa modified the milestones: 1.10.0, 1.11.0 Nov 10, 2022
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Dec 8, 2022
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Dec 14, 2022
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@sunix sunix added the demoable Issues which can be demoed during the Sprint review meeting label Jan 20, 2023
manusa pushed a commit to rohanKanojia/jkube that referenced this issue Feb 8, 2023
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
manusa pushed a commit to rohanKanojia/jkube that referenced this issue Feb 9, 2023
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@manusa manusa modified the milestones: 1.11.0, 1.12.0 Feb 16, 2023
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Feb 21, 2023
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Feb 21, 2023
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Feb 28, 2023
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@manusa manusa modified the milestones: 1.12.0, 1.13.0 Mar 31, 2023
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Apr 12, 2023
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue May 17, 2023
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue May 30, 2023
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue May 30, 2023
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@rohanKanojia
Copy link
Member

Since v1.11.0, <serviceAccount> configuration option has stopped working. ServiceAccount reference was removed from PodTemplateHandler in #1969

Before v1.11.0, it used to work for zero configuration mode but not when user provides a deployment fragment.

rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue May 31, 2023
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue May 31, 2023
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.

    Signed-off-by: Rohan Kumar <rohaan@redhat.com>

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@rohanKanojia
Copy link
Member

We moved serviceAccount configuration related logic to ServiceAccountEnricher in #2190 . This issue should be fixed by that.

I have checked with serviceAccount configuration option with and without depoyment.yaml fragment, it seems to add serviceAccountName in generated Deployment manifest. ServiceAccountNameViaGroovyDSLIT should also verify this scenario.

@rohanKanojia
Copy link
Member

I've created #2196 for merging two configuration options. I think this issue can be closed.

@rohanKanojia
Copy link
Member

@nightswimmings : Sorry for the extremely late reply. We have released v1.13.0 which should contain fix for your ServiceAccount issue. Would appreciate if you could try it out whenever you get time..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working demoable Issues which can be demoed during the Sprint review meeting
Projects
None yet
4 participants