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

feat: add support for Equinix Metal Load Balancer #470

Merged
merged 48 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0fb7d72
feat: Iniitial Create of EMLB
cprivitere Sep 25, 2023
f178e49
define an Equinix Metal Load Balancer client and initialize it
ctreatma Sep 26, 2023
42faf22
chore: standardize markdown
cprivitere Sep 26, 2023
2fa2f7f
chore: tabs to spaces
cprivitere Sep 26, 2023
e3af08d
chore: formatting remove line
cprivitere Sep 26, 2023
248a36c
feat: parse config for new emlb lbs
cprivitere Sep 26, 2023
1aef0da
exchange Metal API key for LB OAuth tokenbefore making LB API requests
ctreatma Sep 27, 2023
f2bbcf0
add map of known locations
ctreatma Sep 28, 2023
1182dde
scaffold out the LBaaS integration
ctreatma Sep 28, 2023
15c1de1
add more detailed implementation outline in comments
ctreatma Sep 28, 2023
69fd1a9
pass in API key and project ID for EMLB
ctreatma Sep 28, 2023
9d7d97f
fix: MapKeys() not Keys()
cprivitere Sep 28, 2023
e53c43f
feat: support tilt based development
cprivitere Sep 28, 2023
c08e63c
fix: get off experimental builder
cprivitere Sep 28, 2023
1c80d87
refactor: introduce usesBGP flag for loadbalancers
ctreatma Oct 2, 2023
24b62b0
feat: move example dev files to dev/
cprivitere Oct 2, 2023
978e07b
fix: ignore dev directory for rebuilds
cprivitere Oct 3, 2023
322373c
feat: create an Equinix Metal Load Balancer for a k8s service
ctreatma Oct 3, 2023
716c3ef
return actual service status for non-BGP load balancers
ctreatma Oct 3, 2023
abd52f3
set LoadBalancerIP for backwards compatibility
ctreatma Oct 3, 2023
4456f42
fix: various updates and comments
cprivitere Oct 3, 2023
b44bae8
fix: ensure LoadBalancer is implemented
cprivitere Oct 3, 2023
0fe57f0
fix: use front end port
cprivitere Oct 3, 2023
20e73f5
fix: don't call this controller
cprivitere Oct 3, 2023
e62ed27
fix: don't call this controller
cprivitere Oct 3, 2023
9a9185f
chore: refactor infrastructure management code
ctreatma Oct 4, 2023
5a5df10
fix: handle multiple ports for a service
ctreatma Oct 5, 2023
7e80f12
fix: use a consistent load balancer name
ctreatma Oct 6, 2023
f9ede3e
fix: commit svc updates
cprivitere Oct 6, 2023
b5b86cf
fix: if service already has a load balancer ID, don't create a new one
ctreatma Oct 6, 2023
21328f0
feat: add code for deletes
cprivitere Oct 9, 2023
937350f
feat: add interface function so deletes work
cprivitere Oct 9, 2023
3b137ee
refactor: defer implementation of GetLoadBalancer to EMLB
ctreatma Oct 10, 2023
adcfa00
fix: delete pools when load balancer is deleted
ctreatma Oct 10, 2023
a442432
fix: patch service object instead of updating
ctreatma Oct 10, 2023
590d80b
feat: report status correctly for new LB
cprivitere Oct 11, 2023
d4507a3
Wire up UpdateService for EMLB
ctreatma Oct 11, 2023
d35cae5
change ID properties to strings
ctreatma Oct 12, 2023
279d0fa
fix: actually delete old resources when updating a service
ctreatma Oct 13, 2023
540c751
chore: bump go mods and version
cprivitere Oct 13, 2023
d7eb273
fix: support latest k8s code new flags
cprivitere Oct 13, 2023
bac1e6c
fix: Tiltfile support new cpem controller name
cprivitere Oct 13, 2023
7f2cfe6
fix: revert k8s and metallb updates
cprivitere Oct 13, 2023
69c4c2a
fix: remove cloud-sa.json from root
cprivitere Oct 17, 2023
36cf224
chore: refactor manager to replace add/update functions with reconcile
ctreatma Oct 20, 2023
e81f2c1
feat: add control plane load balancing with LBaaS
ctreatma Oct 23, 2023
2a3dc23
chore: address lint failures
ctreatma Oct 24, 2023
8a048dc
docs: update README with EMLB support and config
ctreatma Oct 24, 2023
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ vendor/
hacks/
tmp/
.idea
/cloud-sa.json
/Tiltfile
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1.1-experimental
# syntax=docker/dockerfile:1

# Copyright 2020 The Kubernetes Authors.
#
Expand All @@ -15,7 +15,7 @@
# limitations under the License.

# Build the manager binary
ARG GOVER=1.19
ARG GOVER=1.21
FROM --platform=$BUILDPLATFORM golang:${GOVER} as builder

ARG TARGETPLATFORM
Expand Down
366 changes: 198 additions & 168 deletions README.md

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions dev/Tiltfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Specify the registry you wish to store the image in
registry = 'YOUR_REGISTRY_HERE'

# List the k8s context you wish to run this in
allow_k8s_contexts('YOUR_K8S_CONTEXT_HERE')

# Specify docker registry you wish to store image in
docker_build(registry + '/cloud-provider-equinix-metal',
context='.',
dockerfile='./Dockerfile',
ignore=['cloud-sa.json','dev/'],
)

# read in the yaml file and replace the image name with the one we built
deployment = read_yaml_stream('deploy/template/deployment.yaml')
deployment[0]['spec']['template']['spec']['containers'][0]['image'] = registry + '/cloud-provider-equinix-metal'
deployment[0]['spec']['template']['spec']['containers'][0]['env']=[]
deployment[0]['spec']['template']['spec']['containers'][0]['env'].append({"name": "METAL_METRO_NAME","value":"YOUR_METRO_HERE"})
deployment[0]['spec']['template']['spec']['containers'][0]['env'].append({"name": "METAL_LOAD_BALANCER","value":"YOUR_LOAD_BALANCER_HERE"})
k8s_yaml(encode_yaml_stream(deployment))
k8s_resource(workload='cloud-provider-equinix-metal',objects=['cloud-provider-equinix-metal:ServiceAccount:kube-system','cloud-provider-equinix-metal:ClusterRole:default','cloud-provider-equinix-metal:ClusterRoleBinding:default'])
k8s_resource(new_name='metal-cloud-config',objects=['metal-cloud-config:Secret:kube-system'])

# Load the secret extension
load('ext://secret', 'secret_create_generic')

# Create the cloud-provider-equinix-metal secret based on the contents of the
# file named cloud-sa.json put the apiKey and projectID in it
# The file should look like this:
# {
# "apiKey":"YOUR_API_KEY",
# "projectID":"YOUR_PROJECT_ID"
# }
secret_create_generic(
'metal-cloud-config',
'kube-system',
from_file='cloud-sa.json=./cloud-sa.json'
)
4 changes: 4 additions & 0 deletions dev/cloud-sa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"apiKey":"YOUR_API_KEY",
"projectID": "YOUR_PROJECT_ID"
}
36 changes: 36 additions & 0 deletions dev/web-updated.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: v1
kind: Service
metadata:
name: web
labels:
app: web
spec:
ports:
- port: 8100
targetPort: 80
name: web
selector:
app: web
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
labels:
app: web
spec:
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: dockersamples/wordsmith-web
ports:
- containerPort: 80
name: web
36 changes: 36 additions & 0 deletions dev/web-updated2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: v1
kind: Service
metadata:
name: webby
labels:
app: web
spec:
ports:
- port: 8200
targetPort: 80
name: web
selector:
app: web
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
labels:
app: web
spec:
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: dockersamples/wordsmith-web
ports:
- containerPort: 80
name: web
36 changes: 36 additions & 0 deletions dev/web.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: v1
kind: Service
metadata:
name: web
labels:
app: web
spec:
ports:
- port: 8080
targetPort: 80
name: web
selector:
app: web
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
labels:
app: web
spec:
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: dockersamples/wordsmith-web
ports:
- containerPort: 80
name: web
55 changes: 55 additions & 0 deletions dev/words.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
CREATE TABLE nouns (word TEXT NOT NULL);
CREATE TABLE verbs (word TEXT NOT NULL);
CREATE TABLE adjectives (word TEXT NOT NULL);

INSERT INTO nouns(word) VALUES
('cloud'),
('elephant'),
('gø language'),
('laptøp'),
('cøntainer'),
('micrø-service'),
('turtle'),
('whale'),
('gøpher'),
('møby døck'),
('server'),
('bicycle'),
('viking'),
('mermaid'),
('fjørd'),
('legø'),
('flødebolle'),
('smørrebrød');

INSERT INTO verbs(word) VALUES
('will drink'),
('smashes'),
('smøkes'),
('eats'),
('walks tøwards'),
('løves'),
('helps'),
('pushes'),
('debugs'),
('invites'),
('hides'),
('will ship');

INSERT INTO adjectives(word) VALUES
('the exquisite'),
('a pink'),
('the røtten'),
('a red'),
('the serverless'),
('a brøken'),
('a shiny'),
('the pretty'),
('the impressive'),
('an awesøme'),
('the famøus'),
('a gigantic'),
('the gløriøus'),
('the nørdic'),
('the welcøming'),
('the deliciøus');
34 changes: 34 additions & 0 deletions dev/wordsmith-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: minimal-ingress
annotations:
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: websvc
port:
number: 8080
---
apiVersion: v1
kind: Service
metadata:
name: websvc
labels:
app: web
spec:
ports:
- port: 8080
targetPort: 80
name: web
selector:
app: web
type: ClusterIP
43 changes: 22 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
module github.com/equinix/cloud-provider-equinix-metal

go 1.19
go 1.21

require (
github.com/google/uuid v1.3.0
github.com/google/uuid v1.3.1
github.com/hashicorp/go-retryablehttp v0.7.4
github.com/packethost/packet-api-server v0.0.0-20230223042617-bc7d1539adbb
github.com/packethost/packngo v0.30.0
github.com/pallinder/go-randomdata v1.2.0
go.universe.tf/metallb v0.13.7
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
k8s.io/api v0.26.4
k8s.io/apimachinery v0.26.4
k8s.io/client-go v0.26.4
k8s.io/cloud-provider v0.26.4
k8s.io/component-base v0.26.4
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
golang.org/x/oauth2 v0.13.0
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.1
k8s.io/client-go v0.26.1
k8s.io/cloud-provider v0.26.1
k8s.io/component-base v0.26.1
k8s.io/klog/v2 v2.100.1
sigs.k8s.io/controller-runtime v0.14.6
sigs.k8s.io/yaml v1.3.0
)

require (
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect
Expand All @@ -46,7 +48,7 @@ require (
github.com/go-openapi/swag v0.19.14 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/cel-go v0.12.6 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
Expand Down Expand Up @@ -89,31 +91,30 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.16.0 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect
google.golang.org/grpc v1.49.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/apiserver v0.26.4 // indirect
k8s.io/component-helpers v0.26.4 // indirect
k8s.io/controller-manager v0.26.4 // indirect
k8s.io/kms v0.26.4 // indirect
k8s.io/apiserver v0.26.1 // indirect
k8s.io/component-helpers v0.26.1 // indirect
k8s.io/controller-manager v0.26.1 // indirect
k8s.io/kms v0.26.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.36 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.35 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)
Loading
Loading