Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
88735a7
Resize volume by changing pvc size if enabled in config. (#958)
yanchenko-igor Jul 3, 2020
c10d309
bump pgBouncer image (#1050)
FxKu Jul 8, 2020
b80f976
test coverage (#1055)
yanchenko-igor Jul 10, 2020
3759634
delete secrets the right way (#1054)
FxKu Jul 10, 2020
ec932f8
Port-forward service instead of pod (#1040)
toonsevrin Jul 15, 2020
002b47e
Use scram-sha-256 hash if postgresql parameter password_encryption se…
yanchenko-igor Jul 16, 2020
102a353
update dependencies (#1080)
FxKu Jul 29, 2020
ece341d
Allow pod environment variables to also be sourced from a secret (#946)
frittentheke Jul 30, 2020
aab9b0a
chart ui: fix target namespace to allow '*' (#1082)
arichardet Jul 30, 2020
3bee590
fix index in TestGenerateSpiloPodEnvVarswq (#1084)
FxKu Jul 30, 2020
47b11f7
change Clone attribute of PostgresSpec to *CloneDescription (#1020)
hlihhovac Jul 30, 2020
f3ddce8
fix random order for pod environment tests (#1085)
FxKu Jul 30, 2020
7cf2fae
[WIP] Extend infrastructure roles handling (#1064)
erthalion Aug 5, 2020
43163cf
allow using both infrastructure_roles_options (#1090)
FxKu Aug 10, 2020
0508266
Remove all secrets on delete incl. pooler (#1091)
FxKu Aug 10, 2020
dfd0dd9
set search_path for default roles (#1065)
FxKu Aug 11, 2020
fc9ee76
UI Service port forwarding internal port is updated to 80 from 8081. …
sonaysevik Aug 11, 2020
808030a
update go modules (#1097)
FxKu Aug 12, 2020
0d81f97
Added build and node directory to gitignore file. (#1102)
Jan-M Aug 12, 2020
3ddc56e
allow delete only if annotations meet configured criteria (#1069)
FxKu Aug 13, 2020
dab704c
Add kustomize support to Postgres UI. (#1086)
hoangelos Aug 26, 2020
248ce9f
Update to go 1.14.7 (#1122)
FxKu Aug 26, 2020
30c8675
update kind and use with old storage class (#1121)
FxKu Aug 28, 2020
5e93aab
improve e2e test debugging (#1107)
FxKu Aug 28, 2020
e03e9f9
add missing omitempty directive to the attributes of PostgresSpec (#1…
hlihhovac Aug 31, 2020
03437b6
Update issue templates (#1051)
FxKu Sep 3, 2020
d8884a4
Allow to overwrite default ExternalTrafficPolicy for the service (#1136)
yanchenko-igor Sep 15, 2020
d09e418
Set user and group in security context (#1083)
ricoberger Sep 15, 2020
ab95eaa
Fixes #1130 (#1139)
neelasha-09 Sep 22, 2020
2a21cc4
Compare Postgres pod priority on Sync (#1144)
sdudoladov Sep 23, 2020
ffdb47f
remove outdated GSOC info (#1148)
sdudoladov Sep 25, 2020
3b6dc4f
Improve e2e tests (#1111)
sdudoladov Sep 25, 2020
21475f4
Cleanup config examples (#1151)
FxKu Sep 30, 2020
38e1518
update kind (#1156)
sdudoladov Oct 2, 2020
692c721
Introduce ENABLE_JSON_LOGGING env variable (#1158)
dajudge Oct 8, 2020
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
Prev Previous commit
Next Next commit
allow using both infrastructure_roles_options (zalando#1090)
* allow using both infrastructure_roles_options

* new default values for user and role definition

* use robot_zmon as parent role

* add operator log to debug

* right name for old secret

* only extract if rolesDefs is empty

* set password1 in old infrastructure role

* fix new infra rile secret

* choose different role key for new secret

* set memberof everywhere

* reenable all tests

* reflect feedback

* remove condition for rolesDefs
  • Loading branch information
FxKu authored Aug 10, 2020
commit 43163cf83b463e5350073a8acb4bdb622a95b9a4
4 changes: 4 additions & 0 deletions charts/postgres-operator/crds/operatorconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ spec:
type: string
rolekey:
type: string
defaultuservalue:
type: string
defaultrolevalue:
type: string
details:
type: string
template:
Expand Down
1,007 changes: 504 additions & 503 deletions e2e/tests/test_e2e.py

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions manifests/infrastructure-roles-new.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ data:
# infrastructure role definition in the new format
# robot_zmon_acid_monitoring_new
user: cm9ib3Rfem1vbl9hY2lkX21vbml0b3JpbmdfbmV3
# robot_zmon_new
role: cm9ib3Rfem1vbl9uZXc=
# foobar_new
password: Zm9vYmFyX25ldw==
kind: Secret
Expand Down
6 changes: 4 additions & 2 deletions manifests/infrastructure-roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ data:
# provide other options in the configmap.
# robot_zmon_acid_monitoring
user1: cm9ib3Rfem1vbl9hY2lkX21vbml0b3Jpbmc=
# foobar
password1: Zm9vYmFy
# robot_zmon
inrole1: cm9ib3Rfem1vbg==
# testuser
user2: dGVzdHVzZXI=
# foobar
password2: Zm9vYmFy
# testpassword
password2: dGVzdHBhc3N3b3Jk
# user batman with the password justice
# look for other fields in the infrastructure roles configmap
batman: anVzdGljZQ==
Expand Down
4 changes: 4 additions & 0 deletions manifests/operatorconfiguration.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ spec:
type: string
rolekey:
type: string
defaultuservalue:
type: string
defaultrolevalue:
type: string
details:
type: string
template:
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/acid.zalan.do/v1/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,12 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation
"rolekey": {
Type: "string",
},
"defaultuservalue": {
Type: "string",
},
"defaultrolevalue": {
Type: "string",
},
"details": {
Type: "string",
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (c *Cluster) deleteConnectionPooler() (err error) {
serviceName = service.Name
}

// set delete propagation policy to foreground, so that all the dependant
// set delete propagation policy to foreground, so that all the dependent
// will be deleted.
err = c.KubeClient.
Services(c.Namespace).
Expand Down
38 changes: 21 additions & 17 deletions pkg/controller/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"github.com/zalando/postgres-operator/pkg/cluster"
"github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando/postgres-operator/pkg/util"
"github.com/zalando/postgres-operator/pkg/util/config"
"github.com/zalando/postgres-operator/pkg/util/k8sutil"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -118,13 +119,9 @@ var emptyName = (spec.NamespacedName{})
// configuration in ConfigMap & CRD.
func (c *Controller) getInfrastructureRoleDefinitions() []*config.InfrastructureRole {
var roleDef config.InfrastructureRole
rolesDefs := c.opConfig.InfrastructureRoles

if c.opConfig.InfrastructureRolesSecretName == emptyName {
// All the other possibilities require secret name to be present, so if
// it is not, then nothing else to be done here.
return rolesDefs
}
// take from CRD configuration
rolesDefs := c.opConfig.InfrastructureRoles

// check if we can extract something from the configmap config option
if c.opConfig.InfrastructureRolesDefs != "" {
Expand Down Expand Up @@ -163,27 +160,33 @@ func (c *Controller) getInfrastructureRoleDefinitions() []*config.Infrastructure
roleDef.PasswordKey = value
case "rolekey":
roleDef.RoleKey = value
case "defaultuservalue":
roleDef.DefaultUserValue = value
case "defaultrolevalue":
roleDef.DefaultRoleValue = value
default:
c.logger.Warningf("Role description is not known: %s", properties)
}
}
} else {

if roleDef.SecretName != emptyName &&
(roleDef.UserKey != "" || roleDef.DefaultUserValue != "") &&
roleDef.PasswordKey != "" {
rolesDefs = append(rolesDefs, &roleDef)
}
}

if c.opConfig.InfrastructureRolesSecretName != emptyName {
// At this point we deal with the old format, let's replicate it
// via existing definition structure and remember that it's just a
// template, the real values are in user1,password1,inrole1 etc.
roleDef = config.InfrastructureRole{
rolesDefs = append(rolesDefs, &config.InfrastructureRole{
SecretName: c.opConfig.InfrastructureRolesSecretName,
UserKey: "user",
PasswordKey: "password",
RoleKey: "inrole",
Template: true,
}
}

if roleDef.UserKey != "" &&
roleDef.PasswordKey != "" &&
roleDef.RoleKey != "" {
rolesDefs = append(rolesDefs, &roleDef)
})
}

return rolesDefs
Expand Down Expand Up @@ -330,9 +333,10 @@ func (c *Controller) getInfrastructureRole(
return nil, fmt.Errorf("could not decode yaml role: %v", err)
}
} else {
roleDescr.Name = string(secretData[infraRole.UserKey])
roleDescr.Name = util.Coalesce(string(secretData[infraRole.UserKey]), infraRole.DefaultUserValue)
roleDescr.Password = string(secretData[infraRole.PasswordKey])
roleDescr.MemberOf = append(roleDescr.MemberOf, string(secretData[infraRole.RoleKey]))
roleDescr.MemberOf = append(roleDescr.MemberOf,
util.Coalesce(string(secretData[infraRole.RoleKey]), infraRole.DefaultRoleValue))
}

if roleDescr.Valid() {
Expand Down
113 changes: 99 additions & 14 deletions pkg/controller/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,17 @@ func TestInfrastructureRoleDefinitions(t *testing.T) {
roleSecrets string
expectedDefs []*config.InfrastructureRole
}{
// only new format
// only new CRD format
{
[]*config.InfrastructureRole{
&config.InfrastructureRole{
SecretName: spec.NamespacedName{
Namespace: v1.NamespaceDefault,
Name: testInfrastructureRolesNewSecretName,
},
UserKey: "user",
PasswordKey: "password",
RoleKey: "inrole",
UserKey: "test-user",
PasswordKey: "test-password",
RoleKey: "test-role",
Template: false,
},
},
Expand All @@ -301,14 +301,50 @@ func TestInfrastructureRoleDefinitions(t *testing.T) {
Namespace: v1.NamespaceDefault,
Name: testInfrastructureRolesNewSecretName,
},
UserKey: "user",
PasswordKey: "password",
RoleKey: "inrole",
UserKey: "test-user",
PasswordKey: "test-password",
RoleKey: "test-role",
Template: false,
},
},
},
// only old format
// only new configmap format
{
[]*config.InfrastructureRole{},
spec.NamespacedName{},
"secretname: infrastructureroles-new-test, userkey: test-user, passwordkey: test-password, rolekey: test-role",
[]*config.InfrastructureRole{
&config.InfrastructureRole{
SecretName: spec.NamespacedName{
Namespace: v1.NamespaceDefault,
Name: testInfrastructureRolesNewSecretName,
},
UserKey: "test-user",
PasswordKey: "test-password",
RoleKey: "test-role",
Template: false,
},
},
},
// new configmap format with defaultRoleValue
{
[]*config.InfrastructureRole{},
spec.NamespacedName{},
"secretname: infrastructureroles-new-test, userkey: test-user, passwordkey: test-password, defaultrolevalue: test-role",
[]*config.InfrastructureRole{
&config.InfrastructureRole{
SecretName: spec.NamespacedName{
Namespace: v1.NamespaceDefault,
Name: testInfrastructureRolesNewSecretName,
},
UserKey: "test-user",
PasswordKey: "test-password",
DefaultRoleValue: "test-role",
Template: false,
},
},
},
// only old CRD and configmap format
{
[]*config.InfrastructureRole{},
spec.NamespacedName{
Expand All @@ -329,42 +365,91 @@ func TestInfrastructureRoleDefinitions(t *testing.T) {
},
},
},
// only configmap format
// both formats for CRD
{
[]*config.InfrastructureRole{},
[]*config.InfrastructureRole{
&config.InfrastructureRole{
SecretName: spec.NamespacedName{
Namespace: v1.NamespaceDefault,
Name: testInfrastructureRolesNewSecretName,
},
UserKey: "test-user",
PasswordKey: "test-password",
RoleKey: "test-role",
Template: false,
},
},
spec.NamespacedName{
Namespace: v1.NamespaceDefault,
Name: testInfrastructureRolesOldSecretName,
},
"secretname: infrastructureroles-old-test, userkey: test-user, passwordkey: test-password, rolekey: test-role, template: false",
"",
[]*config.InfrastructureRole{
&config.InfrastructureRole{
SecretName: spec.NamespacedName{
Namespace: v1.NamespaceDefault,
Name: testInfrastructureRolesOldSecretName,
Name: testInfrastructureRolesNewSecretName,
},
UserKey: "test-user",
PasswordKey: "test-password",
RoleKey: "test-role",
Template: false,
},
&config.InfrastructureRole{
SecretName: spec.NamespacedName{
Namespace: v1.NamespaceDefault,
Name: testInfrastructureRolesOldSecretName,
},
UserKey: "user",
PasswordKey: "password",
RoleKey: "inrole",
Template: true,
},
},
},
// incorrect configmap format
// both formats for configmap
{
[]*config.InfrastructureRole{},
spec.NamespacedName{
Namespace: v1.NamespaceDefault,
Name: testInfrastructureRolesOldSecretName,
},
"secretname: infrastructureroles-new-test, userkey: test-user, passwordkey: test-password, rolekey: test-role",
[]*config.InfrastructureRole{
&config.InfrastructureRole{
SecretName: spec.NamespacedName{
Namespace: v1.NamespaceDefault,
Name: testInfrastructureRolesNewSecretName,
},
UserKey: "test-user",
PasswordKey: "test-password",
RoleKey: "test-role",
Template: false,
},
&config.InfrastructureRole{
SecretName: spec.NamespacedName{
Namespace: v1.NamespaceDefault,
Name: testInfrastructureRolesOldSecretName,
},
UserKey: "user",
PasswordKey: "password",
RoleKey: "inrole",
Template: true,
},
},
},
// incorrect configmap format
{
[]*config.InfrastructureRole{},
spec.NamespacedName{},
"wrong-format",
[]*config.InfrastructureRole{},
},
// configmap without a secret
{
[]*config.InfrastructureRole{},
spec.NamespacedName{},
"userkey: test-user, passwordkey: test-password, rolekey: test-role, template: false",
"userkey: test-user, passwordkey: test-password, rolekey: test-role",
[]*config.InfrastructureRole{},
},
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/util/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ type InfrastructureRole struct {
PasswordKey string
RoleKey string

DefaultUserValue string
DefaultRoleValue string

// This field point out the detailed yaml definition of the role, if exists
Details string

Expand Down