Skip to content

Commit

Permalink
Add basic support for vultr cloud provider
Browse files Browse the repository at this point in the history
Signed-off-by: Yakul Garg <2000yeshu@gmail.com>
  • Loading branch information
2000yeshu committed Feb 16, 2023
1 parent 2ff7ea4 commit 0f828b9
Show file tree
Hide file tree
Showing 11 changed files with 535 additions and 0 deletions.
1 change: 1 addition & 0 deletions .wwhrd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ exceptions:
- github.com/ajeddeloh/go-json # Since it's a fork, https://github.com/golang/go/blob/master/LICENSE
- github.com/hashicorp/go-version # MPL-2.0
- github.com/hashicorp/go-cleanhttp # MPL-2.0
- github.com/hashicorp/go-retryablehttp # MPL-2.0
9 changes: 9 additions & 0 deletions docs/cloud-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,12 @@ memory: "2048M"
## vSphere

Refer to the [VSphere](./vsphere.md#provider-configuration) specific documentation.

## Vultr

### machine.spec.providerConfig.cloudProviderSpec
```yaml
apiKey: "<< VULTR_API_KEY >>"
plan: "vhf-8c-32gb"
region: ""
osId: 127
60 changes: 60 additions & 0 deletions examples/vultr-machinedeployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
apiVersion: v1
kind: Secret
metadata:
# If you change the namespace/name, you must also
# adjust the rbac rules
name: machine-controller-vultr
namespace: kube-system
type: Opaque
stringData:
apiKey: << VULTR_API_KEY >>
---
apiVersion: "cluster.k8s.io/v1alpha1"
kind: MachineDeployment
metadata:
name: vultr-machinedeployment
namespace: kube-system
spec:
paused: false
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
minReadySeconds: 0
selector:
matchLabels:
foo: bar
template:
metadata:
labels:
foo: bar
spec:
providerSpec:
value:
sshPublicKeys:
- "<< YOUR_PUBLIC_KEY >>"
cloudProvider: "vultr"
cloudProviderSpec:
# Can also be set via the env var 'VULTR_API_KEY' on the machine-controller
apiKey:
secretKeyRef:
namespace: kube-system
name: machine-controller-vultr
key: apiKey
region: blr
plan: 'vhf-8c-32gb'
# Required: app_id, image_id, os_id, snapshot_id, or iso_id must be provided. Currently only os_id is supported.
osId: 215
# Optional
tags:
- tag1
- tag2
- tag3
operatingSystem: "ubuntu"
operatingSystemSpec:
distUpgradeOnBoot: false
disableAutoUpdate: true
versions:
kubelet: 1.24.9
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ require (
github.com/tinkerbell/tink v0.8.0
github.com/vmware/go-vcloud-director/v2 v2.18.0
github.com/vmware/govmomi v0.30.0
github.com/vultr/govultr/v2 v2.17.2
go.anx.io/go-anxcloud v0.5.0
golang.org/x/crypto v0.4.0
golang.org/x/oauth2 v0.3.0
Expand Down Expand Up @@ -118,6 +119,7 @@ require (
github.com/googleapis/enterprise-certificate-proxy v0.2.1 // indirect
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI=
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0=
github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
Expand Down Expand Up @@ -678,6 +682,8 @@ github.com/vmware/go-vcloud-director/v2 v2.18.0 h1:3kXfaLyYObVBn7SsGxPPiIcqogwnH
github.com/vmware/go-vcloud-director/v2 v2.18.0/go.mod h1:KjnB8t5l1bRrc+jLKDJbx0vZLRzz2RPzNQ7xzg7yI3o=
github.com/vmware/govmomi v0.30.0 h1:Fm8ugPnnlMSTSceDKY9goGvjmqc6eQLPUSUeNXdpeXA=
github.com/vmware/govmomi v0.30.0/go.mod h1:F7adsVewLNHsW/IIm7ziFURaXDaHEwcc+ym4r3INMdY=
github.com/vultr/govultr/v2 v2.17.2 h1:gej/rwr91Puc/tgh+j33p/BLR16UrIPnSr+AIwYWZQs=
github.com/vultr/govultr/v2 v2.17.2/go.mod h1:ZFOKGWmgjytfyjeyAdhQlSWwTjh2ig+X49cAp50dzXI=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
Expand Down
4 changes: 4 additions & 0 deletions pkg/cloudprovider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/kubermatic/machine-controller/pkg/cloudprovider/provider/scaleway"
vcd "github.com/kubermatic/machine-controller/pkg/cloudprovider/provider/vmwareclouddirector"
"github.com/kubermatic/machine-controller/pkg/cloudprovider/provider/vsphere"
"github.com/kubermatic/machine-controller/pkg/cloudprovider/provider/vultr"
cloudprovidertypes "github.com/kubermatic/machine-controller/pkg/cloudprovider/types"
"github.com/kubermatic/machine-controller/pkg/providerconfig"
providerconfigtypes "github.com/kubermatic/machine-controller/pkg/providerconfig/types"
Expand Down Expand Up @@ -76,6 +77,9 @@ var (
providerconfigtypes.CloudProviderEquinixMetal: func(cvr *providerconfig.ConfigVarResolver) cloudprovidertypes.Provider {
return equinixmetal.New(cvr)
},
providerconfigtypes.CloudProviderVultr: func(cvr *providerconfig.ConfigVarResolver) cloudprovidertypes.Provider {
return vultr.New(cvr)
},
// NB: This is explicitly left to allow old Packet machines to be deleted.
// We can handle those machines in the same way as Equinix Metal machines
// because there are no API changes.
Expand Down
Loading

0 comments on commit 0f828b9

Please sign in to comment.