Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions deploy/crds/planetscale.com_etcdlockservers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
createClientService:
type: boolean
Expand Down Expand Up @@ -286,6 +292,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
resources:
properties:
Expand Down
18 changes: 18 additions & 0 deletions deploy/crds/planetscale.com_vitesscells.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
sidecarContainers:
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -837,6 +843,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
createClientService:
type: boolean
Expand Down Expand Up @@ -1075,6 +1087,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
resources:
properties:
Expand Down
60 changes: 60 additions & 0 deletions deploy/crds/planetscale.com_vitessclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
sidecarContainers:
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -1043,6 +1049,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
createClientService:
type: boolean
Expand Down Expand Up @@ -1281,6 +1293,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
resources:
properties:
Expand Down Expand Up @@ -1357,6 +1375,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
globalLockserver:
properties:
Expand Down Expand Up @@ -1384,6 +1408,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
createClientService:
type: boolean
Expand Down Expand Up @@ -1622,6 +1652,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
resources:
properties:
Expand Down Expand Up @@ -2882,6 +2918,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
sidecarContainers:
x-kubernetes-preserve-unknown-fields: true
Expand All @@ -2901,6 +2943,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
topologyReconciliation:
properties:
Expand Down Expand Up @@ -3109,6 +3157,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
sidecarContainers:
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -3307,6 +3361,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
sidecarContainers:
x-kubernetes-preserve-unknown-fields: true
Expand Down
6 changes: 6 additions & 0 deletions deploy/crds/planetscale.com_vitesskeyspaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
sidecarContainers:
x-kubernetes-preserve-unknown-fields: true
Expand Down
6 changes: 6 additions & 0 deletions deploy/crds/planetscale.com_vitessshards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,12 @@ spec:
type: object
clusterIP:
type: string
externalTrafficPolicy:
type: string
loadBalancerIP:
type: string
type:
type: string
type: object
sidecarContainers:
x-kubernetes-preserve-unknown-fields: true
Expand Down
28 changes: 28 additions & 0 deletions pkg/apis/planetscale/v2/vitesscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,34 @@ type ServiceOverrides struct {
// initial creation of the Service will only be applied if you manually
// delete the Service.
ClusterIP string `json:"clusterIP,omitempty"`

// Type can optionally be used to override the Service's type.
// Defaults to ClusterIP if not specified. Setting this to NodePort or
// LoadBalancer exposes the Service outside the Kubernetes cluster.
// Changes to this field after the initial creation of the Service are
// applied in-place by the operator (Kubernetes supports transitions
// between Service types; some legacy fields like NodePorts assigned
// for the previous type may need to be cleared manually).
// +optional
Type corev1.ServiceType `json:"type,omitempty"`

// LoadBalancerIP, if set when Type is LoadBalancer, requests the cloud
// load balancer be assigned this specific IP. Only honored by clouds
// (and MetalLB) that support pre-assigned LB IPs. Ignored when Type is
// not LoadBalancer.
// This field is immutable on Service objects, so changes made after
// the initial creation of the Service will only be applied if you
// manually delete the Service.
// +optional
LoadBalancerIP string `json:"loadBalancerIP,omitempty"`

// ExternalTrafficPolicy, if set, controls how external traffic is
// routed for NodePort and LoadBalancer Services. "Cluster" (default)
// obscures the client source IP but balances across nodes; "Local"
// preserves the source IP at the cost of potentially uneven balancing.
// Ignored when Type is ClusterIP.
// +optional
ExternalTrafficPolicy corev1.ServiceExternalTrafficPolicy `json:"externalTrafficPolicy,omitempty"`
}

// VitessDashboardStatus is a summary of the status of the vtctld deployment.
Expand Down
21 changes: 21 additions & 0 deletions pkg/operator/update/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,35 @@ func ServiceOverrides(svc *corev1.Service, so *planetscalev2.ServiceOverrides) {
if so.ClusterIP != "" {
svc.Spec.ClusterIP = so.ClusterIP
}
if so.Type != "" {
svc.Spec.Type = so.Type
}
if so.LoadBalancerIP != "" {
svc.Spec.LoadBalancerIP = so.LoadBalancerIP
}
if so.ExternalTrafficPolicy != "" {
svc.Spec.ExternalTrafficPolicy = so.ExternalTrafficPolicy
}
}

// InPlaceServiceOverrides applies only the overrides that are safe to update in-place.
//
// Service.Type can be changed in-place by Kubernetes (transitions between
// ClusterIP / NodePort / LoadBalancer are supported), so it's applied here.
// ExternalTrafficPolicy is similarly mutable.
// ClusterIP and LoadBalancerIP are immutable on existing Services and are
// therefore only applied at creation time (see ServiceOverrides above).
func InPlaceServiceOverrides(svc *corev1.Service, so *planetscalev2.ServiceOverrides) {
if so == nil {
return
}
if len(so.Annotations) > 0 {
Annotations(&svc.Annotations, so.Annotations)
}
if so.Type != "" {
svc.Spec.Type = so.Type
}
if so.ExternalTrafficPolicy != "" {
svc.Spec.ExternalTrafficPolicy = so.ExternalTrafficPolicy
}
}
Loading
Loading