<p>I'm evaluating crossplane to use as our go to tool to deploy our clients different solutions and have struggled with one issue:</p>
<p>We want to install crossplane to one cluster on GCP (which we create manually) and use that crossplane to provision new cluster on which we can install helm charts and deploy as usual.
The main problem so far is that we haven't figured out how to tell crossplane to install the helm charts into other clusters than itself.</p>
<p>This is what we have tried so for:</p>
<p>The provider-config in the example:</p>
<pre><code>apiVersion: helm.crossplane.io/v1beta1
kind: ProviderConfig
metadata:
  name: helm-provider
spec:
  credentials:
    source: InjectedIdentity
</code></pre>
<p>...which works but installs everything into the same cluster as crossplane.</p>
<p>and the other example:</p>
<pre><code>apiVersion: helm.crossplane.io/v1beta1
kind: ProviderConfig
metadata:
  name: default
spec:
  credentials:
    source: Secret
    secretRef:
      name: cluster-credentials
      namespace: crossplane-system
      key: kubeconfig
</code></pre>
<p>...which required a lot of makefile scripting to easier generate a kubeconfig for the new cluster and with that kubecoinfig still gives a lot of errors (but does begin to create something in the new cluster, but it doesnt work all the way. Gettings errors like: <strong>&quot; PodUnschedulable Cannot schedule pods: gvisor}</strong>).</p>
<p>I have only tried crossplane for a couple of days so I'm aware that I might be approaching this from a completely wrong angle but I do like the promise of crossplane and its approach compared to Terraform and alike.</p>
<p>So the question is: I'm thinking completely wrong or I'm missing something obvious.
The second test with the kubeconfig feels quite complicated right now (many steps in correct order to achieve it).</p>
<p>Thanks</p>

camme
<p>As you've noticed, <code>ProviderConfig</code> with <code>InjectedIdentity</code> is for the case where <code>provider-helm</code> installs the helm release into the same cluster.</p>
<p>To deploy to other clusters, provider-helm needs a <code>kubeconfig</code> file of the remote cluster which needs to be provided as a Kubernetes secret and referenced from <code>ProviderConfig</code>. So, as long as you've provided a <strong>proper</strong> <code>kubeconfig</code> to an external cluster that is <strong>accessible</strong> from your Crossplane cluster (a.k.a. control plane), provider-helm should be able to deploy the release to the remote cluster.</p>
<p>So, it looks like you're on the right track regarding configuring provider-helm, and since you observed something getting deployed to the external cluster, you provided a valid <code>kubeconfig</code>, and provider-helm could access and authenticate to the cluster.</p>
<p><em>The last error you're getting sounds like some incompatibility between your cluster and release</em>, e.g. the external cluster only allows pods with <code>gvisor</code> and the application that you want to install with provider helm does not have some labels accordingly.</p>
<p>As a troubleshooting step, you might try installing that helm chart with exactly same configuration to the external cluster via helm cli, using the same kubeconfig you built.</p>
<p>Regarding the inconvenience of building the Kubeconfig you mentioned, provider-helm needs a way to access to that external Kubernetes cluster, and since <code>kubeconfig</code> is the most common way for this purpose. However, if you see another alternative that makes things easier for some common use cases, this could be implemented and it would be great if you could create a feature request in the repo for this.</p>
<p>Finally, I am wondering how you're creating those external clusters. If it makes sense to create them with Crossplane as well, e.g. if GKE with provider-gcp, then, you can <a href="https://crossplane.io/docs/v1.4/concepts/terminology.html#composition" rel="noreferrer">compose</a> a helm <code>ProviderConfig</code> together with a GKE Cluster resource which would just create the appropriate secret and <code>ProviderConfig</code> when you create a new cluster, you can check this as an example: <a href="https://github.com/crossplane-contrib/provider-helm/blob/master/examples/in-composition/composition.yaml#L147" rel="noreferrer">https://github.com/crossplane-contrib/provider-helm/blob/master/examples/in-composition/composition.yaml#L147</a></p>
