The Runpod Pulumi provider provides resources to interact with Runpod's native APIs.
Project description
title: Runpod meta_desc: Provides an overview of the Runpod Provider for Pulumi. layout: package
The Runpod provider for Pulumi can be used to provision Runpod resources. The Runpod provider must be configured with Runpod's API keys to deploy and update resources in Runpod.
Pulumi guide
Create an empty directory and navigate inside
mkdir -p empty
cd empty
Create a new pulumi stack:
pulumi new
A dropdown box will appear. Please select a minimal project from in there. For example, if you prefer using Go, you would select the following:
go A minimal Go Pulumi program
Then populate the entrypoint file (main.py/main.go/index.ts) with the your data. Please use the guide below to understand more about what parameters are possible for each resource. For Python, please remember to activate the virtual environment.
Config
To begin with, please set your runpod API key to use with Pulumi.
pulumi config set --secret runpod:token
Example
This is an example of how to deploy it over Golang. We also serve pulumi over Typescript and Python. For more examples, please navigate to the examples directory or the docs/installation-configuration.md file. If you have any problems in doing so, please contact support@runpod.io.
- Create a new Pulumi Go example:
pulumi new
Select either the Go template or Runpod's Go template.
-
Set your API keys using the process shown above.
-
Install the official Go package:
go get github.com/runpod/pulumi-runpod-native/sdk/go/runpod@v1.9.98
Replace the version above to any that you want. We advise you to pin a certain version as there will be fewer breaking changes.
- Use this example as a simple building guide for your example project:
package main
import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/runpod/pulumi-runpod-native/sdk/go/runpod"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
testNetworkStorage, err := runpod.NewNetworkStorage(ctx, "testNetworkStorage", &runpod.NetworkStorageArgs{
Name: pulumi.String("testStorage1"),
Size: pulumi.Int(5),
DataCenterId: pulumi.String("EU-RO-1"),
})
if err != nil {
return err
}
myRandomPod, err := runpod.NewPod(ctx, "myRandomPod", &runpod.PodArgs{
CloudType: pulumi.String("ALL"),
NetworkVolumeId: testNetworkStorage.NetworkStorage.ApplyT(func(networkStorage runpod.NetworkStorageType) (*string, error) {
return &networkStorage.Id, nil
}).(pulumi.StringPtrOutput),
GpuCount: pulumi.Int(1),
VolumeInGb: pulumi.Int(50),
ContainerDiskInGb: pulumi.Int(50),
MinVcpuCount: pulumi.Int(2),
MinMemoryInGb: pulumi.Int(15),
GpuTypeId: pulumi.String("NVIDIA GeForce RTX 4090"),
Name: pulumi.String("RunPod Pytorch"),
ImageName: pulumi.String("runpod/pytorch"),
DockerArgs: pulumi.String(""),
Ports: pulumi.String("8888/http"),
VolumeMountPath: pulumi.String("/workspace"),
Env: runpod.PodEnvArray{
&runpod.PodEnvArgs{
Key: pulumi.String("JUPYTER_PASSWORD"),
Value: pulumi.String("rns1hunbsstltcpad22d"),
},
},
})
if err != nil {
return err
}
myTemplate, err := runpod.NewTemplate(ctx, "myTemplate", &runpod.TemplateArgs{
ContainerDiskInGb: pulumi.Int(5),
DockerArgs: pulumi.String("python3 -m http.server 8080"),
Env: runpod.PodEnvArray{
&runpod.PodEnvArgs{
Key: pulumi.String("JUPYTER_PASSWORD"),
Value: pulumi.String("rns1hunbsstltcpad22d"),
},
},
ImageName: pulumi.String("runpod/serverless-hello-world:latest"),
IsServerless: pulumi.Bool(true),
Name: pulumi.String("Testing Pulumi V1"),
Readme: pulumi.String("## Hello, World!"),
VolumeInGb: pulumi.Int(0),
})
if err != nil {
return err
}
myEndpoint, err := runpod.NewEndpoint(ctx, "myEndpoint", &runpod.EndpointArgs{
GpuIds: pulumi.String("AMPERE_16"),
Name: pulumi.String("Pulumi Endpoint Test V2 -fb"),
TemplateId: myTemplate.Template.Id(),
WorkersMax: pulumi.Int(2),
WorkersMin: pulumi.Int(1),
IdleTimeout: pulumi.Int(6),
Locations: pulumi.String("EU-RO-1"),
NetworkVolumeId: testNetworkStorage.NetworkStorage.Id(),
ScalerType: pulumi.String("QUEUE_DELAY"),
ScalerValue: pulumi.Int(4),
})
if err != nil {
return err
}
ctx.Export("pod", myRandomPod.Pod.Id())
ctx.Export("networkStorage", testNetworkStorage.NetworkStorage.Id())
ctx.Export("template", myTemplate.Template.Id())
ctx.Export("endpoint", myEndpoint.Endpoint.Id())
return nil
})
}
- PULUMI UP Create your resources using the command below:
pulumi up
- PULUMI DOWN If you want to remove your resources, you can use the command below:
pulumi down
If you have any issues, please feel free to create an issue or reach out to us directly at support@runpod.io.
Note: For examples in TypeScript and Python, please visit the documentation inside the docs directory or click here.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file runpodinfra-1.9.99.tar.gz
.
File metadata
- Download URL: runpodinfra-1.9.99.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4561fbd9432c3d6256f47fb3ba09f25a86f792ee09696c304505291b6bac0e21 |
|
MD5 | 134267545f34f2c062cdd32d950017ec |
|
BLAKE2b-256 | 762ac42bdfd8c0e83ad3e80607fccdc6a302a7c478655583092370508117841d |