Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support calling resource methods #354

Open
AaronFriel opened this issue Sep 27, 2022 · 4 comments · May be fixed by #431
Open

Support calling resource methods #354

AaronFriel opened this issue Sep 27, 2022 · 4 comments · May be fixed by #431
Assignees
Labels
kind/enhancement Improvements or new features

Comments

@AaronFriel
Copy link
Member

It is almost possible to call resource methods manually, as in this program which calls the "getKubeconfig" method on cluster:

variables:
  kubeconfig:
    Fn::Invoke:
      Function: google-native:container/v1:Cluster/getKubeconfig
      Arguments:
        __self__: ${someClusterResource}

However, this generates an Invoke, not a Call RPC. The syntax also leaves something to be desired, with the __self__ parameter being an implementation detail that other Pulumi languages do not expose to users.

@AaronFriel AaronFriel added this to the 0.79 milestone Sep 27, 2022
@lukehoban
Copy link
Member

The simplest “raw” thing to do might be to just expose the Call concept directly (much like we do for Invoke today)?

variables:
  kubeconfig:
    Fn::Call:
      Function: google-native:container/v1:Cluster/getKubeconfig
      Self: ${someClusterResource}
      Arguments:
        …

Are there other more “sugar” options worth considering?

@viveklak
Copy link

viveklak commented Sep 27, 2022

Just adding a note that we would also need to add support for the above in docs gen as well: pulumi/pulumi-google-native#709

@justinvp
Copy link
Member

justinvp commented Sep 27, 2022

Are there other more “sugar” options worth considering?

Maybe something like the following, where you only have to specify the resource instance and name of the method?

variables:
  kubeconfig:
    Fn::Method:
      Resource: ${someClusterResource}
      Method: getKubeconfig
      Arguments:
        ...

Or, could we get fancy and grab the method out of an expression?

variables:
  kubeconfig:
    Fn::Method:
      Method: ${someClusterResource.getKubeconfig}
      Arguments:
        ...

@mikhailshilkov mikhailshilkov removed this from the 0.79 milestone Oct 25, 2022
@aq17 aq17 self-assigned this Dec 20, 2022
@aq17 aq17 added this to the 0.82 milestone Dec 20, 2022
@aq17 aq17 linked a pull request Dec 21, 2022 that will close this issue
@lukehoban lukehoban modified the milestones: 0.82, 0.83 Jan 13, 2023
@mikhailshilkov mikhailshilkov modified the milestones: 0.83, 0.84 Jan 27, 2023
@AaronFriel AaronFriel modified the milestones: 0.84, 0.85 Feb 13, 2023
@mikhailshilkov mikhailshilkov modified the milestones: 0.85, 0.87 Apr 3, 2023
@mikhailshilkov mikhailshilkov removed this from the 0.87 milestone Apr 26, 2023
@justinvp justinvp added the kind/enhancement Improvements or new features label Jul 18, 2023
@jaxxstorm
Copy link

For those who stumble across this particularly for GKE, you can work around it by building a kubeconfig variable and referencing that:

name: gke-yaml-cluster
runtime: yaml
description: A GKE cluster
resources:
  cluster:
    type: google-native:container/v1beta1:Cluster
    properties: 
      clusterTelemetry:
        type: ENABLED
      defaultMaxPodsConstraint:
        maxPodsPerNode: 100
      initialNodeCount: 1
      ipAllocationPolicy:
        clusterIpv4CidrBlock: /14
        servicesIpv4CidrBlock: /20
        useRoutes: false
      location: us-west2
      resourceLabels:
        env: lbriggs
  provider:
    type: pulumi:providers:kubernetes
    properties:
      kubeconfig: ${kubeconfig}
  nginx-ingress:
    type: kubernetes:helm.sh/v3:Release
    properties: # The arguments to resource properties.
      chart: "ingress-nginx"
      repositoryOpts:
        repo: https://kubernetes.github.io/ingress-nginx
      cleanupOnFail: true
      createNamespace: true
      description: "Main load balancer"
      lint: true
      name: "ingress-nginx"
      namespace: "ingress-nginx"
      version: "4.7.1"
      values:
        ingressClass: "internet"
    options:
      provider: ${provider}
variables:
  kubeconfig:
    fn::toJSON:
      apiVersion: v1
      clusters:
        - cluster:
            certificate-authority-data: ${cluster.masterAuth.clusterCaCertificate}
            server: https://${cluster.endpoint}
          name: ${cluster.name}
      contexts:
        - context:
            cluster: ${cluster.name}
            user: ${cluster.name}
          name: ${cluster.name}
      current-context: ${cluster.name}
      kind: Config
      users:
        - name: ${cluster.name}
          user:
            exec:
              apiVersion: client.authentication.k8s.io/v1beta1
              command: gke-gcloud-auth-plugin
              installHint: Install gke-gcloud-auth-plugin for use with kubectl by following https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke
              provideClusterInfo: true
outputs:
  kubeconfig: ${kubeconfig}
  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants