-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Implement Port Mapping #135
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the UI for the settings form, not just for pipeline?
|
||
@DataBoundSetter | ||
public void setPorts(List<PortMapping> ports) { | ||
this.ports.addAll(ports); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.ports
may be null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by this logic @carlossg the setEnvVars
calls could also be null and fail as it just does this
public void setEnvVars(List<ContainerEnvVar> envVars) {
this.envVars.addAll(envVars);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's only on upgrades, maybe envVars
was there from the beginning
Because ports
didn't exist, when deserializing the previous version configuration jenkins will set ports=null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carlossg, I upgrade to a version of the plugin with this patched it and I didn't see any errors or nothing anything once jenkins was up again and running jobs.
@derfred any update on this? I've recently come into the need of having ports be exposed for e2e testing things. |
@carlossg I have added the UI for exposing the ports. |
@@ -83,6 +83,7 @@ The `containerTemplate` is a template of container that will be added to the pod | |||
* **command** The command the container will execute. | |||
* **args** The arugments passed to the command. | |||
* **ttyEnabled** Flag to mark that tty should be enabled. | |||
* **ports** Expose ports on the container. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@derfred this works great, the only thing that you may want to add to the readme is to outline that you access a port that is open on another container you need to use 127.0.0.1
for the url, as doing it name based is not working for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jwhitcraft in what scenario are you using it? Because I am trying to run some tests with a mariadb database and getting connection refused when trying to connect. My pod template is exactly as the one on readme. I tried to connect to mysql cli from within the container as well, and I get a ´Can't connect to local MySQL server through socket ´ error (commented in the PR as well).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found the solution, described in the PR discussion
@carlossg can we get this merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, added a comment about setPorts
It also needs the help blurbs for the UI under https://github.com/jenkinsci/kubernetes-plugin/tree/master/src/main/resources/org/csanchez/jenkins/plugins/kubernetes and for pipeline in https://github.com/jenkinsci/kubernetes-plugin/tree/master/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStep
public void setPorts(List<PortMapping> ports) { | ||
if (ports != null) { | ||
this.ports.addAll(ports); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it is null then you are doing nothing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should be done if the value is null? this.ports
is already the list as defined above. In my testing of this, this works fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missread. But shouldn't be just
this.ports = ports
otherwise you are adding ports all the time to the existing ones, not clearing up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll comment there
@derfred any chance of finishing up this? |
superseded by #165 |
I'm getting Jenkins is running on a Kubernetes cluster on aws. |
it will be released in 0.12 |
Im trying to run some application tests using mariadb container and portaMapping, but it does not work for me using neither using 127.0.0.1, localhost or 0.0.0.0. When trying to access mysql cli from within the cointainer I get: |
Found the solution that day, just explaining so that other people facing the same issue could benefit from it. Inspecting the container created by Kubernetes, I realized that the container template for Mariadb in the readme does not work, it has two errors:
Im filling a small PR to fix this |
This adds the capability to expose ports on the pods like this: