Skip to content

Commit

Permalink
add external ip reconciliation for AWS provider
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentmrg committed May 27, 2021
1 parent 89b9a6c commit 0c6a5ae
Show file tree
Hide file tree
Showing 17 changed files with 829 additions and 46 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN go mod download
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
COPY pkg/ pkg/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
Expand Down
37 changes: 27 additions & 10 deletions api/v1alpha1/externalip_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,43 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// ExternalIPSpec defines the desired state of ExternalIP
type ExternalIPSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of ExternalIP. Edit externalip_types.go to remove/update
Foo string `json:"foo,omitempty"`
// NodeName is the node's instance on which the address must be attached
// +optional
NodeName *string `json:"nodeName,omitempty"`
}

// ExternalIPState describes the ExternalIP state.
type ExternalIPState string

// All defined ExternalIPStates
const (
ExternalIPStateNone ExternalIPState = ""
ExternalIPStateReserved ExternalIPState = "Reserved"
ExternalIPStateAssociated ExternalIPState = "Associated"
)

// ExternalIPStatus defines the observed state of ExternalIP
type ExternalIPStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
// The current state of the ExternalIP
State ExternalIPState `json:"state,omitempty"`

// The address dientifier
AddressID *string `json:"addressID,omitempty"`

// The address public IP
PublicIPAddress *string `json:"publicIPAddress,omitempty"`

// The instance identifier
InstanceID *string `json:"instanceID,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:scope=Cluster
//+kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state`
//+kubebuilder:printcolumn:name="Public IP",type=string,JSONPath=`.status.publicIPAddress`

// ExternalIP is the Schema for the externalips API
type ExternalIP struct {
Expand Down
24 changes: 22 additions & 2 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions config/crd/bases/kubestatic.quortex.io_externalips.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
creationTimestamp: null
name: externalips.kubestatic.quortex.io
spec:
group: kubestatic.quortex.io
names:
kind: ExternalIP
listKind: ExternalIPList
plural: externalips
singular: externalip
scope: Cluster
versions:
- additionalPrinterColumns:
- jsonPath: .status.state
name: State
type: string
- jsonPath: .status.publicIPAddress
name: Public IP
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: ExternalIP is the Schema for the externalips API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ExternalIPSpec defines the desired state of ExternalIP
properties:
nodeName:
description: NodeName is a request to attach this IP on a specific
node instance.
type: string
type: object
status:
description: ExternalIPStatus defines the observed state of ExternalIP
properties:
addressID:
type: string
instanceID:
type: string
publicIPAddress:
type: string
state:
description: The current state of the ExternalIP
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
44 changes: 44 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: manager-role
rules:
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- kubestatic.quortex.io
resources:
- externalips
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- kubestatic.quortex.io
resources:
- externalips/finalizers
verbs:
- update
- apiGroups:
- kubestatic.quortex.io
resources:
- externalips/status
verbs:
- get
- patch
- update
3 changes: 1 addition & 2 deletions config/samples/_v1alpha1_externalip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ kind: ExternalIP
metadata:
name: externalip-sample
spec:
# Add fields here
foo: bar
nodeName: ip-10-136-35-84.eu-west-1.compute.internal
Loading

0 comments on commit 0c6a5ae

Please sign in to comment.