<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def network_kubernetes_from_context( reactor, context=None, path=None, environ=None, default_config_path=FilePath(expanduser(u"~/.kube/config")), ):
 """ Create a new ``IKubernetes`` provider based on a kube config file. :param reactor: A Twisted reactor which will be used for I/O and scheduling. :param unicode context: The name of the kube config context from which to load configuration details. Or, ``None`` to respect the current context setting from the configuration. :param FilePath path: The location of the kube config file to use. :param dict environ: A environment direction in which to look up ``KUBECONFIG``. If ``None``, the real process environment will be inspected. This is used only if ``path`` is ``None``. :return IKubernetes: The Kubernetes service described by the named context. """

    if path is None:
        if environ is None:
            from os import environ
        try:
            kubeconfigs = environ[u"KUBECONFIG"]
        except KeyError:
            config = KubeConfig.from_file(default_config_path.path)
        else:
            config = _merge_configs_from_env(kubeconfigs)
    else:
        config = KubeConfig.from_file(path.path)

    if context is None:
        context = config.doc[u"current-context"]

    context = config.contexts[context]
    cluster = config.clusters[context[u"cluster"]]
    user = config.users[context[u"user"]]

    if isinstance(cluster[u"server"], bytes):
        base_url = URL.fromText(cluster[u"server"].decode("ascii"))
    else:
        base_url = URL.fromText(cluster[u"server"])
    [ca_cert] = parse(cluster[u"certificate-authority"].bytes())

    client_chain = parse(user[u"client-certificate"].bytes())
    [client_key] = parse(user[u"client-key"].bytes())

    agent = authenticate_with_certificate_chain(
        reactor, base_url, client_chain, client_key, ca_cert,
    )

    return network_kubernetes(
        base_url=base_url,
        agent=agent,
    )