jkube
jkube copied to clipboard
Add support for specifying `imagePullSecrets` via resource configuration
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 @manusa can i work on this?
@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 https://github.com/eclipse/jkube/pull/2012
@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);
}
In order to complete this issue, you need to do this:
- Add field
List<String> imagePullSecretsin ControllerResourceConfig - Modify ControllerResourceConfigTest to test newly added field
- Read this field in PodTemplateHandler's createPodSpec and add to PodSpecBuilder's
.withImagePullSecrets - Add test case covering this scenario in PodTemplateHandlerTest
- Create a new Gradle Integration test for providing imagePullSecrets via resource configuration
- Add documentation for newly added field in
_controller_resource_generation
In order to complete this issue, you need to do this:
- Add field
List<String> imagePullSecretsin ControllerResourceConfig- Modify ControllerResourceConfigTest to test newly added field
- Read this field in PodTemplateHandler's createPodSpec and add to PodSpecBuilder's
.withImagePullSecrets- Add test case covering this scenario in PodTemplateHandlerTest
- Create a new Gradle Integration test for providing imagePullSecrets via resource configuration
- Add documentation for newly added field in
_controller_resource_generation
thankyou so much
Hi @rohanKanojia, I have made all the changes ..how do I test these changes??
@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-pluginconfiguration forimagePullSecretsinpom.xml - Change the
jkube.versionto1.16-SNAPSHOT - run
mvn k8s:resource - Generated manifest in
target/classes/META-INF/jkube/kubernetes.ymlshould containimagePullSectsas specified inpom.xmlconfiguration
@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-pluginconfiguration forimagePullSecretsinpom.xml- Change the
jkube.versionto1.16-SNAPSHOT- run
mvn k8s:resource- Generated manifest in
target/classes/META-INF/jkube/kubernetes.ymlshould containimagePullSectsas specified inpom.xmlconfiguration
ok thanks
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
@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
@Devashishbasu : polite ping, are you still working on this issue?
@Devashishbasu : polite ping, are you still working on this issue?
Hi rohan , no, I am not working on this issue
@rohanKanojia, I am interested in working on this issue. Could you assign it to me?
@arman-yekkehkhani : Thanks a lot for showing interest in fixing this issue. I had added some code pointers in https://github.com/eclipse-jkube/jkube/issues/2467#issuecomment-1886383825
If you need any help, Please don't hesitate to contact me on Eclipse JKube Gitter Channel.
@arman-yekkehkhani : I see you've started working on this. Could you please create a draft PR?
@rohanKanojia Hi Rohan, I created the PR. However, I am not sure how to implement the Gradle integration test.
@arman-yekkehkhani : Could you please take a look at old pull requests for adding gradle integration test? https://github.com/eclipse-jkube/jkube/pull/2533
@rohanKanojia Thank you so much! I added the integration test. Please have a look at it.