Coder Social home page Coder Social logo

googlecloudplatform / k8s-cloud-provider Goto Github PK

View Code? Open in Web Editor NEW
35.0 21.0 45.0 18.56 MB

Support code for implementing a Kubernetes cloud provider for Google Cloud Platform

License: Apache License 2.0

Go 99.95% Makefile 0.04% Shell 0.02%
k8s kubernetes gcp cloud-provider

k8s-cloud-provider's Introduction

k8s-cloud-provider

This repository contains support files for implementing the Kubernetes cloud provider for the Google Cloud Platform. The code in this repository are the Google Cloud specific portions of the cloud provider logic.

Building

Run make.

Update GCE Go Client

For every update on the GCE API Go client, please remember to push a new tag.

k8s-cloud-provider's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

k8s-cloud-provider's Issues

Mock objects do nothing for Update interface

For example:

// Update is a mock for the corresponding method.
func (m *MockHealthChecks) Update(ctx context.Context, key *meta.Key, arg0 *ga.HealthCheck) error {
	if m.UpdateHook != nil {
		return m.UpdateHook(ctx, key, arg0, m)
	}
	return nil
}

It does nothing if UpdateHook is nil. I would expect it to override what is stored in m.Objects[*key]. Do I miss something?

Report whether the Cloud API is getting rate limited

k8s-cloud-provider supports rate limiting specific APIs.

However, while rate limited, the API caller is blocked. It would be great to report back to the caller whether the API is rate limited or not. For instance:

func (gce *GCE) GetAPIObject(name string) (rateLimited bool, obj APIObject)

This function will just return rateLimited = true and let the caller handle it.

TestFilterToString is Failing

Test fails when running make on master

Output:

--- FAIL: TestFilterToString (0.00s)
    filter_test.go:42: filter &filter.F{predicates:[]filter.filterPredicate{filter.filterPredicate{fieldName:"field1", op:0, s:(*string)(0xc00009a500), i:(*int)(nil), b:(*bool)(nil)}, filter.filterPredicate{fieldName:"field2", op:0, s:(*string)(0xc00009a4f0), i:(*int)(nil), b:(*bool)(nil)}}} String() = "\"(field1 ~ abc) (field2 ~ def)\"", want "(field1 ~ abc) (field2 ~ def)"
    filter_test.go:42: filter &filter.F{predicates:[]filter.filterPredicate{filter.filterPredicate{fieldName:"field1", op:0, s:(*string)(0xc00009a510), i:(*int)(nil), b:(*bool)(nil)}, filter.filterPredicate{fieldName:"field2", op:3, s:(*string)(nil), i:(*int)(0xc0000a60f8), b:(*bool)(nil)}}} String() = "\"(field1 ~ abc) (field2 != 17)\"", want "(field1 ~ abc) (field2 != 17)"
    filter_test.go:42: filter &filter.F{predicates:[]filter.filterPredicate{filter.filterPredicate{fieldName:"field1", op:0, s:(*string)(0xc00009a520), i:(*int)(nil), b:(*bool)(nil)}, filter.filterPredicate{fieldName:"field2", op:2, s:(*string)(nil), i:(*int)(0xc0000a6100), b:(*bool)(nil)}}} String() = "\"(field1 ~ abc) (field2 = 17)\"", want "(field1 ~ abc) (field2 = 17)"
E0506 16:53:36.108929   23308 filter.go:245] Match regexp "a(((" is invalid: error parsing regexp: missing closing ): `a(((`
FAIL

filter.Regexp() Does Not Work As Expected

filter.Regexp() uses eq for regex's when it really should be ~. eq or = only do exact matches and a regex actually won't work here.

https://cloud.google.com/sdk/gcloud/reference/topic/filters

	case regexpEquals:
		// GCE API maps regexp comparison to 'eq'
		op = "eq"

Snippet from filter.go

Since there may be code that relies on this behavior, I think realistically we should some additional functions to support all the other match operators (<, <=, >=, > ~, !~) and deprecate filter.Regexp() and filter.NotRegexp()

Add ability to inject arbitrary logic into API calls

Ideally, the k8s-cloud-provider layer exposes a surface that can be used to configure custom hooks into each API call (similar to how its done for the mocks). These hooks can be executed before or after the API call is completed.

Example use case is for tracking metrics.

Support for go modules and semver

Folks,

we are currently using a "random" looking SHA in kubernetes go.mod/go.sum. Looks like you are using git tags here. Any chance you could go a little bit further and enable go modules/semver?

thanks,
Dims

GCEInstances.List() doesn't retry

We've seen some flakes in our CI due to a 503 response from Google API. Example:

https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/logs/release-openshift-ocp-installer-e2e-gcp-4.4/341#1:build-log.txt%3A15854

Looking deeper in the code, it seems like the 503 response comes from a GCEInstances.List() call (I'm linking the k8s code because GH doesn't open the gen.go file from this repo):

https://github.com/kubernetes/kubernetes/blob/f3df7a2fdb16dd7b00a9d357e337ed48a6f70d45/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/gen.go#L13427-L13440

I noticed that GCEInstances.List() doesn't retry when an error is returned, however, GCEInstances.Insert() does:

https://github.com/kubernetes/kubernetes/blob/f3df7a2fdb16dd7b00a9d357e337ed48a6f70d45/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/gen.go#L13484

I'm sure there's a reason for that, but I was wondering if it'd be possible to make GCEInstances.List() retry as well, just like other methods of GCEInstances.

MIG `listManagedInstances` fails to be added

Description

When we are trying to add listManagedInstances, an error is returned

$ make                                                                                                                                                                                                                                go run pkg/cloud/gen/main.go > pkg/cloud/gen.go
panic: template: interface:34:9: executing "interface" at <.Methods>: error calling Methods: method "InstanceGroupManagers"."ListManagedInstances": paged return type "InstanceGroupManagersListManagedInstancesResponse" does not have a .Items field

goroutine 1 [running]:
main.genTypes({0x2641ba0, 0xc0001103f0})
        /Users/nsilve/IdeaProjects/github/k8s-cloud-provider/pkg/cloud/gen/main.go:1069 +0x187
main.main()
        /Users/nsilve/IdeaProjects/github/k8s-cloud-provider/pkg/cloud/gen/main.go:1447 +0xcc
exit status 2
make: *** [gen] Error 1

because for paged responses an Items field is expected but listManagedInstances returns a managedInstances one.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.