This is the kubernetes demo of Jenkins Remoting OpenTelemetry Plugin
-
Install minikube by following the steps from the Install minikube site.
-
Install kubectl. See the instructions from the Install and Set Up kubectl page.
-
Create a minikube cluster
minikube start
Clone this repository, and set up pods.
kubectl create -f jenkins.yaml -f loki.yaml -f otel-collector.yaml -f prometheus.yaml -f grafana.yaml -n jenkins
Wait all pods to be ready
kubectl get pods -n jenkins
You can now access to the Jenkins controller. If you are using minikube, you can get the url by the following command
minikube service jenkins -n jenkins --url
In order to configure the Kubernetes agents, we need to know the Kubernetes URL
and Jenkins URL
.
You can get the Kubernetes URL
by the following command.
$ kubectl cluster-info
Kubernetes master is running at https://192.168.49.2:8443
CoreDNS is running at https://192.168.49.2:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
The port of Jenkins URL
is standard 8080
, and you can get IP address by the following command.
$ kubectl describe pod jenkins -n jenkins | grep IP:
IP: 172.17.0.3
IP: 172.17.0.3
In this case, Kubernetes URL
is https://192.168.49.2:8443
and Jenkins URL
is http://172.17.0.3:8080
.
Now, we are ready to fill in the Kubernetes plugin configuration. In order to do that, open the Jenkins UI and navigate to “Manage Jenkins → Manage Nodes and Clouds → Configure Clouds → Add a new cloud → Kubernetes and fill in the Kubernetes URL and Jenkins URL appropriately, by using the values which we have just collected in the previous step.
Next, we will create and execute a pipeline. Please use this sample pipeline script.
podTemplate(containers:[
containerTemplate(
name: 'jnlp',
image: 'ghcr.io/aki-7/remoting-opentelemetry-kubernetes-demo/agent',
alwaysPullImage: true,
args: '${computer.jnlpmac} ${computer.name}',
envVars: [
envVar(key: 'OTEL_EXPORTER_OTLP_ENDPOINT', value: 'http://collector.otel.jenkins.svc.cluster.local:55680')
]
),
]) {
node(POD_LABEL) {
stage('Run shell') {
sh 'echo hello && sleep 300'
}
}
}
If you can start the pipeline successfully, the metrics and logs are sent to the observability backends.
Open grafana
minikube service grafana -n jenkins
and explore logs and metrics produced by the agent. You can filter the logs and metrics by service_instance_id which is equal to the JENKINS_AGENT_NAME.