(self, instance)
return kube_apiserver_metrics_instance
Set up kube_apiserver_metrics instance so it can be used in OpenMetricsBaseCheck
Set up kube_apiserver_metrics instance so it can be used in OpenMetricsBaseCheck
Set up kube_apiserver_metrics instance so it can be used in OpenMetricsBaseCheck
def _create_kube_apiserver_metrics_instance(self, instance):
        """
        Set up kube_apiserver_metrics instance so it can be used in OpenMetricsBaseCheck
        """
        kube_apiserver_metrics_instance = deepcopy(instance)
        endpoint = instance.get('prometheus_url')
        prometheus_url = endpoint

        # Allow using a proper URL without introducing a breaking change since
        # the scheme option is deprecated.
        if not match('^https?://.*$', endpoint):
            scheme = instance.get('scheme', self.DEFAULT_SCHEME)
            prometheus_url = "{0}://{1}".format(scheme, endpoint)

        kube_apiserver_metrics_instance['prometheus_url'] = prometheus_url

        # Most set ups are using self signed certificates as the APIServer can be used as a CA.
        ssl_verify = instance.get('ssl_verify', self.DEFAULT_SSL_VERIFY)
        kube_apiserver_metrics_instance['ssl_verify'] = ssl_verify

        # We should default to supporting environments using RBAC to access the APIServer.
        bearer_token_auth = instance.get('bearer_token_auth', self.DEFAULT_BEARER_TOKEN_AUTH)
        kube_apiserver_metrics_instance['bearer_token_auth'] = bearer_token_auth

        return kube_apiserver_metrics_instance
def _create_kube_apiserver_metrics_instance ( self , instance ) : kube_apiserver_metrics_instance = deepcopy ( instance ) endpoint = instance . get ( 'prometheus_url' ) prometheus_url = endpoint # Allow using a proper URL without introducing a breaking change since # the scheme option is deprecated. if not match ( '^https?://.*$' , endpoint ) : scheme = instance . get ( 'scheme' , self . DEFAULT_SCHEME ) prometheus_url = "{0}://{1}" . format ( scheme , endpoint ) kube_apiserver_metrics_instance [ 'prometheus_url' ] = prometheus_url # Most set ups are using self signed certificates as the APIServer can be used as a CA. ssl_verify = instance . get ( 'ssl_verify' , self . DEFAULT_SSL_VERIFY ) kube_apiserver_metrics_instance [ 'ssl_verify' ] = ssl_verify # We should default to supporting environments using RBAC to access the APIServer. bearer_token_auth = instance . get ( 'bearer_token_auth' , self . DEFAULT_BEARER_TOKEN_AUTH ) kube_apiserver_metrics_instance [ 'bearer_token_auth' ] = bearer_token_auth return kube_apiserver_metrics_instance