attilapiros opened a new pull request #30751:
URL: https://github.com/apache/spark/pull/30751


   ### What changes were proposed in this pull request?
   
   From [minikube version 
v1.1.0](https://github.com/kubernetes/minikube/blob/v1.1.0/CHANGELOG.md) 
kubectl is available as a command. So the kubeconfig settings can be accessed 
like:
   
   ```
   $ minikube kubectl config view
   apiVersion: v1
   clusters:
   - cluster:
       certificate-authority: /Users/attilazsoltpiros/.minikube/ca.crt
       server: https://127.0.0.1:32788
     name: minikube
   contexts:
   - context:
       cluster: minikube
       namespace: default
       user: minikube
     name: minikube
   current-context: minikube
   kind: Config
   preferences: {}
   users:
   - name: minikube
     user:
       client-certificate: 
/Users/attilazsoltpiros/.minikube/profiles/minikube/client.crt
       client-key: 
/Users/attilazsoltpiros/.minikube/profiles/minikube/client.key
   ```
   
   Here the vm-driver was docker and the server port (https://127.0.0.1:32788) 
is different from the hardcoded 8443.
   
   So the main part of this PR is introducing kubernetes client configuration 
based on the kubeconfig (output of `minikube kubectl config view`) in case of 
minikube versions after v1.1.0 and the old legacy way of configuration is also 
kept as minikube version should be supported back to v0.34.1 .
   
   Moreover as the old style of config parsing pattern wasn't sufficient in my 
case as when the `minikube kubectl config view` is called kubectl downloading 
message might be included before the first key I changed it even for the 
existent keys to be a consistent pattern in this file.
   
   The old parsing in an example:
   ```
   private val HOST_PREFIX = "host:"
   
   val hostString = statusString.find(_.contains(s"$HOST_PREFIX "))
   
   val status1 = hostString.get.split(HOST_PREFIX)(1)
   ```
   
   The new parsing: 
   ```
   private val HOST_PREFIX = "host: "
   
   val hostString = statusString.find(_.contains(HOST_PREFIX))
   
   hostString.get.split(HOST_PREFIX)(1)
   ``` 
   
   So the PREFIX is extended with the extra space at the declaration (this way 
the two separate string operation are more safe and consistent with each other) 
and the replace is changed to split and getting the 2nd string from the result 
(which is guaranteed to contain only the text after the PREFIX when the PREFIX 
is a contained substring).
   
   Finally there is tiny change in `dev-run-integration-tests.sh` to introduce 
`--skip-building-dependencies` which switchs off building of maven dependencies 
of `kubernetes-integration-tests` from the Spark project.
   This could be used when only the `kubernetes-integration-tests` should be 
rebuilded as only the tests are modified. 
   
   
   ### Why are the changes needed?
   
   Kubernetes client configuration based on kubeconfig settings is more 
reliable and provides a solution which is minikube version independent.
    
   ### Does this PR introduce _any_ user-facing change?
   
   No. This is only test code.
   
   ### How was this patch tested?
   
   tested manually on two minikube versions.
   
   Minikube  v0.34.1:
   
   ```
   $ minikube version
   minikube version: v0.34.1
   
   $ grep "version\|building" 
resource-managers/kubernetes/integration-tests/target/integration-tests.log
   20/12/12 12:52:25.135 ScalaTest-main-running-DiscoverySuite INFO Minikube: 
minikube version: v0.34.1
   20/12/12 12:52:25.761 ScalaTest-main-running-DiscoverySuite INFO Minikube: 
building kubernetes config with apiVersion: v1, masterUrl: 
https://192.168.99.103:8443, caCertFile: 
/Users/attilazsoltpiros/.minikube/ca.crt, clientCertFile: 
/Users/attilazsoltpiros/.minikube/apiserver.crt, clientKeyFile: 
/Users/attilazsoltpiros/.minikube/apiserver.key
   ```
   
   Minikube v1.15.1
   ```
   $ minikube version
   
   minikube version: v1.15.1
   commit: 23f40a012abb52eff365ff99a709501a61ac5876
   
   $ grep "version\|building" 
resource-managers/kubernetes/integration-tests/target/integration-tests.log
   
   20/12/13 06:25:55.086 ScalaTest-main-running-DiscoverySuite INFO Minikube: 
minikube version: v1.15.1
   20/12/13 06:25:55.597 ScalaTest-main-running-DiscoverySuite INFO Minikube: 
building kubernetes config with apiVersion: v1, masterUrl: 
https://192.168.64.4:8443, caCertFile: 
/Users/attilazsoltpiros/.minikube/ca.crt, clientCertFile: 
/Users/attilazsoltpiros/.minikube/profiles/minikube/client.crt, clientKeyFile: 
/Users/attilazsoltpiros/.minikube/profiles/minikube/client.key
   
   $ minikube kubectl config view
   apiVersion: v1
   clusters:
   - cluster:
       certificate-authority: /Users/attilazsoltpiros/.minikube/ca.crt
       server: https://192.168.64.4:8443
     name: minikube
   contexts:
   - context:
       cluster: minikube
       namespace: default
       user: minikube
     name: minikube
   current-context: minikube
   kind: Config
   preferences: {}
   users:
   - name: minikube
     user:
       client-certificate: 
/Users/attilazsoltpiros/.minikube/profiles/minikube/client.crt
       client-key: 
/Users/attilazsoltpiros/.minikube/profiles/minikube/client.key
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to