Merge branch 'master' into refactor/exp
This commit is contained in:
commit
39fa576824
|
|
@ -107,8 +107,13 @@ Those are top-level keys, containing both leaf keys and groups.
|
||||||
* **kubernetes_use_configmaps**
|
* **kubernetes_use_configmaps**
|
||||||
Select if setup uses endpoints (default), or configmaps to manage leader when
|
Select if setup uses endpoints (default), or configmaps to manage leader when
|
||||||
DCS is kubernetes (not etcd or similar). In OpenShift it is not possible to
|
DCS is kubernetes (not etcd or similar). In OpenShift it is not possible to
|
||||||
use endpoints option, and configmaps is required. By default,
|
use endpoints option, and configmaps is required. Starting with K8s 1.33,
|
||||||
`kubernetes_use_configmaps: false`, meaning endpoints will be used.
|
endpoints are marked as deprecated. It's recommended to switch to config maps
|
||||||
|
instead. But, to do so make sure you scale the Postgres cluster down to just
|
||||||
|
one primary pod (e.g. using `max_instances` option). Otherwise, you risk
|
||||||
|
running into a split-brain scenario.
|
||||||
|
By default, `kubernetes_use_configmaps: false`, meaning endpoints will be used.
|
||||||
|
Starting from v1.16.0 the default will be changed to `true`.
|
||||||
|
|
||||||
* **docker_image**
|
* **docker_image**
|
||||||
Spilo Docker image for Postgres instances. For production, don't rely on the
|
Spilo Docker image for Postgres instances. For production, don't rely on the
|
||||||
|
|
|
||||||
|
|
@ -59,13 +59,20 @@ rules:
|
||||||
- get
|
- get
|
||||||
- patch
|
- patch
|
||||||
- update
|
- update
|
||||||
# to read configuration from ConfigMaps
|
# to read configuration from ConfigMaps and help Patroni manage the cluster if endpoints are not used
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
- ""
|
- ""
|
||||||
resources:
|
resources:
|
||||||
- configmaps
|
- configmaps
|
||||||
verbs:
|
verbs:
|
||||||
|
- create
|
||||||
|
- delete
|
||||||
|
- deletecollection
|
||||||
- get
|
- get
|
||||||
|
- list
|
||||||
|
- patch
|
||||||
|
- update
|
||||||
|
- watch
|
||||||
# to send events to the CRs
|
# to send events to the CRs
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
- ""
|
- ""
|
||||||
|
|
@ -78,7 +85,7 @@ rules:
|
||||||
- patch
|
- patch
|
||||||
- update
|
- update
|
||||||
- watch
|
- watch
|
||||||
# to manage endpoints which are also used by Patroni
|
# to manage endpoints which are also used by Patroni (if it is using config maps)
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
- ""
|
- ""
|
||||||
resources:
|
resources:
|
||||||
|
|
@ -249,7 +256,21 @@ kind: ClusterRole
|
||||||
metadata:
|
metadata:
|
||||||
name: postgres-pod
|
name: postgres-pod
|
||||||
rules:
|
rules:
|
||||||
# Patroni needs to watch and manage endpoints
|
# Patroni needs to watch and manage config maps (or endpoints)
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- configmaps
|
||||||
|
verbs:
|
||||||
|
- create
|
||||||
|
- delete
|
||||||
|
- deletecollection
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
- patch
|
||||||
|
- update
|
||||||
|
- watch
|
||||||
|
# Patroni needs to watch and manage endpoints (or config maps)
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
- ""
|
- ""
|
||||||
resources:
|
resources:
|
||||||
|
|
|
||||||
|
|
@ -841,6 +841,14 @@ func (c *Cluster) compareServices(old, new *v1.Service) (bool, string) {
|
||||||
return false, "new service's owner references do not match the current ones"
|
return false, "new service's owner references do not match the current ones"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(old.Spec.Selector, new.Spec.Selector) {
|
||||||
|
return false, "new service's selector does not match the current one"
|
||||||
|
}
|
||||||
|
|
||||||
|
if old.Spec.ExternalTrafficPolicy != new.Spec.ExternalTrafficPolicy {
|
||||||
|
return false, "new service's ExternalTrafficPolicy does not match the current one"
|
||||||
|
}
|
||||||
|
|
||||||
return true, ""
|
return true, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1341,14 +1341,21 @@ func TestCompareEnv(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newService(ann map[string]string, svcT v1.ServiceType, lbSr []string) *v1.Service {
|
func newService(
|
||||||
|
annotations map[string]string,
|
||||||
|
svcType v1.ServiceType,
|
||||||
|
sourceRanges []string,
|
||||||
|
selector map[string]string,
|
||||||
|
policy v1.ServiceExternalTrafficPolicyType) *v1.Service {
|
||||||
svc := &v1.Service{
|
svc := &v1.Service{
|
||||||
Spec: v1.ServiceSpec{
|
Spec: v1.ServiceSpec{
|
||||||
Type: svcT,
|
Selector: selector,
|
||||||
LoadBalancerSourceRanges: lbSr,
|
Type: svcType,
|
||||||
|
LoadBalancerSourceRanges: sourceRanges,
|
||||||
|
ExternalTrafficPolicy: policy,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
svc.Annotations = ann
|
svc.Annotations = annotations
|
||||||
return svc
|
return svc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1365,13 +1372,18 @@ func TestCompareServices(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defaultPolicy := v1.ServiceExternalTrafficPolicyTypeCluster
|
||||||
|
|
||||||
serviceWithOwnerReference := newService(
|
serviceWithOwnerReference := newService(
|
||||||
map[string]string{
|
map[string]string{
|
||||||
constants.ZalandoDNSNameAnnotation: "clstr.acid.zalan.do",
|
constants.ZalandoDNSNameAnnotation: "clstr.acid.zalan.do",
|
||||||
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
||||||
},
|
},
|
||||||
v1.ServiceTypeClusterIP,
|
v1.ServiceTypeClusterIP,
|
||||||
[]string{"128.141.0.0/16", "137.138.0.0/16"})
|
[]string{"128.141.0.0/16", "137.138.0.0/16"},
|
||||||
|
nil,
|
||||||
|
defaultPolicy,
|
||||||
|
)
|
||||||
|
|
||||||
ownerRef := metav1.OwnerReference{
|
ownerRef := metav1.OwnerReference{
|
||||||
APIVersion: "acid.zalan.do/v1",
|
APIVersion: "acid.zalan.do/v1",
|
||||||
|
|
@ -1397,14 +1409,16 @@ func TestCompareServices(t *testing.T) {
|
||||||
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
||||||
},
|
},
|
||||||
v1.ServiceTypeClusterIP,
|
v1.ServiceTypeClusterIP,
|
||||||
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
|
[]string{"128.141.0.0/16", "137.138.0.0/16"},
|
||||||
|
nil, defaultPolicy),
|
||||||
new: newService(
|
new: newService(
|
||||||
map[string]string{
|
map[string]string{
|
||||||
constants.ZalandoDNSNameAnnotation: "clstr.acid.zalan.do",
|
constants.ZalandoDNSNameAnnotation: "clstr.acid.zalan.do",
|
||||||
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
||||||
},
|
},
|
||||||
v1.ServiceTypeClusterIP,
|
v1.ServiceTypeClusterIP,
|
||||||
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
|
[]string{"128.141.0.0/16", "137.138.0.0/16"},
|
||||||
|
nil, defaultPolicy),
|
||||||
match: true,
|
match: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -1415,14 +1429,16 @@ func TestCompareServices(t *testing.T) {
|
||||||
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
||||||
},
|
},
|
||||||
v1.ServiceTypeClusterIP,
|
v1.ServiceTypeClusterIP,
|
||||||
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
|
[]string{"128.141.0.0/16", "137.138.0.0/16"},
|
||||||
|
nil, defaultPolicy),
|
||||||
new: newService(
|
new: newService(
|
||||||
map[string]string{
|
map[string]string{
|
||||||
constants.ZalandoDNSNameAnnotation: "clstr.acid.zalan.do",
|
constants.ZalandoDNSNameAnnotation: "clstr.acid.zalan.do",
|
||||||
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
||||||
},
|
},
|
||||||
v1.ServiceTypeLoadBalancer,
|
v1.ServiceTypeLoadBalancer,
|
||||||
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
|
[]string{"128.141.0.0/16", "137.138.0.0/16"},
|
||||||
|
nil, defaultPolicy),
|
||||||
match: false,
|
match: false,
|
||||||
reason: `new service's type "LoadBalancer" does not match the current one "ClusterIP"`,
|
reason: `new service's type "LoadBalancer" does not match the current one "ClusterIP"`,
|
||||||
},
|
},
|
||||||
|
|
@ -1434,14 +1450,16 @@ func TestCompareServices(t *testing.T) {
|
||||||
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
||||||
},
|
},
|
||||||
v1.ServiceTypeLoadBalancer,
|
v1.ServiceTypeLoadBalancer,
|
||||||
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
|
[]string{"128.141.0.0/16", "137.138.0.0/16"},
|
||||||
|
nil, defaultPolicy),
|
||||||
new: newService(
|
new: newService(
|
||||||
map[string]string{
|
map[string]string{
|
||||||
constants.ZalandoDNSNameAnnotation: "clstr.acid.zalan.do",
|
constants.ZalandoDNSNameAnnotation: "clstr.acid.zalan.do",
|
||||||
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
||||||
},
|
},
|
||||||
v1.ServiceTypeLoadBalancer,
|
v1.ServiceTypeLoadBalancer,
|
||||||
[]string{"185.249.56.0/22"}),
|
[]string{"185.249.56.0/22"},
|
||||||
|
nil, defaultPolicy),
|
||||||
match: false,
|
match: false,
|
||||||
reason: `new service's LoadBalancerSourceRange does not match the current one`,
|
reason: `new service's LoadBalancerSourceRange does not match the current one`,
|
||||||
},
|
},
|
||||||
|
|
@ -1453,14 +1471,16 @@ func TestCompareServices(t *testing.T) {
|
||||||
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
||||||
},
|
},
|
||||||
v1.ServiceTypeLoadBalancer,
|
v1.ServiceTypeLoadBalancer,
|
||||||
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
|
[]string{"128.141.0.0/16", "137.138.0.0/16"},
|
||||||
|
nil, defaultPolicy),
|
||||||
new: newService(
|
new: newService(
|
||||||
map[string]string{
|
map[string]string{
|
||||||
constants.ZalandoDNSNameAnnotation: "clstr.acid.zalan.do",
|
constants.ZalandoDNSNameAnnotation: "clstr.acid.zalan.do",
|
||||||
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
||||||
},
|
},
|
||||||
v1.ServiceTypeLoadBalancer,
|
v1.ServiceTypeLoadBalancer,
|
||||||
[]string{}),
|
[]string{},
|
||||||
|
nil, defaultPolicy),
|
||||||
match: false,
|
match: false,
|
||||||
reason: `new service's LoadBalancerSourceRange does not match the current one`,
|
reason: `new service's LoadBalancerSourceRange does not match the current one`,
|
||||||
},
|
},
|
||||||
|
|
@ -1472,10 +1492,39 @@ func TestCompareServices(t *testing.T) {
|
||||||
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
|
||||||
},
|
},
|
||||||
v1.ServiceTypeClusterIP,
|
v1.ServiceTypeClusterIP,
|
||||||
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
|
[]string{"128.141.0.0/16", "137.138.0.0/16"},
|
||||||
|
nil, defaultPolicy),
|
||||||
new: serviceWithOwnerReference,
|
new: serviceWithOwnerReference,
|
||||||
match: false,
|
match: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
about: "new service has a label selector",
|
||||||
|
current: newService(
|
||||||
|
map[string]string{},
|
||||||
|
v1.ServiceTypeClusterIP,
|
||||||
|
[]string{},
|
||||||
|
nil, defaultPolicy),
|
||||||
|
new: newService(
|
||||||
|
map[string]string{},
|
||||||
|
v1.ServiceTypeClusterIP,
|
||||||
|
[]string{},
|
||||||
|
map[string]string{"cluster-name": "clstr", "spilo-role": "master"}, defaultPolicy),
|
||||||
|
match: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
about: "services differ on external traffic policy",
|
||||||
|
current: newService(
|
||||||
|
map[string]string{},
|
||||||
|
v1.ServiceTypeClusterIP,
|
||||||
|
[]string{},
|
||||||
|
nil, defaultPolicy),
|
||||||
|
new: newService(
|
||||||
|
map[string]string{},
|
||||||
|
v1.ServiceTypeClusterIP,
|
||||||
|
[]string{},
|
||||||
|
nil, v1.ServiceExternalTrafficPolicyTypeLocal),
|
||||||
|
match: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue