code: func UpdateKubeconfig(tc *client.TeleportClient) error {
  	config, err := LoadKubeConfig()
  	if err != nil {
  		return trace.Wrap(err)
  	}
  
  	clusterName, proxyPort := tc.KubeProxyHostPort()
  	var clusterAddr string
  	if tc.SiteName != "" {
  		// In case of a remote cluster, use SNI subdomain to "point" to a remote cluster name
  		clusterAddr = fmt.Sprintf("https://%v.%v:%v",
  			kubeutils.EncodeClusterName(tc.SiteName), clusterName, proxyPort)
  		clusterName = tc.SiteName
  	} else {
  		clusterAddr = fmt.Sprintf("https://%v:%v", clusterName, proxyPort)
  	}
  
  	creds, err := tc.LocalAgent().GetKey()
  	if err != nil {
  		return trace.Wrap(err)
  	}
  	certAuthorities, err := tc.LocalAgent().GetCertsPEM()
  	if err != nil {
  		return trace.Wrap(err)
  	}
  
  	config.AuthInfos[clusterName] = &clientcmdapi.AuthInfo{
  		ClientCertificateData: creds.TLSCert,
  		ClientKeyData:         creds.Priv,
  	}
  	config.Clusters[clusterName] = &clientcmdapi.Cluster{
  		Server: clusterAddr,
  		CertificateAuthorityData: certAuthorities,
  	}
  
  	lastContext := config.Contexts[clusterName]
  	newContext := &clientcmdapi.Context{
  		Cluster:  clusterName,
  		AuthInfo: clusterName,
  	}
  	if lastContext != nil {
  		newContext.Namespace = lastContext.Namespace
  		newContext.Extensions = lastContext.Extensions
  	}
  	config.Contexts[clusterName] = newContext
  	config.CurrentContext = clusterName
  	return SaveKubeConfig(*config)
  }
docs: // UpdateKubeconfig adds Teleport configuration to kubeconfig.