Skip to content

Commit 21475f4

Browse files
authored
Cleanup config examples (zalando#1151)
* post polishing for latest PRs * update travis and go modules * make deprecation comments in structs less confusing * have separate pod priority class es for operator and database pods
1 parent 3b6dc4f commit 21475f4

16 files changed

+110
-71
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ script:
2020
- hack/verify-codegen.sh
2121
- travis_wait 20 go test -race -covermode atomic -coverprofile=profile.cov ./pkg/... -v
2222
- goveralls -coverprofile=profile.cov -service=travis-ci -v
23-
- travis_wait 20 make e2e
23+
- make e2e

charts/postgres-operator/crds/operatorconfigurations.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ spec:
263263
type: boolean
264264
enable_replica_load_balancer:
265265
type: boolean
266+
external_traffic_policy:
267+
type: string
268+
enum:
269+
- "Cluster"
270+
- "Local"
266271
master_dns_name_format:
267272
type: string
268273
replica_dns_name_format:

charts/postgres-operator/templates/configmap.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ metadata:
99
app.kubernetes.io/managed-by: {{ .Release.Service }}
1010
app.kubernetes.io/instance: {{ .Release.Name }}
1111
data:
12+
{{- if .Values.podPriorityClassName }}
13+
pod_priority_class_name: {{ .Values.podPriorityClassName }}
14+
{{- end }}
1215
pod_service_account_name: {{ include "postgres-pod.serviceAccountName" . }}
1316
{{ toYaml .Values.configGeneral | indent 2 }}
1417
{{ toYaml .Values.configUsers | indent 2 }}

charts/postgres-operator/templates/operatorconfiguration.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ configuration:
1313
users:
1414
{{ toYaml .Values.configUsers | indent 4 }}
1515
kubernetes:
16+
{{- if .Values.podPriorityClassName }}
17+
pod_priority_class_name: {{ .Values.podPriorityClassName }}
18+
{{- end }}
1619
pod_service_account_name: {{ include "postgres-pod.serviceAccountName" . }}
1720
oauth_token_secret_name: {{ template "postgres-operator.fullname" . }}
1821
{{ toYaml .Values.configKubernetes | indent 4 }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- if .Values.podPriorityClassName }}
2+
apiVersion: scheduling.k8s.io/v1
3+
description: 'Use only for databases controlled by Postgres operator'
4+
kind: PriorityClass
5+
metadata:
6+
labels:
7+
app.kubernetes.io/name: {{ template "postgres-operator.name" . }}
8+
helm.sh/chart: {{ template "postgres-operator.chart" . }}
9+
app.kubernetes.io/managed-by: {{ .Release.Service }}
10+
app.kubernetes.io/instance: {{ .Release.Name }}
11+
name: {{ .Values.podPriorityClassName }}
12+
preemptionPolicy: PreemptLowerPriority
13+
globalDefault: false
14+
value: 1000000
15+
{{- end }}

charts/postgres-operator/values-crd.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ configLoadBalancer:
183183
enable_master_load_balancer: false
184184
# toggles service type load balancer pointing to the replica pod of the cluster
185185
enable_replica_load_balancer: false
186+
# define external traffic policy for the load balancer
187+
external_traffic_policy: "Cluster"
186188
# defines the DNS name string template for the master load balancer cluster
187189
master_dns_name_format: "{cluster}.{team}.{hostedzone}"
188190
# defines the DNS name string template for the replica load balancer cluster
@@ -318,8 +320,12 @@ podServiceAccount:
318320
# If not set a name is generated using the fullname template and "-pod" suffix
319321
name: "postgres-pod"
320322

323+
# priority class for operator pod
321324
priorityClassName: ""
322325

326+
# priority class for database pods
327+
podPriorityClassName: ""
328+
323329
resources:
324330
limits:
325331
cpu: 500m

charts/postgres-operator/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ configLoadBalancer:
172172
enable_master_load_balancer: "false"
173173
# toggles service type load balancer pointing to the replica pod of the cluster
174174
enable_replica_load_balancer: "false"
175+
# define external traffic policy for the load balancer
176+
external_traffic_policy: "Cluster"
175177
# defines the DNS name string template for the master load balancer cluster
176178
master_dns_name_format: '{cluster}.{team}.{hostedzone}'
177179
# defines the DNS name string template for the replica load balancer cluster
@@ -310,8 +312,12 @@ podServiceAccount:
310312
# If not set a name is generated using the fullname template and "-pod" suffix
311313
name: "postgres-pod"
312314

315+
# priority class for operator pod
313316
priorityClassName: ""
314317

318+
# priority class for database pods
319+
podPriorityClassName: ""
320+
315321
resources:
316322
limits:
317323
cpu: 500m

docs/reference/operator_parameters.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,12 @@ CRD-based configuration.
434434
Those options affect the behavior of load balancers created by the operator.
435435
In the CRD-based configuration they are grouped under the `load_balancer` key.
436436

437+
* **custom_service_annotations**
438+
This key/value map provides a list of annotations that get attached to each
439+
service of a cluster created by the operator. If the annotation key is also
440+
provided by the cluster definition, the manifest value is used.
441+
Optional.
442+
437443
* **db_hosted_zone**
438444
DNS zone for the cluster DNS name when the load balancer is configured for
439445
the cluster. Only used when combined with
@@ -450,11 +456,8 @@ In the CRD-based configuration they are grouped under the `load_balancer` key.
450456
cluster. Can be overridden by individual cluster settings. The default is
451457
`false`.
452458

453-
* **custom_service_annotations**
454-
This key/value map provides a list of annotations that get attached to each
455-
service of a cluster created by the operator. If the annotation key is also
456-
provided by the cluster definition, the manifest value is used.
457-
Optional.
459+
* **external_traffic_policy** defines external traffic policy for load
460+
balancers. Allowed values are `Cluster` (default) and `Local`.
458461

459462
* **master_dns_name_format** defines the DNS name string template for the
460463
master load balancer cluster. The default is
@@ -470,9 +473,6 @@ In the CRD-based configuration they are grouped under the `load_balancer` key.
470473
replaced with the hosted zone (the value of the `db_hosted_zone` parameter).
471474
No other placeholders are allowed.
472475

473-
* **external_traffic_policy** define external traffic policy for the load
474-
balancer, it will default to `Cluster` if undefined.
475-
476476
## AWS or GCP interaction
477477

478478
The options in this group configure operator interactions with non-Kubernetes

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ require (
1010
github.com/sirupsen/logrus v1.6.0
1111
github.com/stretchr/testify v1.5.1
1212
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
13-
golang.org/x/tools v0.0.0-20200828161849-5deb26317202 // indirect
14-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
13+
golang.org/x/tools v0.0.0-20200928201943-a0ef9b62deab // indirect
1514
gopkg.in/yaml.v2 v2.2.8
1615
k8s.io/api v0.18.8
1716
k8s.io/apiextensions-apiserver v0.18.0

go.sum

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb
287287
github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
288288
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
289289
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
290-
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
290+
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
291291
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
292292
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
293293
go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
@@ -333,8 +333,8 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL
333333
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
334334
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
335335
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
336-
golang.org/x/net v0.0.0-20200625001655-4c5254603344 h1:vGXIOMxbNfDTk/aXCmfdLgkrSV+Z2tcbze+pEc3v5W4=
337-
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
336+
golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA=
337+
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
338338
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
339339
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
340340
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
@@ -386,11 +386,10 @@ golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgw
386386
golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
387387
golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
388388
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
389-
golang.org/x/tools v0.0.0-20200828161849-5deb26317202 h1:DrWbY9UUFi/sl/3HkNVoBjDbGfIPZZfgoGsGxOL1EU8=
390-
golang.org/x/tools v0.0.0-20200828161849-5deb26317202/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
389+
golang.org/x/tools v0.0.0-20200928201943-a0ef9b62deab h1:CyH2SDm5ATQiX9gtbMYfvNNed97A9v+TJFnUX/fTaJY=
390+
golang.org/x/tools v0.0.0-20200928201943-a0ef9b62deab/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
391391
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
392392
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
393-
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
394393
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
395394
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
396395
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=

manifests/configmap.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ data:
4747
# enable_team_superuser: "false"
4848
enable_teams_api: "false"
4949
# etcd_host: ""
50+
external_traffic_policy: "Cluster"
5051
# gcp_credentials: ""
5152
# kubernetes_use_configmaps: "false"
5253
# infrastructure_roles_secret_name: "postgresql-infrastructure-roles"
@@ -80,12 +81,12 @@ data:
8081
# pod_environment_secret: "my-custom-secret"
8182
pod_label_wait_timeout: 10m
8283
pod_management_policy: "ordered_ready"
84+
# pod_priority_class_name: "postgres-pod-priority"
8385
pod_role_label: spilo-role
8486
# pod_service_account_definition: ""
8587
pod_service_account_name: "postgres-pod"
8688
# pod_service_account_role_binding_definition: ""
8789
pod_terminate_grace_period: 5m
88-
# pod_priority_class_name: "postgres-pod-priority"
8990
# postgres_superuser_teams: "postgres_superusers"
9091
# protected_role_names: "admin"
9192
ready_wait_interval: 3s

manifests/operatorconfiguration.crd.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ spec:
265265
type: boolean
266266
enable_replica_load_balancer:
267267
type: boolean
268+
external_traffic_policy:
269+
type: string
270+
enum:
271+
- "Cluster"
272+
- "Local"
268273
master_dns_name_format:
269274
type: string
270275
replica_dns_name_format:

manifests/postgresql-operator-default-configuration.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ configuration:
6161
# pod_environment_configmap: "default/my-custom-config"
6262
# pod_environment_secret: "my-custom-secret"
6363
pod_management_policy: "ordered_ready"
64-
# pod_priority_class_name: ""
64+
# pod_priority_class_name: "postgres-pod-priority"
6565
pod_role_label: spilo-role
6666
# pod_service_account_definition: ""
6767
pod_service_account_name: postgres-pod
@@ -90,12 +90,13 @@ configuration:
9090
resource_check_interval: 3s
9191
resource_check_timeout: 10m
9292
load_balancer:
93-
# db_hosted_zone: ""
94-
enable_master_load_balancer: false
95-
enable_replica_load_balancer: false
9693
# custom_service_annotations:
9794
# keyx: valuex
9895
# keyy: valuey
96+
# db_hosted_zone: ""
97+
enable_master_load_balancer: false
98+
enable_replica_load_balancer: false
99+
external_traffic_policy: "Cluster"
99100
master_dns_name_format: "{cluster}.{team}.{hostedzone}"
100101
replica_dns_name_format: "{cluster}-repl.{team}.{hostedzone}"
101102
aws_or_gcp:

pkg/apis/acid.zalan.do/v1/crds.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,12 +1135,6 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation
11351135
"enable_replica_load_balancer": {
11361136
Type: "boolean",
11371137
},
1138-
"master_dns_name_format": {
1139-
Type: "string",
1140-
},
1141-
"replica_dns_name_format": {
1142-
Type: "string",
1143-
},
11441138
"external_traffic_policy": {
11451139
Type: "string",
11461140
Enum: []apiextv1beta1.JSON{
@@ -1152,6 +1146,12 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation
11521146
},
11531147
},
11541148
},
1149+
"master_dns_name_format": {
1150+
Type: "string",
1151+
},
1152+
"replica_dns_name_format": {
1153+
Type: "string",
1154+
},
11551155
},
11561156
},
11571157
"aws_or_gcp": {

pkg/apis/acid.zalan.do/v1/operator_configuration_type.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,19 @@ type OperatorLogicalBackupConfiguration struct {
193193

194194
// OperatorConfigurationData defines the operation config
195195
type OperatorConfigurationData struct {
196-
EnableCRDValidation *bool `json:"enable_crd_validation,omitempty"`
197-
EnableLazySpiloUpgrade bool `json:"enable_lazy_spilo_upgrade,omitempty"`
198-
EtcdHost string `json:"etcd_host,omitempty"`
199-
KubernetesUseConfigMaps bool `json:"kubernetes_use_configmaps,omitempty"`
200-
DockerImage string `json:"docker_image,omitempty"`
201-
Workers uint32 `json:"workers,omitempty"`
202-
MinInstances int32 `json:"min_instances,omitempty"`
203-
MaxInstances int32 `json:"max_instances,omitempty"`
204-
ResyncPeriod Duration `json:"resync_period,omitempty"`
205-
RepairPeriod Duration `json:"repair_period,omitempty"`
206-
SetMemoryRequestToLimit bool `json:"set_memory_request_to_limit,omitempty"`
207-
ShmVolume *bool `json:"enable_shm_volume,omitempty"`
208-
// deprecated in favour of SidecarContainers
209-
SidecarImages map[string]string `json:"sidecar_docker_images,omitempty"`
196+
EnableCRDValidation *bool `json:"enable_crd_validation,omitempty"`
197+
EnableLazySpiloUpgrade bool `json:"enable_lazy_spilo_upgrade,omitempty"`
198+
EtcdHost string `json:"etcd_host,omitempty"`
199+
KubernetesUseConfigMaps bool `json:"kubernetes_use_configmaps,omitempty"`
200+
DockerImage string `json:"docker_image,omitempty"`
201+
Workers uint32 `json:"workers,omitempty"`
202+
MinInstances int32 `json:"min_instances,omitempty"`
203+
MaxInstances int32 `json:"max_instances,omitempty"`
204+
ResyncPeriod Duration `json:"resync_period,omitempty"`
205+
RepairPeriod Duration `json:"repair_period,omitempty"`
206+
SetMemoryRequestToLimit bool `json:"set_memory_request_to_limit,omitempty"`
207+
ShmVolume *bool `json:"enable_shm_volume,omitempty"`
208+
SidecarImages map[string]string `json:"sidecar_docker_images,omitempty"` // deprecated in favour of SidecarContainers
210209
SidecarContainers []v1.Container `json:"sidecars,omitempty"`
211210
PostgresUsersConfiguration PostgresUsersConfiguration `json:"users"`
212211
Kubernetes KubernetesMetaConfiguration `json:"kubernetes"`

0 commit comments

Comments
 (0)