@@ -1006,72 +1006,31 @@ Run `mvn clean install` and copy `target/kubernetes.hpi` to Jenkins plugins fold
1006
1006
1007
1007
## Running Kubernetes Integration Tests
1008
1008
1009
- ### Integration tests with Kind (recommended)
1009
+ Set up your `$KUBECONFIG` however you like, for example
1010
1010
1011
1011
```bash
1012
- export MOUNT_M2=true
1013
- ./kind-mount-m2.sh
1014
- ./kind-preload.sh
1015
- ./test-in-k8s.sh -Dtest=KubernetesPipelineTest#runInPod
1016
- kind delete cluster
1012
+ kind create cluster
1017
1013
```
1018
1014
1019
- ### Integration tests in a remote cluster
1020
-
1021
- Set up your ` $KUBECONFIG ` as usual, then
1015
+ then
1022
1016
1023
1017
``` bash
1024
- ./test-in-k8s.sh -Dtest=KubernetesPipelineTest#runInPod
1018
+ kubectl krew install tunnel # as needed; install Krew first
1019
+ kubectl tunnel expose jenkins 8000:8000 8001:8001 &
1020
+ mvn test -Djenkins.host.address=jenkins.default -Dport=8000 -DslaveAgentPort=8001 -Dtest=KubernetesPipelineTest#runInPod
1025
1021
```
1026
1022
1027
- ### Integration tests with Minikube
1028
-
1029
- The system you run ` mvn ` on needs to be reachable from the cluster.
1030
- If you see the agents happen to connect to the wrong host, see you can use
1031
- ` jenkins.host.address ` as mentioned above.
1032
-
1033
- For integration tests install and start [ minikube] ( https://github.com/kubernetes/minikube ) .
1034
- Tests will detect it and run a set of integration tests in a new namespace.
1035
-
1036
- Some integration tests run a local jenkins, so the host that runs them needs
1037
- to be accessible from the kubernetes cluster.
1038
- By default Jenkins will listen on ` 192.168.64.1 ` interface only, for security reasons.
1039
- If your minikube is not running in that network, pass ` connectorHost ` to maven, ie.
1040
-
1041
- mvn clean install -DconnectorHost=$(minikube ip | sed -e 's/\([0-9]*\.[0-9]*\.[0-9]*\).*/\1.1/')
1042
-
1043
- If you don't mind others in your network being able to use your test jenkins you could just use this:
1044
-
1045
- mvn clean install -DconnectorHost=0.0.0.0
1046
-
1047
- Then your test jenkins will listen on all ip addresses so that the build pods will be able to connect from the pods in your minikube VM to your host.
1048
-
1049
- If your minikube is running in a VM (e.g. on virtualbox) and the host running ` mvn `
1050
- does not have a public hostname for the VM to access, you can set the ` jenkins.host.address `
1051
- system property to the (host-only or NAT) IP of your host:
1052
-
1053
- mvn clean install -Djenkins.host.address=192.168.99.1
1054
-
1055
- ### Integration tests with Microk8s
1056
-
1057
- If [ Microk8s] ( https://microk8s.io/ ) is running and is the default context in your ` ~/.kube/config ` ,
1058
- just run as
1059
-
1060
- mvn clean install -Pmicrok8s
1061
-
1062
- This assumes that from a pod, the host system is accessible as IP address ` 10.1.1.1 ` .
1063
- It might be some variant such as ` 10.1.37.1 ` ,
1064
- in which case you would need to set ` -DconnectorHost=… -Djenkins.host.address=… ` instead.
1065
- To see the actual address, try:
1023
+ Alternately, you can run everything like in CI:
1066
1024
1067
1025
``` bash
1068
- ifdata -pa cni0
1026
+ export KIND_PRELOAD=true # optionally
1027
+ ./kind.sh -Dtest=KubernetesPipelineTest#runInPod
1069
1028
```
1070
1029
1071
- Or to verify the networking inside a pod :
1030
+ You can also run interactively after setting up the tunnel :
1072
1031
1073
1032
``` bash
1074
- kubectl run --rm --image=praqma/network-multitool --restart=Never --attach sh ip route | fgrep ' default via '
1033
+ mvn hpi: run -Djenkins.host.address=jenkins.default -Dport=8000 -Djenkins.model.Jenkins.slaveAgentPort=8001
1075
1034
```
1076
1035
1077
1036
# Docker image
0 commit comments