Skip to content

Commit 5335a71

Browse files
authored
K8SPS-241: Cluster-wide support (#673)
* Generate cw-* files. * Fix env var. * Fix kustomize. * Regenerate cw files. * Update deploy_operator test function. * Get correct client. * Fix import. * Check OPERATOR_NS env var in tests. * Regenerate cw files. * Remove operator_ns env var for pmm and minio. * Update tests. * Update tests. * Fix test. * Fix tests. * remove comment
1 parent 34fc8bf commit 5335a71

26 files changed

+11159
-86
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ manifests: kustomize generate
108108
echo "---" >> $(DEPLOYDIR)/operator.yaml
109109
cat $(DEPLOYDIR)/crd.yaml $(DEPLOYDIR)/rbac.yaml $(DEPLOYDIR)/operator.yaml > $(DEPLOYDIR)/bundle.yaml
110110

111+
$(KUSTOMIZE) build config/rbac/cluster/ > $(DEPLOYDIR)/cw-rbac.yaml
112+
echo "---" >> $(DEPLOYDIR)/cw-rbac.yaml
113+
cd config/manager/cluster && $(KUSTOMIZE) edit set image perconalab/percona-server-mysql-operator=$(IMAGE)
114+
$(KUSTOMIZE) build config/manager/cluster/ > $(DEPLOYDIR)/cw-operator.yaml
115+
echo "---" >> $(DEPLOYDIR)/cw-operator.yaml
116+
cat $(DEPLOYDIR)/crd.yaml $(DEPLOYDIR)/cw-rbac.yaml $(DEPLOYDIR)/cw-operator.yaml > $(DEPLOYDIR)/cw-bundle.yaml
117+
111118
gen-versionservice-client: swagger
112119
rm pkg/version/service/version.swagger.yaml
113120
curl https://raw.githubusercontent.com/Percona-Lab/percona-version-service/main/api/version.swagger.yaml --output pkg/version/service/version.swagger.yaml

cmd/manager/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3636
ctrl "sigs.k8s.io/controller-runtime"
3737
"sigs.k8s.io/controller-runtime/pkg/cache"
38-
"sigs.k8s.io/controller-runtime/pkg/client"
3938
"sigs.k8s.io/controller-runtime/pkg/healthz"
4039
"sigs.k8s.io/controller-runtime/pkg/log/zap"
4140
metricsServer "sigs.k8s.io/controller-runtime/pkg/metrics/server"
@@ -134,7 +133,7 @@ func main() {
134133
os.Exit(1)
135134
}
136135

137-
nsClient := client.NewNamespacedClient(mgr.GetClient(), namespace)
136+
nsClient := mgr.GetClient()
138137

139138
cliCmd, err := clientcmd.NewClient()
140139
if err != nil {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
2+
kind: ControllerManagerConfig
3+
health:
4+
healthProbeBindAddress: :8081
5+
metrics:
6+
bindAddress: 127.0.0.1:8080
7+
webhook:
8+
port: 9443
9+
leaderElection:
10+
leaderElect: true
11+
resourceName: 08db2feb.percona.com
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
resources:
2+
- manager.yaml
3+
4+
generatorOptions:
5+
disableNameSuffixHash: true
6+
7+
configMapGenerator:
8+
- files:
9+
- controller_manager_config.yaml
10+
name: percona-server-mysql-operator-config
11+
apiVersion: kustomize.config.k8s.io/v1beta1
12+
kind: Kustomization
13+
images:
14+
- name: perconalab/percona-server-mysql-operator
15+
newName: perconalab/percona-server-mysql-operator
16+
newTag: main

config/manager/cluster/manager.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: percona-server-mysql-operator
6+
spec:
7+
selector:
8+
matchLabels:
9+
app.kubernetes.io/name: percona-server-mysql-operator
10+
replicas: 1
11+
strategy:
12+
rollingUpdate:
13+
maxUnavailable: 1
14+
type: RollingUpdate
15+
template:
16+
metadata:
17+
labels:
18+
app.kubernetes.io/name: percona-server-mysql-operator
19+
spec:
20+
securityContext:
21+
runAsNonRoot: true
22+
containers:
23+
- command:
24+
- /usr/local/bin/percona-server-mysql-operator
25+
args:
26+
- --leader-elect
27+
env:
28+
- name: LOG_STRUCTURED
29+
value: 'false'
30+
- name: LOG_LEVEL
31+
value: INFO
32+
- name: WATCH_NAMESPACE
33+
value: ""
34+
- name: DISABLE_TELEMETRY
35+
value: "false"
36+
image: perconalab/percona-server-mysql-operator:main
37+
imagePullPolicy: Always
38+
name: manager
39+
securityContext:
40+
allowPrivilegeEscalation: false
41+
livenessProbe:
42+
httpGet:
43+
path: /healthz
44+
port: 8081
45+
initialDelaySeconds: 15
46+
periodSeconds: 20
47+
readinessProbe:
48+
httpGet:
49+
path: /readyz
50+
port: 8081
51+
initialDelaySeconds: 5
52+
periodSeconds: 10
53+
resources:
54+
limits:
55+
cpu: 200m
56+
memory: 100Mi
57+
requests:
58+
cpu: 100m
59+
memory: 20Mi
60+
serviceAccountName: percona-server-mysql-operator
61+
terminationGracePeriodSeconds: 10
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
resources:
2+
# All RBAC will be applied under this service account in
3+
# the deployment namespace. You may comment out this resource
4+
# if your manager will use a service account that exists at
5+
# runtime. Be sure to update RoleBinding and ClusterRoleBinding
6+
# subjects if changing service account names.
7+
- service_account.yaml
8+
- role.yaml
9+
- role_binding.yaml
10+
- leader_election_role.yaml
11+
- leader_election_role_binding.yaml
12+
- orchestrator_service_account.yaml
13+
- orchestrator_role.yaml
14+
- orchestrator_role_binding.yaml
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
resources:
2+
# All RBAC will be applied under this service account in
3+
# the deployment namespace. You may comment out this resource
4+
# if your manager will use a service account that exists at
5+
# runtime. Be sure to update RoleBinding and ClusterRoleBinding
6+
# subjects if changing service account names.
7+
- service_account.yaml
8+
- role.yaml
9+
- role_binding.yaml
10+
- leader_election_role.yaml
11+
- leader_election_role_binding.yaml
12+
- orchestrator_service_account.yaml
13+
- orchestrator_role.yaml
14+
- orchestrator_role_binding.yaml
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# permissions to do leader election.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: Role
4+
metadata:
5+
name: percona-server-mysql-operator-leaderelection
6+
rules:
7+
- apiGroups:
8+
- ""
9+
resources:
10+
- configmaps
11+
verbs:
12+
- get
13+
- list
14+
- watch
15+
- create
16+
- update
17+
- patch
18+
- delete
19+
- apiGroups:
20+
- coordination.k8s.io
21+
resources:
22+
- leases
23+
verbs:
24+
- get
25+
- list
26+
- watch
27+
- create
28+
- update
29+
- patch
30+
- delete
31+
- apiGroups:
32+
- ""
33+
resources:
34+
- events
35+
verbs:
36+
- create
37+
- patch
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: RoleBinding
3+
metadata:
4+
name: percona-server-mysql-operator-leaderelection
5+
roleRef:
6+
apiGroup: rbac.authorization.k8s.io
7+
kind: Role
8+
name: percona-server-mysql-operator-leaderelection
9+
subjects:
10+
- kind: ServiceAccount
11+
name: percona-server-mysql-operator
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: Role
4+
metadata:
5+
name: percona-server-mysql-operator-orchestrator
6+
rules:
7+
- apiGroups:
8+
- ""
9+
resources:
10+
- pods
11+
verbs:
12+
- list
13+
- patch
14+
- apiGroups:
15+
- ps.percona.com
16+
resources:
17+
- perconaservermysqls
18+
verbs:
19+
- get

0 commit comments

Comments
 (0)