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

Support multiple namespaces #666

Merged
merged 17 commits into from
Mar 10, 2025
Merged
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
21 changes: 21 additions & 0 deletions deploy/role.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: vitess-operator-subcontroller
namespace: example
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this supposed to be in the default namespace?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not the subcontroller if it is meant for backups, but there are tons of places in this PR where vitess-operator is in the example namespace.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this is just creating metadata both both namespaces. It wasn't obvious from the diff, but at line 25, the namespace is implicitly default.

rules:
- apiGroups:
- planetscale.com
resources:
- vitessshards
- vitessshards/status
- vitessshards/finalizers
- vitessbackups
- vitessbackups/status
- vitessbackups/finalizers
- vitessbackupstorages
- vitessbackupstorages/status
- vitessbackupstorages/finalizers
verbs:
- '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: vitess-operator
rules:
Expand Down
21 changes: 18 additions & 3 deletions deploy/role_binding.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: vitess-operator
name: vitess-operator-subcontroller
namespace: example
subjects:
- kind: ServiceAccount
name: vitess-operator
- kind: ServiceAccount
name: vitess-operator
namespace: example
roleRef:
kind: Role
name: vitess-operator-subcontroller
apiGroup: rbac.authorization.k8s.io
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: vitess-operator
subjects:
- kind: ServiceAccount
name: vitess-operator
namespace: default
roleRef:
kind: ClusterRole
name: vitess-operator
apiGroup: rbac.authorization.k8s.io
6 changes: 6 additions & 0 deletions deploy/service_account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: vitess-operator
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: vitess-operator
namespace: example
2 changes: 1 addition & 1 deletion test/endtoend/backup_restore_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ echo "Make temporary directory for the test"
mkdir -p -m 777 ./vtdataroot/backup
echo "Building the docker image"
docker build -f build/Dockerfile.release -t vitess-operator-pr:latest .
echo "Setting up the kind config"
setupKindConfig
createKindCluster

cd "$PWD/test/endtoend/operator"
killall kubectl
setupKubectlAccessForCI

createExampleNamespace
get_started "operator-latest.yaml" "101_initial_cluster_backup.yaml"
verifyVtGateVersion "22.0.0"
checkSemiSyncSetup
Expand Down
3 changes: 2 additions & 1 deletion test/endtoend/backup_schedule_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function verifyListBackupsOutputWithSchedule() {
for i in {1..600} ; do
# Ensure that we can view the backup files from the host.
docker exec -it $(docker container ls --format '{{.Names}}' | grep kind) chmod o+rwx -R /backup > /dev/null
backupCount=$(kubectl get vtb --no-headers | wc -l)
backupCount=$(kubectl get vtb -n example --no-headers | wc -l)
echo "Found ${backupCount} backups"
if [[ "${backupCount}" -ge 3 ]]; then
echo -e "Check for Jobs' pods"
Expand Down Expand Up @@ -51,6 +51,7 @@ cd "$PWD/test/endtoend/operator"
killall kubectl
setupKubectlAccessForCI

createExampleNamespace
get_started "operator-latest.yaml" "101_initial_cluster_backup_schedule.yaml"
verifyVtGateVersion "22.0.0"
checkSemiSyncSetup
Expand Down
5 changes: 3 additions & 2 deletions test/endtoend/hpa_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source ./test/endtoend/utils.sh

function verifyHpaCount() {
expectedCount=$1
count=$(kubectl get hpa --no-headers | wc -l)
count=$(kubectl get hpa -n example --no-headers | wc -l)
if [[ "$count" -eq "$expectedCount" ]]; then
echo "HorizontalPodAutoscaler count is $count"
return 0
Expand All @@ -17,7 +17,7 @@ function verifyHpaCount() {
function verifyHpaWithTimeout() {
regex=$1
for i in {1..600} ; do
out=$(kubectl get hpa --no-headers)
out=$(kubectl get hpa -n example --no-headers)
echo "$out" | grep -E "$regex" > /dev/null 2>&1
if [[ $? -eq 0 ]]; then
echo "HorizontalPodAutoscaler $regex found"
Expand All @@ -41,6 +41,7 @@ cd "$PWD/test/endtoend/operator"
killall kubectl
setupKubectlAccessForCI

createExampleNamespace
get_started "operator-latest.yaml" "101_initial_cluster_autoscale.yaml"
verifyVtGateVersion "22.0.0"
checkSemiSyncSetup
Expand Down
2 changes: 2 additions & 0 deletions test/endtoend/operator/101_initial_cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ apiVersion: planetscale.com/v2
kind: VitessCluster
metadata:
name: example
namespace: example
spec:
backup:
engine: xtrabackup
Expand Down Expand Up @@ -103,6 +104,7 @@ apiVersion: v1
kind: Secret
metadata:
name: example-cluster-config
namespace: example
type: Opaque
stringData:
users.json: |
Expand Down
2 changes: 2 additions & 0 deletions test/endtoend/operator/101_initial_cluster_autoscale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ apiVersion: planetscale.com/v2
kind: VitessCluster
metadata:
name: example
namespace: example
spec:
images:
vtctld: vitess/lite:latest
Expand Down Expand Up @@ -96,6 +97,7 @@ apiVersion: v1
kind: Secret
metadata:
name: example-cluster-config
namespace: example
type: Opaque
stringData:
users.json: |
Expand Down
5 changes: 3 additions & 2 deletions test/endtoend/operator/101_initial_cluster_backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ apiVersion: planetscale.com/v2
kind: VitessCluster
metadata:
name: example
namespace: example
spec:
backup:
engine: xtrabackup
Expand All @@ -21,7 +22,7 @@ spec:
vtorc: vitess/lite:latest
vtbackup: vitess/lite:latest
mysqld:
mysql80Compatible: mysql:8.0.40
mysql80Compatible: vitess/lite:latest
mysqldExporter: prom/mysqld-exporter:v0.14.0
cells:
- name: zone1
Expand Down Expand Up @@ -78,7 +79,6 @@ spec:
vttablet:
extraFlags:
db_charset: utf8mb4
wait_for_backup_interval: "0"
resources:
limits:
memory: 512Mi
Expand All @@ -104,6 +104,7 @@ apiVersion: v1
kind: Secret
metadata:
name: example-cluster-config
namespace: example
type: Opaque
stringData:
users.json: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ apiVersion: planetscale.com/v2
kind: VitessCluster
metadata:
name: example
namespace: example
spec:
backup:
engine: xtrabackup
Expand Down Expand Up @@ -109,7 +110,6 @@ spec:
vttablet:
extraFlags:
db_charset: utf8mb4
wait_for_backup_interval: "0"
resources:
limits:
memory: 1024Mi
Expand All @@ -135,6 +135,7 @@ apiVersion: v1
kind: Secret
metadata:
name: example-cluster-config
namespace: example
type: Opaque
stringData:
users.json: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ apiVersion: planetscale.com/v2
kind: VitessCluster
metadata:
name: example
namespace: example
spec:
images:
vtctld: vitess/lite:latest
Expand Down Expand Up @@ -94,6 +95,7 @@ apiVersion: v1
kind: Secret
metadata:
name: example-cluster-config
namespace: example
type: Opaque
stringData:
users.json: |
Expand Down Expand Up @@ -210,6 +212,7 @@ apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pv-claim
namespace: example
spec:
accessModes:
- ReadWriteOnce
Expand All @@ -221,6 +224,7 @@ apiVersion: v1
kind: Service
metadata:
name: mysql
namespace: example
labels:
app: mysql
spec:
Expand All @@ -234,6 +238,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
namespace: example
spec:
replicas: 1
selector:
Expand Down
2 changes: 2 additions & 0 deletions test/endtoend/operator/101_initial_cluster_vtorc_vtadmin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ apiVersion: planetscale.com/v2
kind: VitessCluster
metadata:
name: example
namespace: example
spec:
images:
vtctld: vitess/lite:latest
Expand Down Expand Up @@ -111,6 +112,7 @@ apiVersion: v1
kind: Secret
metadata:
name: example-cluster-config
namespace: example
type: Opaque
stringData:
users.json: |
Expand Down
1 change: 1 addition & 0 deletions test/endtoend/operator/102_keyspace_teardown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ apiVersion: planetscale.com/v2
kind: VitessCluster
metadata:
name: example
namespace: example
spec:
backup:
engine: xtrabackup
Expand Down
1 change: 1 addition & 0 deletions test/endtoend/operator/201_customer_tablets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: planetscale.com/v2
kind: VitessCluster
metadata:
name: example
namespace: example
spec:
backup:
engine: xtrabackup
Expand Down
1 change: 1 addition & 0 deletions test/endtoend/operator/302_new_shards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: planetscale.com/v2
kind: VitessCluster
metadata:
name: example
namespace: example
spec:
backup:
engine: xtrabackup
Expand Down
1 change: 1 addition & 0 deletions test/endtoend/operator/306_down_shard_0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: planetscale.com/v2
kind: VitessCluster
metadata:
name: example
namespace: example
spec:
backup:
engine: xtrabackup
Expand Down
1 change: 1 addition & 0 deletions test/endtoend/operator/401_scheduled_backups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: planetscale.com/v2
kind: VitessCluster
metadata:
name: example
namespace: example
spec:
backup:
engine: xtrabackup
Expand Down
1 change: 1 addition & 0 deletions test/endtoend/operator/cluster_autoscale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ apiVersion: planetscale.com/v2
kind: VitessCluster
metadata:
name: example
namespace: example
spec:
images:
vtctld: vitess/lite:latest
Expand Down
1 change: 1 addition & 0 deletions test/endtoend/operator/cluster_upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ apiVersion: planetscale.com/v2
kind: VitessCluster
metadata:
name: example
namespace: example
spec:
backup:
engine: xtrabackup
Expand Down
Loading