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

Add support for specifying imagePullSecrets via resource configuration #2467

Closed
rohanKanojia opened this issue Nov 22, 2023 · 18 comments · Fixed by #3133
Closed

Add support for specifying imagePullSecrets via resource configuration #2467

rohanKanojia opened this issue Nov 22, 2023 · 18 comments · Fixed by #3133
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@rohanKanojia
Copy link
Member

rohanKanojia commented Nov 22, 2023

Component

JKube Kit

Is your enhancement related to a problem? Please describe

This was asked by a user on Gitter chat:

How to configure the generated file to include the imagePullSecrets content in the maven pom file

As a user, If I want to specify imagePullSecrets for Deployment, I need to add them in resource fragment like this:

https://github.com/eclipse/jkube/blob/5dc19d9563adb3c10a2ad1f30e8f404d5ca29ab9/quickstarts/maven/tomee/src/main/jkube/deployment.yaml#L26-L27

This option should also be exposed via controller resource configuration

Describe the solution you'd like

As a user, I want to specify imagePullSecrets in my pom.xml like this:

<configuration>
  <resources> 
    <controller>
      <replicas>2</replicas>
       <imagePullSecrets>
           <imagePullSecret>${env.SECRET1}</imagePullSecret>
       </imagePullSecrets>
    </controller>
  </resources>
</configuration>

so that generated Deployment (or any other controller) contains specified imagePullSecrets

Describe alternatives you've considered

No response

Additional context

No response

@rohanKanojia rohanKanojia added the enhancement New feature or request label Nov 22, 2023
@rohanKanojia rohanKanojia changed the title Add support ffor specifying imagePullSecrets via resource configuration Add support for specifying imagePullSecrets via resource configuration Nov 22, 2023
@Devashishbasu
Copy link
Contributor

@rohanKanojia @manusa can i work on this?

@rohanKanojia
Copy link
Member Author

@Devashishbasu : This one would be a somewhat medium-level difficulty issue. You just need to add a field to ControllerResourceConfig and PodTemplateHandler would read that. A similar field schedule was added to resource configuration in this PR #2012

@Devashishbasu
Copy link
Contributor

Devashishbasu commented Jan 11, 2024

@rohanKanojia i have added this code for reading imagePullSecrets in PodTemplateHandler is it okay or i have to modify it? or do i have to add test cases?

 public PodTemplateSpec getPodTemplate(ControllerResourceConfig config) {
        List<String> imagePullSecrets = new ArrayList<>();
        if (config.getImagePullSecrets() != null) {
            for (String secret : config.getImagePullSecrets()) {
                imagePullSecrets.add(new String(secret));
            }
        }
        podTemplateSpec.setImagePullSecrets(imagePullSecrets);


    }

@rohanKanojia
Copy link
Member Author

In order to complete this issue, you need to do this:

  1. Add field List<String> imagePullSecrets in ControllerResourceConfig
  2. Modify ControllerResourceConfigTest to test newly added field
  3. Read this field in PodTemplateHandler's createPodSpec and add to PodSpecBuilder's .withImagePullSecrets
  4. Add test case covering this scenario in PodTemplateHandlerTest
  5. Create a new Gradle Integration test for providing imagePullSecrets via resource configuration
  6. Add documentation for newly added field in _controller_resource_generation

@Devashishbasu
Copy link
Contributor

In order to complete this issue, you need to do this:

  1. Add field List<String> imagePullSecrets in ControllerResourceConfig
  2. Modify ControllerResourceConfigTest to test newly added field
  3. Read this field in PodTemplateHandler's createPodSpec and add to PodSpecBuilder's .withImagePullSecrets
  4. Add test case covering this scenario in PodTemplateHandlerTest
  5. Create a new Gradle Integration test for providing imagePullSecrets via resource configuration
  6. Add documentation for newly added field in _controller_resource_generation

thankyou so much

@Devashishbasu
Copy link
Contributor

Hi @rohanKanojia, I have made all the changes ..how do I test these changes??

@rohanKanojia
Copy link
Member Author

@Devashishbasu : Unit tests added to verify this change should pass.

You can also verify by going to any demo project in quickstarts/maven/ .

  • Add the kubernetes-maven-plugin configuration for imagePullSecrets in pom.xml
  • Change the jkube.version to 1.16-SNAPSHOT
  • run mvn k8s:resource
  • Generated manifest in target/classes/META-INF/jkube/kubernetes.yml should contain imagePullSects as specified in pom.xml configuration

@Devashishbasu
Copy link
Contributor

@Devashishbasu : Unit tests added to verify this change should pass.

You can also verify by going to any demo project in quickstarts/maven/ .

  • Add the kubernetes-maven-plugin configuration for imagePullSecrets in pom.xml
  • Change the jkube.version to 1.16-SNAPSHOT
  • run mvn k8s:resource
  • Generated manifest in target/classes/META-INF/jkube/kubernetes.yml should contain imagePullSects as specified in pom.xml configuration

ok thanks

@Devashishbasu
Copy link
Contributor

Hi @rohanKanojia ...unit tests added to verify my changes have passed and when i am building hello-world from quickstarts/maven using mvn clean install its showing build success ...but when i am trying to run mvn k8s:resource then its showing this error
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.109 s
[INFO] Finished at: 2024-01-13T23:02:42+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'k8s' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\hp.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException

please help

@rohanKanojia
Copy link
Member Author

@Devashishbasu : Which quickstart are you using? I meant running it like this:

# Build project
$ mvn clean install
# Go to quickstart
$ cd quickstarts/maven/spring-boot
# Run kubernetes-maven-plugin
$ mvn k8s:resource -Pkubernetes

@rohanKanojia
Copy link
Member Author

@Devashishbasu : polite ping, are you still working on this issue?

@Devashishbasu
Copy link
Contributor

@Devashishbasu : polite ping, are you still working on this issue?

Hi rohan , no, I am not working on this issue

@arman-yekkehkhani
Copy link
Contributor

@rohanKanojia, I am interested in working on this issue. Could you assign it to me?

@rohanKanojia
Copy link
Member Author

rohanKanojia commented May 29, 2024

@arman-yekkehkhani : Thanks a lot for showing interest in fixing this issue. I had added some code pointers in #2467 (comment)

If you need any help, Please don't hesitate to contact me on Eclipse JKube Gitter Channel.

arman-yekkehkhani added a commit to arman-yekkehkhani/jkube that referenced this issue Jun 3, 2024
…s via resource configuration, issue eclipse-jkube#2467

Signed-off-by: arman-yekkehkhani <arman.yekkehkhani@gmail.com>
arman-yekkehkhani added a commit to arman-yekkehkhani/jkube that referenced this issue Jun 3, 2024
…ce_generation.adoc, issue eclipse-jkube#2467

Signed-off-by: arman-yekkehkhani <arman.yekkehkhani@gmail.com>
@rohanKanojia
Copy link
Member Author

@arman-yekkehkhani : I see you've started working on this. Could you please create a draft PR?

@arman-yekkehkhani
Copy link
Contributor

@rohanKanojia Hi Rohan, I created the PR. However, I am not sure how to implement the Gradle integration test.

@rohanKanojia
Copy link
Member Author

@arman-yekkehkhani : Could you please take a look at old pull requests for adding gradle integration test? #2533

arman-yekkehkhani added a commit to arman-yekkehkhani/jkube that referenced this issue Jun 5, 2024
…clipse-jkube#2467

Signed-off-by: arman-yekkehkhani <arman.yekkehkhani@gmail.com>
@arman-yekkehkhani
Copy link
Contributor

@rohanKanojia Thank you so much! I added the integration test. Please have a look at it.

arman-yekkehkhani added a commit to arman-yekkehkhani/jkube that referenced this issue Jun 5, 2024
…ass, issue eclipse-jkube#2467

Signed-off-by: arman-yekkehkhani <arman.yekkehkhani@gmail.com>
arman-yekkehkhani added a commit to arman-yekkehkhani/jkube that referenced this issue Jun 6, 2024
Signed-off-by: arman-yekkehkhani <arman.yekkehkhani@gmail.com>
arman-yekkehkhani added a commit to arman-yekkehkhani/jkube that referenced this issue Jun 6, 2024
…2467

Signed-off-by: arman-yekkehkhani <arman.yekkehkhani@gmail.com>
@manusa manusa added this to the 1.17.0 milestone Jun 7, 2024 — with automated-tasks
manusa pushed a commit that referenced this issue Jun 7, 2024
…nfiguration (3133)

feature(imagePullSecrets): Add support for specifying imagePullSecrets via resource configuration, issue #2467

Signed-off-by: arman-yekkehkhani <arman.yekkehkhani@gmail.com>
---
feature(imagePullSecrets): add imagePullSecrets to _controller_resource_generation.adoc, issue #2467

Signed-off-by: arman-yekkehkhani <arman.yekkehkhani@gmail.com>
---
Merge branch 'eclipse-jkube:master' into gh_2467-experimental
---
feature(imagePullSecrets): add gradle plugin integration test, issue #2467

Signed-off-by: arman-yekkehkhani <arman.yekkehkhani@gmail.com>
---
feature(imagePullSecrets): remove public access modifier from test class, issue #2467

Signed-off-by: arman-yekkehkhani <arman.yekkehkhani@gmail.com>
---
feature(imagePullSecrets): add license, issue #2467

Signed-off-by: arman-yekkehkhani <arman.yekkehkhani@gmail.com>
---
feature(imagePullSecrets): update CHANGELOG.md , issue #2467

Signed-off-by: arman-yekkehkhani <arman.yekkehkhani@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants