Interface K8SJavaProxy
- All Known Implementing Classes:
AasK8SJavaProxy,AbstractK8SJavaProxy,HttpK8SJavaProxy
public interface K8SJavaProxy
An interface to create K8S (Kubernetes) proxy.
- Author:
- Ahmad Alamoush, SSE
-
Method Summary
Modifier and TypeMethodDescriptioncreateK8SRequest(byte[] requestByte) Create K8S request object from the actual array of bytes for the received request.byte[]executeK8SDelete(K8SRequest request) Execute DELETE request and send it to the MasterProxy.byte[]executeK8SGet(BufferedOutputStream writer, K8SRequest request) Execute GET request and send it to the MasterProxy.byte[]executeK8SJavaClientRequest(BufferedOutputStream writer, K8SRequest request) Execute the request and send it to K8S apiserver.byte[]executeK8SPatch(K8SRequest request) Execute PATCH request and send it to the MasterProxy.byte[]executeK8SPost(K8SRequest request) Execute POST request and send it to the MasterProxy.byte[]executeK8SPut(K8SRequest request) Execute PUT request and send it to the MasterProxy.okhttp3.ResponseExecute the request and send it to K8S apiserver.byte[]extractK8SRequestByte(InputStream reader) Extract the request as array of bytes from the InputStream of the localhost server socket.byte[]formatK8SResponse(K8SRequest request, okhttp3.Response response) Format the response from K8S apiserver.byte[]formatK8SResponse(K8SRequest request, org.apache.http.HttpResponse httpResponse) Format the response from the MasterProxy.byte[]formatWatchK8SResponse(BufferedOutputStream writer, K8SRequest request, okhttp3.Response response) Format the response from K8S apiserver.byte[]formatWatchK8SResponse(BufferedOutputStream writer, K8SRequest request, org.apache.http.HttpResponse httpResponse) Format the response from the MasterProxy.getServerSocket(int localPort, String certificatePath, String keyPath, String algo, boolean tlsCheck) Create server socket for specified port on localhost to receive new requests.byte[]sendK8SRequest(BufferedOutputStream writer, K8SRequest request) Send the K8S request object to the MasterProxy or K8S apiserver.
-
Method Details
-
getServerSocket
ServerSocket getServerSocket(int localPort, String certificatePath, String keyPath, String algo, boolean tlsCheck) throws IOException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, CertificateException, InvalidKeySpecException, KeyManagementException Create server socket for specified port on localhost to receive new requests. If certificatePath or keyPath or algo is null, Then it will use apiserver.key and apiserver.crt and RSA by default.- Parameters:
localPort- the port on the localhostcertificatePath- the path of certificate used to create the socketkeyPath- the path of key used to create the socketalgo- the algorithm used for the keytlsCheck- check to use tls security- Returns:
- the created server socket for the specified port on localhost
- Throws:
IOExceptionUnrecoverableKeyExceptionNoSuchAlgorithmExceptionKeyStoreExceptionCertificateExceptionInvalidKeySpecExceptionKeyManagementException
-
extractK8SRequestByte
Extract the request as array of bytes from the InputStream of the localhost server socket.- Parameters:
reader- the InputStream for the port on the localhost- Returns:
- the request as array of bytes
- Throws:
IOException
-
createK8SRequest
Create K8S request object from the actual array of bytes for the received request.- Parameters:
requestByte- the request as array of bytes- Returns:
- the new created K8S request object (K8SRequest)
-
sendK8SRequest
byte[] sendK8SRequest(BufferedOutputStream writer, K8SRequest request) throws IOException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, CertificateException Send the K8S request object to the MasterProxy or K8S apiserver.- Parameters:
writer- is the output buffer to send watch request streamrequest- the K8S request object (K8SRequest)- Returns:
- the response from the MasterProxy or K8S apiserver for sent request
- Throws:
CertificateExceptionKeyStoreExceptionNoSuchAlgorithmExceptionKeyManagementExceptionIOException
-
executeK8SGet
byte[] executeK8SGet(BufferedOutputStream writer, K8SRequest request) throws org.apache.http.client.ClientProtocolException, IOException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, CertificateException Execute GET request and send it to the MasterProxy.- Parameters:
writer- is the output buffer to send watch request streamrequest- the K8S request object (K8SRequest)- Returns:
- the response from the MasterProxy for sent GET request
- Throws:
CertificateExceptionKeyStoreExceptionNoSuchAlgorithmExceptionKeyManagementExceptionorg.apache.http.client.ClientProtocolExceptionIOException
-
executeK8SPost
byte[] executeK8SPost(K8SRequest request) throws org.apache.http.client.ClientProtocolException, IOException Execute POST request and send it to the MasterProxy.- Parameters:
request- the K8S request object (K8SRequest)- Returns:
- the response from the MasterProxy for sent POST request
- Throws:
org.apache.http.client.ClientProtocolExceptionIOException
-
executeK8SPut
byte[] executeK8SPut(K8SRequest request) throws org.apache.http.client.ClientProtocolException, IOException Execute PUT request and send it to the MasterProxy.- Parameters:
request- the K8S request object (K8SRequest)- Returns:
- the response from the MasterProxy for sent PUT request
- Throws:
org.apache.http.client.ClientProtocolExceptionIOException
-
executeK8SPatch
byte[] executeK8SPatch(K8SRequest request) throws org.apache.http.client.ClientProtocolException, IOException Execute PATCH request and send it to the MasterProxy.- Parameters:
request- the K8S request object (K8SRequest)- Returns:
- the response from the MasterProxy for sent PATCH request
- Throws:
org.apache.http.client.ClientProtocolExceptionIOException
-
executeK8SDelete
byte[] executeK8SDelete(K8SRequest request) throws org.apache.http.client.ClientProtocolException, IOException Execute DELETE request and send it to the MasterProxy.- Parameters:
request- the K8S request object (K8SRequest)- Returns:
- the response from the MasterProxy for sent DELETE request
- Throws:
org.apache.http.client.ClientProtocolExceptionIOException
-
executeK8SJavaClientRequest
byte[] executeK8SJavaClientRequest(BufferedOutputStream writer, K8SRequest request) throws IOException Execute the request and send it to K8S apiserver.- Parameters:
writer- is the output buffer to send watch request streamrequest- the K8S request object (K8SRequest)- Returns:
- the response from K8S apiserver for request as string
- Throws:
IOException
-
executeWatchK8SJavaClientRequest
Execute the request and send it to K8S apiserver.- Parameters:
request- the K8S request object (K8SRequest)- Returns:
- the response from K8S apiserver for request as okhttp3.response
- Throws:
IOException
-
formatK8SResponse
byte[] formatK8SResponse(K8SRequest request, org.apache.http.HttpResponse httpResponse) throws org.apache.http.ParseException, IOException Format the response from the MasterProxy.- Parameters:
request- the K8S request object (K8SRequest)httpResponse- the response from the MasterProxy- Returns:
- the formated response
- Throws:
org.apache.http.ParseExceptionIOException
-
formatWatchK8SResponse
byte[] formatWatchK8SResponse(BufferedOutputStream writer, K8SRequest request, org.apache.http.HttpResponse httpResponse) throws org.apache.http.ParseException, IOException Format the response from the MasterProxy.- Parameters:
writer- is the output buffer to send watch request streamrequest- the K8S request object (K8SRequest)httpResponse- the response from the MasterProxy- Returns:
- the formated response
- Throws:
org.apache.http.ParseExceptionIOException
-
formatK8SResponse
Format the response from K8S apiserver.- Parameters:
request- the K8S request object (K8SRequest)response- the response from the K8S apiserver- Returns:
- the formated response
- Throws:
IOException
-
formatWatchK8SResponse
byte[] formatWatchK8SResponse(BufferedOutputStream writer, K8SRequest request, okhttp3.Response response) throws IOException Format the response from K8S apiserver.- Parameters:
writer- is the output buffer to send watch request streamrequest- the K8S request object (K8SRequest)response- the response from the K8S apiserver- Returns:
- the formated response
- Throws:
IOException
-