Пример #1
0
    def _get_kube_cluster(self, cluster_name):
        # Get the current version information
        cluster_version = self._kube_operator.kube_get_kubernetes_version()

        # Retrieve the default kubernetes cluster configuration
        cluster_config = self._kube_operator.kube_get_kubernetes_config()
        cluster_ca_cert = utils.get_file_content(cluster_config.ssl_ca_cert)
        admin_client_cert = utils.get_file_content(cluster_config.cert_file)
        admin_client_key = utils.get_file_content(cluster_config.key_file)

        # Build public endpoint from private endpoint
        endpoint_parsed = urlparse(cluster_config.host)
        endpoint_host = utils.format_url_address(self._get_oam_address())
        endpoint_netloc = "{}:{}".format(endpoint_host, endpoint_parsed.port)
        cluster_api_endpoint = endpoint_parsed._replace(
            netloc=endpoint_netloc).geturl()

        # Retrieve the default cluster admin service account token
        admin_user = kubernetes.KUBERNETES_ADMIN_USER
        admin_token = self._kube_operator.kube_get_service_account_token(
            admin_user, kubernetes.NAMESPACE_KUBE_SYSTEM)

        return {
            "cluster_name": cluster_name,
            "cluster_version": cluster_version,
            'cluster_api_endpoint': cluster_api_endpoint,
            "cluster_ca_cert": cluster_ca_cert,
            "admin_client_cert": admin_client_cert,
            "admin_client_key": admin_client_key,
            "admin_user": admin_user,
            "admin_token": admin_token
        }
 def test_addresses(self):
     overrides = self.operator.get_helm_chart_overrides(
         app_constants.HELM_CHART_OIDC_CLIENT,
         cnamespace=common.HELM_NS_KUBE_SYSTEM)
     oam_addr_name = utils.format_address_name(
         constants.CONTROLLER_HOSTNAME, constants.NETWORK_TYPE_OAM)
     address = self.dbapi.address_get_by_name(oam_addr_name)
     oam_url = utils.format_url_address(address.address)
     parameters = {
         'config': {
             'issuer': 'https://%s:30556/dex' % oam_url,
             'redirect_uri': "https://%s:30555/callback" % oam_url,
         }
     }
     self.assertOverridesParameters(overrides, parameters)
Пример #3
0
    def test_issuer(self):
        overrides = self.operator.get_helm_chart_overrides(
            common.HELM_CHART_DEX, cnamespace=common.HELM_NS_KUBE_SYSTEM)

        oam_addr_name = utils.format_address_name(
            constants.CONTROLLER_HOSTNAME, constants.NETWORK_TYPE_OAM)
        oam_address = self.dbapi.address_get_by_name(oam_addr_name)
        config_issuer = "https://%s:30556/dex" % (utils.format_url_address(
            oam_address.address))
        self.assertOverridesParameters(
            overrides,
            {
                # issuer is set properly
                'config': {
                    'issuer': config_issuer
                }
            })
Пример #4
0
 def _format_url_address(address):
     return utils.format_url_address(address)
Пример #5
0
 def _get_cluster_api_endpoint(self):
     endpoint_host = utils.format_url_address(self.oam_subnet[2])
     return "https://{}:6443".format(endpoint_host)