parameters: (self,
                   cluster_name="default-cluster",
                   kubernetes_proxy_addr=None,
                   redis_ip=None,
                   redis_port=6379,
                   useInternalIP=False,
                   namespace='default',
                   service_types=None,
                   create_namespace_if_not_exists=False)
docstring: Parameters
          ----------
          cluster_name : str
              A unique name for this Clipper cluster. This can be used to run multiple Clipper
              clusters on the same Kubernetes cluster without interfering with each other.
              Kubernetes cluster name must follow Kubernetes label value naming rule, namely:
              Valid label values must be 63 characters or less and must be empty or begin and end with
              an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.),
              and alphanumerics between. See more at:
              https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
          kubernetes_proxy_addr : str, optional
              The proxy address if you are proxying connections locally using ``kubectl proxy``.
              If this argument is provided, Clipper will construct the appropriate proxy
              URLs for accessing Clipper's Kubernetes services, rather than using the API server
              addres provided in your kube config.
          redis_ip : str, optional
              The address of a running Redis cluster. If set to None, Clipper will start
              a Redis deployment for you.
          redis_port : int, optional
              The Redis port. If ``redis_ip`` is set to None, Clipper will start Redis on this port.
              If ``redis_ip`` is provided, Clipper will connect to Redis on this port.
          useInternalIP : bool, optional
              Use Internal IP of the K8S nodes . If ``useInternalIP`` is set to False, Clipper will
              throw an exception if none of the nodes have ExternalDNS.
              If ``useInternalIP`` is set to true, Clipper will use the Internal IP of the K8S node
              if no ExternalDNS exists for any of the nodes.
          namespace: str, optional
              The Kubernetes namespace to use .
              If this argument is provided, all Clipper artifacts and resources will be created in this
              k8s namespace. If not "default" namespace is used.
          service_types: dict, optional
              Specify what kind of Kubernetes service you want.
              You must use predefined 'ServiceTypes' in Kubernetes as value. See more at:
              https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
              For example, service_types = {
                  'redis': 'NodePort',
                  'management': 'LoadBalancer',
                  'query': 'LoadBalancer',
                  'query-rpc': 'ClusterIP',
                  'metric': 'LoadBalancer'
              }
          create_namespace_if_not_exists: bool, False
              Create a k8s namespace if the namespace doesnt already exist.
              If this argument is provided and the k8s namespace does not exist a new k8s namespace will
              be created.
  
          Note
          ----
          Clipper stores all persistent configuration state (such as registered application and model
          information) in Redis. If you want Clipper to be durable and able to recover from failures,
          we recommend configuring your own persistent and replicated Redis cluster rather than
          letting Clipper launch one for you.
function: def __init__(self,
                   cluster_name="default-cluster",
                   kubernetes_proxy_addr=None,
                   redis_ip=None,
                   redis_port=6379,
                   useInternalIP=False,
                   namespace='default',
                   service_types=None,
                   create_namespace_if_not_exists=False):
          """
  
          Parameters
          ----------
          cluster_name : str
              A unique name for this Clipper cluster. This can be used to run multiple Clipper
              clusters on the same Kubernetes cluster without interfering with each other.
              Kubernetes cluster name must follow Kubernetes label value naming rule, namely:
              Valid label values must be 63 characters or less and must be empty or begin and end with
              an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.),
              and alphanumerics between. See more at:
              https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
          kubernetes_proxy_addr : str, optional
              The proxy address if you are proxying connections locally using ``kubectl proxy``.
              If this argument is provided, Clipper will construct the appropriate proxy
              URLs for accessing Clipper's Kubernetes services, rather than using the API server
              addres provided in your kube config.
          redis_ip : str, optional
              The address of a running Redis cluster. If set to None, Clipper will start
              a Redis deployment for you.
          redis_port : int, optional
              The Redis port. If ``redis_ip`` is set to None, Clipper will start Redis on this port.
              If ``redis_ip`` is provided, Clipper will connect to Redis on this port.
          useInternalIP : bool, optional
              Use Internal IP of the K8S nodes . If ``useInternalIP`` is set to False, Clipper will
              throw an exception if none of the nodes have ExternalDNS.
              If ``useInternalIP`` is set to true, Clipper will use the Internal IP of the K8S node
              if no ExternalDNS exists for any of the nodes.
          namespace: str, optional
              The Kubernetes namespace to use .
              If this argument is provided, all Clipper artifacts and resources will be created in this
              k8s namespace. If not "default" namespace is used.
          service_types: dict, optional
              Specify what kind of Kubernetes service you want.
              You must use predefined 'ServiceTypes' in Kubernetes as value. See more at:
              https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
              For example, service_types = {
                  'redis': 'NodePort',
                  'management': 'LoadBalancer',
                  'query': 'LoadBalancer',
                  'query-rpc': 'ClusterIP',
                  'metric': 'LoadBalancer'
              }
          create_namespace_if_not_exists: bool, False
              Create a k8s namespace if the namespace doesnt already exist.
              If this argument is provided and the k8s namespace does not exist a new k8s namespace will
              be created.
  
          Note
          ----
          Clipper stores all persistent configuration state (such as registered application and model
          information) in Redis. If you want Clipper to be durable and able to recover from failures,
          we recommend configuring your own persistent and replicated Redis cluster rather than
          letting Clipper launch one for you.
          """
  
          self.cluster_name = cluster_name
  
          if kubernetes_proxy_addr is not None:
              self.kubernetes_proxy_addr = kubernetes_proxy_addr
              self.use_k8s_proxy = True
          else:
              self.use_k8s_proxy = False
  
          self.redis_ip = redis_ip
          self.redis_port = redis_port
          self.useInternalIP = useInternalIP
          config.load_kube_config()
          configuration.assert_hostname = False
          self._k8s_v1 = client.CoreV1Api()
          self._k8s_beta = client.ExtensionsV1beta1Api()
          self._k8s_rbac = client.RbacAuthorizationV1beta1Api()
  
  
          # Create the template engine
          # Config: Any variable missing -> Error
          self.template_engine = jinja2.Environment(
              loader=jinja2.FileSystemLoader(cur_dir, followlinks=True),
              undefined=jinja2.StrictUndefined)
  
          # Check if namespace exists and if create flag set ...create the namespace or throw error
          namespaces = []
          for ns in self._k8s_v1.list_namespace().items:
              namespaces.append(ns.metadata.name)
  
          if namespace in namespaces:
              self.k8s_namespace = namespace
          elif create_namespace_if_not_exists:
              body = client.V1Namespace()
              body.metadata = client.V1ObjectMeta(name=namespace)
              try:
                  self._k8s_v1.create_namespace(body)
              except ApiException as e:
                  logging.error(
                      "Exception creating Kubernetes namespace: {}".format(e))
                  raise ClipperException(
                      "Could not create Kubernetes namespace. "
                      "Reason: {}".format(e.reason))
              self.k8s_namespace = namespace
          else:
              msg = "Error connecting to Kubernetes cluster. Namespace does not exist. You can pass in KubernetesContainerManager(create_namespace_if_not_exists=True) to crate this namespcae"
              logger.error(msg)
              raise ClipperException(msg)
  
          # Initialize logger with cluster identifier
          if self.k8s_namespace != "default":
              self.cluster_identifier = "{cluster}".format(
                  cluster=self.cluster_name)
          else:
              self.cluster_identifier = "{ns}-{cluster}".format(
                  ns=self.k8s_namespace, cluster=self.cluster_name)
  
          self.logger = ClusterAdapter(logger, {
              'cluster_name': self.cluster_identifier
          })
  
          self.service_types = self._determine_service_types(service_types)
function_tokens: def __init__ ( self , cluster_name = "default-cluster" , kubernetes_proxy_addr = None , redis_ip = None , redis_port = 6379 , useInternalIP = False , namespace = 'default' , service_types = None , create_namespace_if_not_exists = False ) : self . cluster_name = cluster_name if kubernetes_proxy_addr is not None : self . kubernetes_proxy_addr = kubernetes_proxy_addr self . use_k8s_proxy = True else : self . use_k8s_proxy = False self . redis_ip = redis_ip self . redis_port = redis_port self . useInternalIP = useInternalIP config . load_kube_config ( ) configuration . assert_hostname = False self . _k8s_v1 = client . CoreV1Api ( ) self . _k8s_beta = client . ExtensionsV1beta1Api ( ) self . _k8s_rbac = client . RbacAuthorizationV1beta1Api ( ) # Create the template engine # Config: Any variable missing -> Error self . template_engine = jinja2 . Environment ( loader = jinja2 . FileSystemLoader ( cur_dir , followlinks = True ) , undefined = jinja2 . StrictUndefined ) # Check if namespace exists and if create flag set ...create the namespace or throw error namespaces = [ ] for ns in self . _k8s_v1 . list_namespace ( ) . items : namespaces . append ( ns . metadata . name ) if namespace in namespaces : self . k8s_namespace = namespace elif create_namespace_if_not_exists : body = client . V1Namespace ( ) body . metadata = client . V1ObjectMeta ( name = namespace ) try : self . _k8s_v1 . create_namespace ( body ) except ApiException as e : logging . error ( "Exception creating Kubernetes namespace: {}" . format ( e ) ) raise ClipperException ( "Could not create Kubernetes namespace. " "Reason: {}" . format ( e . reason ) ) self . k8s_namespace = namespace else : msg = "Error connecting to Kubernetes cluster. Namespace does not exist. You can pass in KubernetesContainerManager(create_namespace_if_not_exists=True) to crate this namespcae" logger . error ( msg ) raise ClipperException ( msg ) # Initialize logger with cluster identifier if self . k8s_namespace != "default" : self . cluster_identifier = "{cluster}" . format ( cluster = self . cluster_name ) else : self . cluster_identifier = "{ns}-{cluster}" . format ( ns = self . k8s_namespace , cluster = self . cluster_name ) self . logger = ClusterAdapter ( logger , { 'cluster_name' : self . cluster_identifier } ) self . service_types = self . _determine_service_types ( service_types )