Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K8SPXC-377: User management #1835

Open
wants to merge 56 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
3ffb20b
Add users types.
inelpandzic Sep 26, 2024
d88ee0d
Merge branch 'main' into K8SPXC-377-user-management
inelpandzic Sep 26, 2024
a67903b
update crds
inelpandzic Sep 26, 2024
070e22b
Implement user upsert and initial e2e tests added.
inelpandzic Oct 2, 2024
477d354
Implement
inelpandzic Oct 2, 2024
089fad3
Add cr example.
inelpandzic Oct 2, 2024
777d754
Update e2e test
inelpandzic Oct 2, 2024
ee0969e
Update cr example.
inelpandzic Oct 2, 2024
9b34061
Update e2e tests.
inelpandzic Oct 3, 2024
69fbce7
Fix and log
inelpandzic Oct 3, 2024
0796816
Log
inelpandzic Oct 3, 2024
590c8be
Fix pass change check.
inelpandzic Oct 3, 2024
40b075c
Fix exec
inelpandzic Oct 3, 2024
04de24e
Fix exec args.
inelpandzic Oct 3, 2024
d3ad7ba
Update e2e
inelpandzic Oct 3, 2024
51a50f1
exec
inelpandzic Oct 3, 2024
79d43ab
Call exec properly.
inelpandzic Oct 3, 2024
7e6d5bc
Fix queries
inelpandzic Oct 3, 2024
b99de0d
Fix user changed check.
inelpandzic Oct 3, 2024
5a25973
Log and cleanup
inelpandzic Oct 3, 2024
ca14ac7
fix
inelpandzic Oct 3, 2024
a1bdf21
Cleanup
inelpandzic Oct 3, 2024
83c0125
update e2e test.
inelpandzic Oct 4, 2024
988bdc6
Update e2e
inelpandzic Oct 5, 2024
eef535d
Fix import
inelpandzic Oct 5, 2024
2e31a99
Update e2e tests.
inelpandzic Oct 5, 2024
7b1c407
Update
inelpandzic Oct 5, 2024
fee134d
update test
inelpandzic Oct 5, 2024
856e48e
Update tests
inelpandzic Oct 7, 2024
99e91b0
Update tests.
inelpandzic Oct 7, 2024
c8e5315
Log
inelpandzic Oct 7, 2024
c19c84f
Get users with grants.
inelpandzic Oct 7, 2024
8750633
Update test secrets
inelpandzic Oct 7, 2024
389f372
Log
inelpandzic Oct 7, 2024
acffa51
Update
inelpandzic Oct 7, 2024
5a148e4
Update user.grants.
inelpandzic Oct 7, 2024
d302d19
log
inelpandzic Oct 7, 2024
b58634a
Fix user.grants.
inelpandzic Oct 7, 2024
d6e6715
Fix
inelpandzic Oct 7, 2024
33478a5
update
inelpandzic Oct 7, 2024
71f6021
Generate password secret
inelpandzic Oct 8, 2024
321cd97
Fix panic
inelpandzic Oct 8, 2024
95cc79d
Log
inelpandzic Oct 8, 2024
3054bac
Fix
inelpandzic Oct 8, 2024
07ca6cb
Fix
inelpandzic Oct 8, 2024
28ce249
Update e2e
inelpandzic Oct 8, 2024
380153c
Update e2e tests.
inelpandzic Oct 8, 2024
7e901ed
Cleanup
inelpandzic Oct 8, 2024
aa0701d
Add to e2e tests.
inelpandzic Oct 8, 2024
380e756
Merge branch 'main' into K8SPXC-377-user-management
inelpandzic Oct 8, 2024
0082a71
Update e2e test.
inelpandzic Oct 9, 2024
a16d3c7
Update e2e test.
inelpandzic Oct 9, 2024
99934a0
Fix e2e test.
inelpandzic Oct 9, 2024
e8ad940
Update upsertQuery logic.
inelpandzic Oct 9, 2024
f0fb89d
Refactor
inelpandzic Oct 10, 2024
471eb2c
Merge branch 'main' into K8SPXC-377-user-management
inelpandzic Oct 10, 2024
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
28 changes: 28 additions & 0 deletions config/crd/bases/pxc.percona.com_perconaxtradbclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10230,6 +10230,34 @@ spec:
versionServiceEndpoint:
type: string
type: object
users:
items:
properties:
dbs:
items:
type: string
type: array
grants:
items:
type: string
type: array
hosts:
items:
type: string
type: array
name:
type: string
passwordSecretRef:
properties:
key:
type: string
name:
type: string
type: object
withGrantOption:
type: boolean
type: object
type: array
vaultSecretName:
type: string
type: object
Expand Down
28 changes: 28 additions & 0 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11132,6 +11132,34 @@ spec:
versionServiceEndpoint:
type: string
type: object
users:
items:
properties:
dbs:
items:
type: string
type: array
grants:
items:
type: string
type: array
hosts:
items:
type: string
type: array
name:
type: string
passwordSecretRef:
properties:
key:
type: string
name:
type: string
type: object
withGrantOption:
type: boolean
type: object
type: array
vaultSecretName:
type: string
type: object
Expand Down
18 changes: 18 additions & 0 deletions deploy/cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,24 @@ spec:
requests:
memory: 100M
cpu: 200m

# users:
inelpandzic marked this conversation as resolved.
Show resolved Hide resolved
# - name: my-user
# dbs:
# - db1
# - db2
# hosts:
# - localhost
# grants:
# - SELECT
# - DELETE
# - INSERT
# withGrantOption: true
# passwordSecretRef:
# name: my-user-pwd
# key: my-user-pwd-key
# - name: my-user-two

pmm:
enabled: false
image: perconalab/pmm-client:dev-latest
Expand Down
28 changes: 28 additions & 0 deletions deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11132,6 +11132,34 @@ spec:
versionServiceEndpoint:
type: string
type: object
users:
items:
properties:
dbs:
items:
type: string
type: array
grants:
items:
type: string
type: array
hosts:
items:
type: string
type: array
name:
type: string
passwordSecretRef:
properties:
key:
type: string
name:
type: string
type: object
withGrantOption:
type: boolean
type: object
type: array
vaultSecretName:
type: string
type: object
Expand Down
28 changes: 28 additions & 0 deletions deploy/cw-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11132,6 +11132,34 @@ spec:
versionServiceEndpoint:
type: string
type: object
users:
items:
properties:
dbs:
items:
type: string
type: array
grants:
items:
type: string
type: array
hosts:
items:
type: string
type: array
name:
type: string
passwordSecretRef:
properties:
key:
type: string
name:
type: string
type: object
withGrantOption:
type: boolean
type: object
type: array
vaultSecretName:
type: string
type: object
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/custom-users/compare/select-1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
100500
1 change: 1 addition & 0 deletions e2e-tests/custom-users/compare/user-five-1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
user-five %
2 changes: 2 additions & 0 deletions e2e-tests/custom-users/compare/user-five.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GRANT SELECT ON *.* TO `user-five`@`%`
GRANT REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN ON *.* TO `user-five`@`%`
1 change: 1 addition & 0 deletions e2e-tests/custom-users/compare/user-four-1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
user-four %
3 changes: 3 additions & 0 deletions e2e-tests/custom-users/compare/user-four-2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GRANT SELECT ON *.* TO `user-four`@`%`
GRANT REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN ON *.* TO `user-four`@`%`
GRANT INSERT ON `test1`.* TO `user-four`@`%`
2 changes: 2 additions & 0 deletions e2e-tests/custom-users/compare/user-four.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GRANT SELECT ON *.* TO `user-four`@`%`
GRANT REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN ON *.* TO `user-four`@`%`
2 changes: 2 additions & 0 deletions e2e-tests/custom-users/compare/user-one-1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
user-one %
user-one 127.0.0.1
3 changes: 3 additions & 0 deletions e2e-tests/custom-users/compare/user-one-2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GRANT USAGE ON *.* TO `user-one`@`127.0.0.1`
GRANT SELECT, INSERT ON `db1`.* TO `user-one`@`127.0.0.1`
GRANT SELECT, INSERT ON `db2`.* TO `user-one`@`127.0.0.1`
3 changes: 3 additions & 0 deletions e2e-tests/custom-users/compare/user-one.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GRANT USAGE ON *.* TO `user-one`@`%`
GRANT SELECT, INSERT ON `db1`.* TO `user-one`@`%`
GRANT SELECT, INSERT ON `db2`.* TO `user-one`@`%`
1 change: 1 addition & 0 deletions e2e-tests/custom-users/compare/user-three-1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
user-three %
1 change: 1 addition & 0 deletions e2e-tests/custom-users/compare/user-three.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GRANT USAGE ON *.* TO `user-three`@`%`
1 change: 1 addition & 0 deletions e2e-tests/custom-users/compare/user-two-1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
user-two %
1 change: 1 addition & 0 deletions e2e-tests/custom-users/compare/user-two.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GRANT INSERT, UPDATE ON *.* TO `user-two`@`%`
124 changes: 124 additions & 0 deletions e2e-tests/custom-users/conf/some-name.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
apiVersion: pxc.percona.com/v1-6-0
kind: PerconaXtraDBCluster
metadata:
name: some-name
finalizers:
- percona.com/delete-pxc-pods-in-order
spec:
secretsName: my-cluster-secrets
vaultSecretName: some-name-vault
pause: false

users:
- name: user-one
dbs:
- db1
- db2
hosts:
- '%'
- '127.0.0.1'
grants:
- SELECT
- INSERT
passwordSecretRef:
name: user-secrets
key: pwd-key-one
- name: user-two
hosts:
- '%'
grants:
- INSERT
- UPDATE
passwordSecretRef:
name: user-secrets # will use default user password key
- name: user-three # will use generated password

pxc:
size: 3
image: -pxc
resources:
requests:
memory: 0.1G
cpu: 100m
limits:
memory: "1G"
cpu: "1"
volumeSpec:
persistentVolumeClaim:
resources:
requests:
storage: 2Gi
affinity:
antiAffinityTopologyKey: "kubernetes.io/hostname"
podDisruptionBudget:
maxUnavailable: 1
haproxy:
enabled: true
size: 3
image: -haproxy
affinity:
antiAffinityTopologyKey: "kubernetes.io/hostname"
tolerations:
- key: "node.alpha.kubernetes.io/unreachable"
operator: "Exists"
effect: "NoExecute"
tolerationSeconds: 6000
podDisruptionBudget:
maxUnavailable: 2
proxysql:
enabled: false
size: 2
image: -proxysql
resources:
requests:
memory: 0.1G
cpu: 100m
limits:
memory: 1G
cpu: 700m
volumeSpec:
persistentVolumeClaim:
resources:
requests:
storage: 2Gi
affinity:
antiAffinityTopologyKey: "kubernetes.io/hostname"
podDisruptionBudget:
maxUnavailable: 1
pmm:
enabled: false
image: perconalab/pmm-client:1.17.1
serverHost: monitoring-service
serverUser: pmm
backup:
image: -backup
serviceAccountName: default
storages:
pvc:
type: filesystem
volume:
persistentVolumeClaim:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
aws-s3:
type: s3
s3:
region: us-east-1
bucket: operator-testing
credentialsSecret: aws-s3-secret
minio:
type: s3
s3:
credentialsSecret: minio-secret
region: us-east-1
bucket: operator-testing
endpointUrl: http://minio-service:9000/
gcp-cs:
type: s3
s3:
credentialsSecret: gcp-cs-secret
region: us-east-1
bucket: operator-testing
endpointUrl: https://storage.googleapis.com
18 changes: 18 additions & 0 deletions e2e-tests/custom-users/conf/user-secrets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Secret
metadata:
name: user-secrets
type: Opaque
stringData:
pwd-key-one: testpass
pwd-key-two: testpass2
password: testpass3
# ---
# apiVersion: v1
# kind: Secret
# metadata:
# name: user-secrets-two
# type: Opaque
# stringData:
# pwd-key: testpass
# password: testpass
Loading
Loading