Skip to content

Commit a0633dd

Browse files
authored
Merge pull request #345 from oracle/release_0.11.0
Release 0.11.0
2 parents 220ab89 + 136a541 commit a0633dd

File tree

1,279 files changed

+39315
-3049
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,279 files changed

+39315
-3049
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ COPY --from=0 /go/src/github.com/oracle/oci-cloud-controller-manager/image/* /us
3535
RUN yum install -y util-linux \
3636
&& yum install -y e2fsprogs \
3737
&& yum clean all
38+
39+
COPY --from=0 /go/src/github.com/oracle/oci-cloud-controller-manager/dist/* /usr/local/bin/

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ cloud-provider specific code out of the Kubernetes codebase.
2424

2525
| | Kubernetes 1.16 | Kubernetes 1.17 | Kubernetes 1.18 |
2626
|----------|------------------------|------------------------|------------------------|
27-
| <=v 0.7 ||||
28-
| v 0.8 ||||
29-
| v 0.9 ||||
27+
| <=v 0.7 ||||
28+
| \>=v 0.8 ||||
3029

3130
Key:
3231

docs/load-balancer-annotations.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ spec:
2323
| Name | Description | Default |
2424
| ----- | ----------- | ------- |
2525
| `oci-load-balancer-internal` | Create an [internal load balancer][1]. Cannot be modified after load balancer creation. | `false` |
26-
| `oci-load-balancer-shape` | A template that determines the load balancer's total pre-provisioned maximum capacity (bandwidth) for ingress plus egress traffic. Available shapes include `100Mbps`, `400Mbps`, and `8000Mbps.` Cannot be modified after load balancer creation. | `"100Mbps"` |
26+
| `oci-load-balancer-shape` | A template that determines the load balancer's total pre-provisioned capacity (bandwidth) for ingress plus egress traffic. Available shapes include `100Mbps`, `400Mbps`, `8000Mbps` and `flexible`. Use `oci lb shape list` to get the list of shapes supported on your account | `"100Mbps"` |
27+
| `oci-load-balancer-shape-flex-min` | A template that determines the load balancer's minimum pre-provisioned capacity (bandwidth) for ingress plus egress traffic. Only used when `oci-load-balancer-shape` is set to `flexible` | `N/A` |
28+
| `oci-load-balancer-shape-flex-max` | A template that determines the load balancer's maximum pre-provisioned capacity (bandwidth) for ingress plus egress traffic. Only used when `oci-load-balancer-shape` is set to `flexible` | `N/A` |
2729
| `oci-load-balancer-subnet1` | The OCID of the one required regional subnet to attach the load balancer to OR The OCID of the first [subnet][2] of the two required Availability Domain specific subnets to attach the load balancer to. Must be in separate Availability Domains. | Value provided in config file |
2830
| `oci-load-balancer-subnet2` | The OCID of the second [subnet][2] of the two required subnets to attach the load balancer to. Must be in separate Availability Domains. | Value provided in config file |
2931
| `oci-load-balancer-health-check-retries` | The number of retries to attempt before a backend server is considered "unhealthy". | `3` |

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,12 @@ require (
5757
github.com/onsi/ginkgo v1.8.0
5858
github.com/onsi/gomega v1.5.0
5959
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
60-
github.com/oracle/oci-go-sdk v0.0.0-00000000000000-857a54193bc062afe3933d02b38e3fe9d158f744
60+
github.com/oracle/oci-go-sdk/v31 v31.0.0
6161
github.com/pkg/errors v0.8.0
6262
github.com/prometheus/client_golang v0.9.2
6363
github.com/spf13/cobra v0.0.5 // indirect
6464
github.com/spf13/pflag v1.0.3
6565
github.com/spf13/viper v1.3.2
66-
github.com/stretchr/testify v1.4.0 // indirect
6766
go.uber.org/atomic v1.3.2 // indirect
6867
go.uber.org/zap v1.9.1
6968
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ github.com/opencontainers/runtime-spec v1.0.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/
273273
github.com/opencontainers/selinux v0.0.0-20170621221121-4a2974bf1ee9/go.mod h1:+BLncwf63G4dgOzykXAxcmnFlUaOlkDdmw/CqsW6pjs=
274274
github.com/oracle/oci-go-sdk v0.0.0-00000000000000-857a54193bc062afe3933d02b38e3fe9d158f744 h1:AqDL016+OkmPfrT8PkE/tmgLOj+8ljCs+Gktx5ZHtjs=
275275
github.com/oracle/oci-go-sdk v0.0.0-00000000000000-857a54193bc062afe3933d02b38e3fe9d158f744/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
276+
github.com/oracle/oci-go-sdk/v31 v31.0.0 h1:LEstCAlSNcuuPIRUMLuX3UF+V3ID2B1LN4k9Dvbd5tM=
277+
github.com/oracle/oci-go-sdk/v31 v31.0.0/go.mod h1:4MlbGGDlqigjplvUfbVecEqNCN2cYZbdJ8PpAMVAQkw=
276278
github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
277279
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
278280
github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
@@ -338,6 +340,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
338340
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
339341
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
340342
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
343+
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
344+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
341345
github.com/syndtr/gocapability v0.0.0-20160928074757-e7cb7fa329f4/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
342346
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8 h1:ndzgwNDnKIqyCvHTXaCqh9KlOWKvBry6nuXMJmonVsE=
343347
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
@@ -467,6 +471,8 @@ gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa
467471
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
468472
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
469473
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
474+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
475+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
470476
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
471477
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
472478
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

hack/run_e2e_test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function run_e2e_tests_existing_cluster() {
3939
--adlocation=${ADLOCATION} \
4040
--delete-namespace=${DELETE_NAMESPACE} \
4141
--image-pull-repo=${IMAGE_PULL_REPO} \
42+
--cmek-kms-key=${CMEK_KMS_KEY} \
4243
retval=$?
4344
exit $retval
4445
}

pkg/cloudprovider/providers/oci/ccm.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ import (
2222
"io"
2323
"time"
2424

25-
"github.com/oracle/oci-go-sdk/core"
26-
27-
providercfg "github.com/oracle/oci-cloud-controller-manager/pkg/cloudprovider/providers/oci/config"
28-
"github.com/oracle/oci-cloud-controller-manager/pkg/oci/client"
29-
"github.com/oracle/oci-cloud-controller-manager/pkg/oci/instance/metadata"
3025
"github.com/pkg/errors"
3126
"go.uber.org/zap"
3227
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -36,6 +31,12 @@ import (
3631
listersv1 "k8s.io/client-go/listers/core/v1"
3732
"k8s.io/client-go/tools/cache"
3833
cloudprovider "k8s.io/cloud-provider"
34+
35+
providercfg "github.com/oracle/oci-cloud-controller-manager/pkg/cloudprovider/providers/oci/config"
36+
"github.com/oracle/oci-cloud-controller-manager/pkg/metrics"
37+
"github.com/oracle/oci-cloud-controller-manager/pkg/oci/client"
38+
"github.com/oracle/oci-cloud-controller-manager/pkg/oci/instance/metadata"
39+
"github.com/oracle/oci-go-sdk/v31/core"
3940
)
4041

4142
const (
@@ -66,6 +67,7 @@ type CloudProvider struct {
6667

6768
logger *zap.SugaredLogger
6869
instanceCache cache.Store
70+
metricPusher *metrics.MetricPusher
6971
}
7072

7173
// Compile time check that CloudProvider implements the cloudprovider.Interface
@@ -109,11 +111,25 @@ func NewCloudProvider(config *providercfg.Config) (cloudprovider.Interface, erro
109111
config.VCNID = *subnet.VcnId
110112
}
111113

114+
metricPusher, err := metrics.NewMetricPusher(logger.Sugar())
115+
if err != nil {
116+
logger.Sugar().With("error", err).Error("Metrics collection could not be enabled")
117+
// disable metrics
118+
metricPusher = nil
119+
}
120+
121+
if metricPusher != nil {
122+
logger.Info("Metrics collection has been enabled")
123+
} else {
124+
logger.Info("Metrics collection has not been enabled")
125+
}
126+
112127
return &CloudProvider{
113128
client: c,
114129
config: config,
115130
logger: logger.Sugar(),
116131
instanceCache: cache.NewTTLStore(instanceCacheKeyFn, time.Duration(24)*time.Hour),
132+
metricPusher: metricPusher,
117133
}, nil
118134
}
119135

pkg/cloudprovider/providers/oci/config/config.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import (
1919
"io"
2020
"os"
2121

22-
"github.com/oracle/oci-go-sdk/common"
23-
"github.com/oracle/oci-go-sdk/common/auth"
22+
"github.com/oracle/oci-go-sdk/v31/common"
23+
"github.com/oracle/oci-go-sdk/v31/common/auth"
2424
"github.com/pkg/errors"
2525

2626
"go.uber.org/zap"
@@ -103,12 +103,26 @@ type RateLimiterConfig struct {
103103
DisableRateLimiter bool `yaml:"disableRateLimiter"`
104104
}
105105

106+
// MetricsConfig holds the configuration for collection metrics
107+
// which are pushed to OCI Monitoring. More details present at
108+
// https://docs.cloud.oracle.com/en-us/iaas/Content/Monitoring/Tasks/publishingcustommetrics.htm
109+
type MetricsConfig struct {
110+
CompartmentID string `yaml:"compartmentID"`
111+
Namespace string `yaml:"namespace"`
112+
ResourceGroup string `yaml:"resourceGroup"`
113+
// +optional
114+
// This prefix is added to all the metric names
115+
Prefix string `yaml:"prefix"`
116+
}
117+
106118
// Config holds the OCI cloud-provider config passed to Kubernetes components
107119
// via the --cloud-config option.
108120
type Config struct {
109121
Auth AuthConfig `yaml:"auth"`
110122
LoadBalancer *LoadBalancerConfig `yaml:"loadBalancer"`
111123
RateLimiter *RateLimiterConfig `yaml:"rateLimiter"`
124+
// Metrics collection is enabled when this configuration is provided
125+
Metrics *MetricsConfig `yaml:"metrics"`
112126

113127
RegionKey string `yaml:"regionKey"`
114128

pkg/cloudprovider/providers/oci/config/config_validate.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,21 @@ func ValidateConfig(c *Config) field.ErrorList {
8282
if c.LoadBalancer != nil && !c.LoadBalancer.Disabled {
8383
allErrs = append(allErrs, validateLoadBalancerConfig(c, field.NewPath("loadBalancer"))...)
8484
}
85+
86+
// Validate metric config if the metrics block is not empty
87+
if c.Metrics != nil {
88+
if len(c.Metrics.CompartmentID) == 0 {
89+
// The compartment is required for pushing metrics to OCI Monitoring
90+
allErrs = append(allErrs, field.Required(field.NewPath("metrics", "compartment"), "Compartment is required for pushing custom metrics"))
91+
}
92+
93+
if len(c.Metrics.Namespace) == 0 {
94+
allErrs = append(allErrs, field.Required(field.NewPath("metrics", "namespace"), "Metric namespace is required for pushing custom metrics"))
95+
}
96+
97+
if len(c.Metrics.ResourceGroup) == 0 {
98+
allErrs = append(allErrs, field.Required(field.NewPath("metrics", "resourceGroup"), "Metric resource group is required for pushing custom metrics"))
99+
}
100+
}
85101
return allErrs
86102
}

pkg/cloudprovider/providers/oci/config/config_validate_test.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,76 @@ func TestValidateConfig(t *testing.T) {
264264
},
265265
},
266266
},
267+
{
268+
name: "valid config for Auth, LB and metrics",
269+
in: &Config{
270+
metadataSvc: metadata.NewErrorMock(),
271+
Auth: AuthConfig{
272+
metadataSvc: metadata.NewErrorMock(),
273+
Region: "us-phoenix-1",
274+
TenancyID: "ocid1.tenancy.oc1..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
275+
CompartmentID: "ocid1.compartment.oc1..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
276+
UserID: "ocid1.user.oc1..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
277+
PrivateKey: "-----BEGIN RSA PRIVATE KEY----- (etc)",
278+
Fingerprint: "8c:bf:17:7b:5f:e0:7d:13:75:11:d6:39:0d:e2:84:74",
279+
},
280+
LoadBalancer: &LoadBalancerConfig{
281+
Subnet1: "ocid1.tenancy.oc1..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
282+
Subnet2: "ocid1.subnet.oc1.phx.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
283+
},
284+
Metrics: &MetricsConfig{
285+
CompartmentID: "ocid1.compartment.oc1..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
286+
Namespace: "test",
287+
ResourceGroup: "test-rg",
288+
Prefix: "Prefix.",
289+
},
290+
},
291+
errs: field.ErrorList{},
292+
}, {
293+
name: "valid config for Auth, LB and invalid config for metrics",
294+
in: &Config{
295+
metadataSvc: metadata.NewErrorMock(),
296+
Auth: AuthConfig{
297+
metadataSvc: metadata.NewErrorMock(),
298+
Region: "us-phoenix-1",
299+
TenancyID: "ocid1.tenancy.oc1..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
300+
CompartmentID: "ocid1.compartment.oc1..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
301+
UserID: "ocid1.user.oc1..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
302+
PrivateKey: "-----BEGIN RSA PRIVATE KEY----- (etc)",
303+
Fingerprint: "8c:bf:17:7b:5f:e0:7d:13:75:11:d6:39:0d:e2:84:74",
304+
},
305+
LoadBalancer: &LoadBalancerConfig{
306+
Subnet1: "ocid1.tenancy.oc1..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
307+
Subnet2: "ocid1.subnet.oc1.phx.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
308+
},
309+
Metrics: &MetricsConfig{
310+
CompartmentID: "",
311+
Namespace: "",
312+
ResourceGroup: "",
313+
Prefix: "Prefix.",
314+
},
315+
},
316+
errs: field.ErrorList{
317+
&field.Error{
318+
Type: field.ErrorTypeRequired,
319+
Field: "metrics.compartment",
320+
BadValue: "",
321+
Detail: "Compartment is required for pushing custom metrics",
322+
},
323+
&field.Error{
324+
Type: field.ErrorTypeRequired,
325+
Field: "metrics.namespace",
326+
BadValue: "",
327+
Detail: "Metric namespace is required for pushing custom metrics",
328+
},
329+
&field.Error{
330+
Type: field.ErrorTypeRequired,
331+
Field: "metrics.resourceGroup",
332+
BadValue: "",
333+
Detail: "Metric resource group is required for pushing custom metrics",
334+
},
335+
},
336+
},
267337
}
268338

269339
for _, tt := range testCases {

pkg/cloudprovider/providers/oci/instances.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"fmt"
2020
"net"
2121

22-
"github.com/oracle/oci-go-sdk/core"
22+
"github.com/oracle/oci-go-sdk/v31/core"
2323
"k8s.io/apimachinery/pkg/labels"
2424

2525
"github.com/oracle/oci-cloud-controller-manager/pkg/oci/client"
@@ -162,7 +162,7 @@ func (cp *CloudProvider) InstanceID(ctx context.Context, nodeName types.NodeName
162162
name := mapNodeNameToInstanceName(nodeName)
163163
compartmentID, err := cp.getCompartmentIDByNodeName(name)
164164
if err != nil {
165-
if cp.config.CompartmentID != "" {
165+
if cp.config.CompartmentID != "" {
166166
compartmentID = cp.config.CompartmentID
167167
} else {
168168
return "", errors.Wrap(err, "error getting CompartmentID from Node Name")

0 commit comments

Comments
 (0)