All Known Implementing Classes:
AasK8SJavaProxy, AbstractK8SJavaProxy, HttpK8SJavaProxy

public interface K8SJavaProxy
An interface to create K8S (Kubernetes) proxy.
Author:
Ahmad Alamoush, SSE
  • Method Details

    • getServerSocket

      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 localhost
      certificatePath - the path of certificate used to create the socket
      keyPath - the path of key used to create the socket
      algo - the algorithm used for the key
      tlsCheck - check to use tls security
      Returns:
      the created server socket for the specified port on localhost
      Throws:
      IOException
      UnrecoverableKeyException
      NoSuchAlgorithmException
      KeyStoreException
      CertificateException
      InvalidKeySpecException
      KeyManagementException
    • extractK8SRequestByte

      byte[] extractK8SRequestByte(InputStream reader) throws IOException
      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

      K8SRequest createK8SRequest(byte[] requestByte)
      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

      Send the K8S request object to the MasterProxy or K8S apiserver.
      Parameters:
      writer - is the output buffer to send watch request stream
      request - the K8S request object (K8SRequest)
      Returns:
      the response from the MasterProxy or K8S apiserver for sent request
      Throws:
      CertificateException
      KeyStoreException
      NoSuchAlgorithmException
      KeyManagementException
      IOException
    • 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 stream
      request - the K8S request object (K8SRequest)
      Returns:
      the response from the MasterProxy for sent GET request
      Throws:
      CertificateException
      KeyStoreException
      NoSuchAlgorithmException
      KeyManagementException
      org.apache.http.client.ClientProtocolException
      IOException
    • 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.ClientProtocolException
      IOException
    • 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.ClientProtocolException
      IOException
    • 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.ClientProtocolException
      IOException
    • 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.ClientProtocolException
      IOException
    • 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 stream
      request - the K8S request object (K8SRequest)
      Returns:
      the response from K8S apiserver for request as string
      Throws:
      IOException
    • executeWatchK8SJavaClientRequest

      okhttp3.Response executeWatchK8SJavaClientRequest(K8SRequest request) throws IOException
      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.ParseException
      IOException
    • 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 stream
      request - the K8S request object (K8SRequest)
      httpResponse - the response from the MasterProxy
      Returns:
      the formated response
      Throws:
      org.apache.http.ParseException
      IOException
    • formatK8SResponse

      byte[] formatK8SResponse(K8SRequest request, okhttp3.Response response) throws IOException
      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 stream
      request - the K8S request object (K8SRequest)
      response - the response from the K8S apiserver
      Returns:
      the formated response
      Throws:
      IOException