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

Add support for OpenNebula as a cloud provider #1450

Merged
merged 6 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ examples/*.srl
.vscode
.gitpod.yml
cmd/machine-controller/__debug_bin
!pkg
embik marked this conversation as resolved.
Show resolved Hide resolved
38 changes: 38 additions & 0 deletions docs/cloud-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,44 @@ tags:
tagKey: tagValue
```

## OpenNebula

### machine.spec.providerConfig.cloudProviderSpec

```yaml
# XML-RPC endpoint of your OpenNebula installation
endpoint: ""
# your OpenNebula username
username: ""
# your OpenNebula password
password: ""

# cpu (float64)
cpu: 1
# vcpu
vcpu: 2
# memory in MB
memory: 1024

# the name of the image to use, needs to be owned by the current user
image: "Amazon Linux 2"
# which datastore to use for the image
datastore: ""
# size of the disk in MB
diskSize: 51200

# network name, needs to be owned by the current user
network: ""

# whether to enable the VNC console
enableVNC: true

# optional key/value pairs to add to the VM template
vmTemplateExtra:
# useful for e.g. setting the placement attributes as defined in https://docs.opennebula.io/6.4/management_and_operations/references/template.html#template-placement-section
SCHED_REQUIREMENTS: 'RACK="G4"'
```

## Google Cloud Platform

### machine.spec.providerConfig.cloudProviderSpec
Expand Down
70 changes: 70 additions & 0 deletions examples/opennebula-machinedeployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
apiVersion: v1
kind: Secret
metadata:
# If you change the namespace/name, you must also
# adjust the rbac rules
name: machine-controller-opennebula
namespace: kube-system
type: Opaque
stringData:
password: << ONE_PASSWORD >>
---
apiVersion: "cluster.k8s.io/v1alpha1"
kind: MachineDeployment
metadata:
name: opennebula-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: "opennebula"
cloudProviderSpec:
endpoint: "<< ONE_ENDPOINT including '/RPC2' >>"
username: "<< ONE_USERNAME >>"
# If empty, can be set via ONE_PASSWORD env var
password:
secretKeyRef:
namespace: kube-system
name: machine-controller-opennebula
key: password
cpu: 1
vcpu: 2
memory: 1024

image: "flatcar-stable"
datastore: "<< YOUR_DATASTORE_NAME >>"
diskSize: 51200 # MB

network: "<< YOUR_NETWORK_NAME >>"

enableVNC: true

# if you want to have more control over e.g. placement of the VM you can do this:
#vmTemplateExtra:
# SCHED_REQUIREMENTS: 'RACK="G4"'
operatingSystem: "flatcar"
operatingSystemSpec:
distUpgradeOnBoot: false

# use cloud-init for flatcar as ignition doesn't know anything about OpenNebula yet
provisioningUtility: "cloud-init"
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 @@ -11,6 +11,7 @@ require (
github.com/BurntSushi/toml v1.2.1
github.com/Masterminds/semver/v3 v3.2.0
github.com/Masterminds/sprig/v3 v3.2.3
github.com/OpenNebula/one/src/oca/go/src/goca v0.0.0-20220908162715-b27302cc7db5
github.com/aliyun/alibaba-cloud-sdk-go v1.62.112
github.com/aws/aws-sdk-go-v2 v1.17.3
github.com/aws/aws-sdk-go-v2/config v1.18.7
Expand Down Expand Up @@ -129,6 +130,7 @@ require (
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kolo/xmlrpc v0.0.0-20190717152603-07c4ee3fd181 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/OpenNebula/one/src/oca/go/src/goca v0.0.0-20220908162715-b27302cc7db5 h1:3SAiuS+PAdJHhDlTdnqseo9mZAcolUgDRS1PYEDUaFY=
github.com/OpenNebula/one/src/oca/go/src/goca v0.0.0-20220908162715-b27302cc7db5/go.mod h1:dvAwZi1Aol7eu6BENzHtl8ztGBkacB9t/fJj+fYk+Xg=
github.com/PaesslerAG/gval v1.0.0/go.mod h1:y/nm5yEyTeX6av0OfKJNp9rBNj2XrGhAf5+v24IBN1I=
github.com/PaesslerAG/gval v1.2.1 h1:Ggwtej1xCyt1994VuDCSjycybIDo3duDCDghK/xc/A0=
github.com/PaesslerAG/gval v1.2.1/go.mod h1:XRFLwvmkTEdYziLdaCeCa5ImcGVrfQbeNUbVR+C6xac=
Expand Down Expand Up @@ -396,6 +398,7 @@ github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:Fecb
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
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=
Expand Down Expand Up @@ -454,6 +457,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/kolo/xmlrpc v0.0.0-20190717152603-07c4ee3fd181 h1:TrxPzApUukas24OMMVDUMlCs1XCExJtnGaDEiIAR4oQ=
github.com/kolo/xmlrpc v0.0.0-20190717152603-07c4ee3fd181/go.mod h1:o03bZfuBwAXHetKXuInt4S7omeXUu62/A845kiycsSQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
Expand Down
4 changes: 4 additions & 0 deletions pkg/cloudprovider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/kubermatic/machine-controller/pkg/cloudprovider/provider/kubevirt"
"github.com/kubermatic/machine-controller/pkg/cloudprovider/provider/linode"
"github.com/kubermatic/machine-controller/pkg/cloudprovider/provider/nutanix"
"github.com/kubermatic/machine-controller/pkg/cloudprovider/provider/opennebula"
"github.com/kubermatic/machine-controller/pkg/cloudprovider/provider/openstack"
"github.com/kubermatic/machine-controller/pkg/cloudprovider/provider/scaleway"
vcd "github.com/kubermatic/machine-controller/pkg/cloudprovider/provider/vmwareclouddirector"
Expand Down Expand Up @@ -112,6 +113,9 @@ var (
providerconfigtypes.CloudProviderVMwareCloudDirector: func(cvr *providerconfig.ConfigVarResolver) cloudprovidertypes.Provider {
return vcd.New(cvr)
},
providerconfigtypes.CloudProviderOpenNebula: func(cvr *providerconfig.ConfigVarResolver) cloudprovidertypes.Provider {
return opennebula.New(cvr)
},
}
)

Expand Down
Loading