Skip to content

Jenkins Kubernetes networking

To run Jenkins within a Kubernetes cluster, specific networking configurations are required to facilitate user access via the web interface and to handle communication between the Jenkins master and build agents.

Service Configuration

A Kubernetes Service (jenkins-svc) acts as the internal network endpoint for the Jenkins deployment.^[400-devops__06-Kubernetes__k8s-jenkins__k8s.md] It is configured with two TCP ports to handle different traffic types:

  • HTTP (Port 8080): Connects the service port 8080 to the container port 8080 (named http) for web UI traffic^[400-devops__06-Kubernetes__k8s-jenkins__k8s.md].
  • Agent (Port 50000): Connects the service port 50000 to the container port 50000 (named agent) for JNLP-based build agent connections^[400-devops__06-Kubernetes__k8s-jenkins__k8s.md].

Ingress Configuration

External access to the Jenkins UI is managed using an Ingress resource, which routes HTTP and HTTPS traffic based on rules^[400-devops__06-Kubernetes__k8s-jenkins__k8s.md]. The provided configuration utilizes an Ingress with the following specifications:

  • Ingress Class: Set to nginx^[400-devops__06-Kubernetes__k8s-jenkins__k8s.md].
  • Host Rule: Traffic is routed based on the hostname yudady.gq^[400-devops__06-Kubernetes__k8s-jenkins__k8s.md].
  • Path Routing: A Prefix path type is used for the root path (/)^[400-devops__06-Kubernetes__k8s-jenkins__k8s.md]. All incoming requests matching this rule are forwarded to the jenkins-svc service on port 8080^[400-devops__06-Kubernetes__k8s-jenkins__k8s.md].

Container Ports

The Jenkins Pod itself must expose specific ports to facilitate the connections defined by the Service and Ingress^[400-devops__06-Kubernetes__k8s-jenkins__k8s.md].

  • http (Container Port 8080): This is the main port for the Jenkins web interface^[400-devops__06-Kubernetes__k8s-jenkins__k8s.md].
  • agent (Container Port 50000): This port is used for communication between the Jenkins master and build agents^[400-devops__06-Kubernetes__k8s-jenkins__k8s.md].

Sources

  • 400-devops__06-Kubernetes__k8s-jenkins__k8s.md