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

Oracle Cloud Infrastructure (OCI) Provider #2367

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ ADD --chmod=644 ./configs/azure.json /models/azure.json
ADD --chmod=644 ./configs/aws.json /models/aws.json
ADD --chmod=644 ./configs/gcp.json /models/gcp.json
ADD --chmod=644 ./configs/alibaba.json /models/alibaba.json
ADD --chmod=644 ./configs/oracle.json /models/oracle.json
USER 1001
ENTRYPOINT ["/go/bin/app"]
1 change: 1 addition & 0 deletions Dockerfile.cross
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ADD --chmod=644 ./configs/azure.json /models/azure.json
ADD --chmod=644 ./configs/aws.json /models/aws.json
ADD --chmod=644 ./configs/gcp.json /models/gcp.json
ADD --chmod=644 ./configs/alibaba.json /models/alibaba.json
ADD --chmod=644 ./configs/oracle.json /models/oracle.json

COPY ${binarypath} /go/bin/app

Expand Down
9 changes: 9 additions & 0 deletions configs/oracle.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"provider":"Oracle",
"CPU": "0.015",
"RAM": "0.002",
"GPU": "2.00",
"storage": "0.00005479452",
"defaultLBPrice": "0.0113",
"internetNetworkEgress": "0.0085"
}
5 changes: 5 additions & 0 deletions core/pkg/opencost/assetprops.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ const CustomProvider = "custom"
// ScalewayProvider describes the provider Scaleway
const ScalewayProvider = "Scaleway"

// OracleProvider describes the provider Oracle
const OracleProvider = "Oracle"

// NilProvider describes unknown provider
const NilProvider = "-"

Expand All @@ -202,6 +205,8 @@ func ParseProvider(str string) string {
return AzureProvider
case "scaleway", "scw", "kapsule":
return ScalewayProvider
case "oci", "oracle":
return OracleProvider
default:
return NilProvider
}
Expand Down
72 changes: 72 additions & 0 deletions pkg/cloud/oracle/key.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package oracle

import (
"fmt"

"github.com/opencost/opencost/core/pkg/util"
)

type oracleKey struct {
gpuCount int
gpuType string
providerID string
instanceType string
labels map[string]string
}

func (k *oracleKey) ID() string {
return k.providerID
}

// Features are the OCI node features: compute, memory, and optionally gpu.
func (k *oracleKey) Features() string {
arch, ok := util.GetArchType(k.labels)
if !ok {
arch = "amd64"
}
return fmt.Sprintf("%s,%t,%s", k.instanceType, k.isVirtualNode(), arch)
}

func (k *oracleKey) GPUType() string {
return k.gpuType
}

func (k *oracleKey) GPUCount() int {
return k.gpuCount
}

func (k *oracleKey) isVirtualNode() bool {
_, ok := k.labels[virtualNodeLabel]
return ok
}

const driverOCI = "oracle.com/oci"
const driverOCIBV = "blockvolume.csi.oraclecloud.com"

// ociStorageDrivers are the known storage drivers for OCI.
var ociStorageDrivers = map[string]bool{
driverOCI: true,
driverOCIBV: true,
}

type oraclePVKey struct {
storageClass string
driver string
providerID string
parameters map[string]string
}

func (p *oraclePVKey) Features() string {
if ociStorageDrivers[p.driver] {
return blockVolumePartNumber
}
return ""
}

func (p *oraclePVKey) GetStorageClass() string {
return p.storageClass
}

func (p *oraclePVKey) ID() string {
return p.providerID
}