Run code-generation pipeline - you need to do this everytime you change the linode-terraform-provider version, to update CRDs
make generateRun against a Kubernetes cluster:
export KUBECONFIG=<kubeconfig>
make runBuild, push, and install:
make allBuild binary:
make build- Find the resource (not data source) that was added in Terraform Provider for Linode. Newer resources are usually implemented through the
frameworkplugin, and you can find them inlinode/framework_provider.gounderResources. Older resources may be implemented withSDKv2. - In this repo, add the name of the provider to the appropriate list in
config/externalname.go. Ifframeworkbased, this will be in theterraformPluginFrameworkExternalNameConfigslist; make sure there is a 1:1 mapping with the list fromlinode/framework_provider.go. - Create a directory for the new resource group in
config/. - Add a file
config.goimplementing theConfiguremethod (see config/vpc/config.go for an example). The minimum change needed is overriding theShortGroup. - Add the configure method to the loop at
config/provider.go:GetProvider()method. - Change the terraform provider version in the
Makefileand thego.modfile. - Run
make submodulesandmake generate. - Check the new CRDs created in
examples-generated/. If you need to make any changes, go back to step 4 and edit the config, thenmake generateagain. - Run
make local-deploy. This will create a Kind cluster set up with Crossplane and Provider Linode. - Create a ProviderConfig and a secret with your Linode API token
apiVersion: linode.upbound.io/v1beta1
kind: ProviderConfig
metadata:
name: default
spec:
credentials:
source: Secret
secretRef:
name: linode-api-token
namespace: default
key: credentials
The Linode API token secret needs to be in the form echo '{"token": "$LINODE_API_TOKEN", "api_version": "v4beta"}' | base64. Take that value and input it here:
apiVersion: v1
data:
credentials: PUT THE SECRET HERE
kind: Secret
metadata:
name: linode-api-token
namespace: default
type: Opaque
- Create a manifest for your resource, or use the generated example depending on what you are testing.
k applythe new resource, the ProviderConfig, and the linode API token secret. Test that it works!
-
Review the terraform-provider-linode release notes, and verify if there are is any migration from sdk->plugin framework. k ge a. If there's a migration, update the list in
config/externalname.gob. If there's a new resource follow steps under Add a new resource -
Change
TERRAFORM_PROVIDER_VERSIONin makefile -
Change
github.com/linode/terraform-provider-linode/v2in go.mod -
Run
go mod tidy -
Run
make generate -
Test changes locally with
make local-deploy- create a manifest for your resource and test that it works.
make controlplane.up- will start a kind cluster with everything neededmake generateto generate crd's and other generated codek apply -f package/crdsto install CRDs- use
make debugto run the provider locally
- Create an account on the upbound marketplace
- Install UP from - https://docs.upbound.io/reference/cli/#homebrew
- login to the account using
up login(if you're already logged in, logout first) - Create a repo if you don't have one
up repository create provider-linode - run
make build - run
make xpkg.build - run
up xpkg push <username>/<repo_name>:<version> -f <path to built xpkg>
up xpkg push tchinmai7/provider-linode:v0.0.1 -f _output/xpkg/linux_amd64/provider-linode-v0.0.0-130.g7bacec4.xpkgthe version HAS to be a semver 8. modify your provider package to use this version instead.