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

Add basic OpenShift support and setup [Part 1] #1955

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,19 @@ define generate-operator-manifests

mv '$(3)'/scylla-operator/templates/operator.clusterrole.yaml '$(2)'/00_operator.clusterrole.yaml
mv '$(3)'/scylla-operator/templates/operator.clusterrole_def.yaml '$(2)'/00_operator.clusterrole_def.yaml
mv '$(3)'/scylla-operator/templates/operator.clusterrole_def_openshift.yaml '$(2)'/00_operator.clusterrole_def_openshift.yaml
mv '$(3)'/scylla-operator/templates/operator_remote.clusterrole.yaml '$(2)'/00_operator_remote.clusterrole.yaml
mv '$(3)'/scylla-operator/templates/operator_remote.clusterrole_def.yaml '$(2)'/00_operator_remote.clusterrole_def.yaml
mv '$(3)'/scylla-operator/templates/view_clusterrole.yaml '$(2)'/00_scyllacluster_clusterrole_view.yaml
mv '$(3)'/scylla-operator/templates/edit_clusterrole.yaml '$(2)'/00_scyllacluster_clusterrole_edit.yaml
mv '$(3)'/scylla-operator/templates/scyllacluster_member_clusterrole.yaml '$(2)'/00_scyllacluster_member_clusterrole.yaml
mv '$(3)'/scylla-operator/templates/scyllacluster_member_clusterrole_def.yaml '$(2)'/00_scyllacluster_member_clusterrole_def.yaml
mv '$(3)'/scylla-operator/templates/scyllacluster_member_clusterrole_def_openshift.yaml '$(2)'/00_scyllacluster_member_clusterrole_def_openshift.yaml
mv '$(3)'/scylla-operator/templates/scylladbmonitoring_prometheus_clusterrole.yaml '$(2)'/00_scylladbmonitoring_prometheus_clusterrole.yaml
mv '$(3)'/scylla-operator/templates/scylladbmonitoring_prometheus_clusterrole_def.yaml '$(2)'/00_scylladbmonitoring_prometheus_clusterrole_def.yaml
mv '$(3)'/scylla-operator/templates/scylladbmonitoring_prometheus_clusterrole_def_openshift.yaml '$(2)'/00_scylladbmonitoring_prometheus_clusterrole_def_openshift.yaml
mv '$(3)'/scylla-operator/templates/scylladbmonitoring_grafana_clusterrole.yaml '$(2)'/00_scylladbmonitoring_grafana_clusterrole.yaml
mv '$(3)'/scylla-operator/templates/scylladbmonitoring_grafana_clusterrole_def_openshift.yaml '$(2)'/00_scylladbmonitoring_grafana_clusterrole_def_openshift.yaml

mv '$(3)'/scylla-operator/templates/issuer.yaml '$(2)'/10_issuer.yaml
mv '$(3)'/scylla-operator/templates/certificate.yaml '$(2)'/10_certificate.yaml
Expand Down Expand Up @@ -415,6 +420,7 @@ define generate-manager-manifests-prod
mv '$(3)'/scylla-manager/templates/manager_service.yaml '$(2)'/10_manager_service.yaml
mv '$(3)'/scylla-manager/templates/manager_serviceaccount.yaml '$(2)'/10_manager_serviceaccount.yaml
mv '$(3)'/scylla-manager/templates/manager_configmap.yaml '$(2)'/10_manager_configmap.yaml
mv '$(3)'/scylla-manager/templates/manager_networkpolicy.yaml '$(2)'/10_manager_networkpolicy.yaml

mv '$(3)'/scylla-manager/templates/controller_clusterrolebinding.yaml '$(2)'/20_controller_clusterrolebinding.yaml

Expand Down Expand Up @@ -517,7 +523,6 @@ verify-deploy:
$(diff) -r '$(tmp_dir)'/manager/dev deploy/manager/dev
$(call concat-manifests,$(sort $(wildcard ./deploy/manager/dev/*.yaml)),'$(tmp_dir)'/manager-dev.yaml)
$(diff) '$(tmp_dir)'/manager-dev.yaml deploy/manager-dev.yaml

.PHONY: verify-deploy

# $1 - file name
Expand Down
1 change: 1 addition & 0 deletions assets/monitoring/grafana/v1alpha1/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ spec:
labels:
scylla-operator.scylladb.com/deployment-name: "{{ .scyllaDBMonitoringName }}-grafana"
spec:
serviceAccountName: "{{ .scyllaDBMonitoringName }}-grafana"
affinity:
{{- .affinity | toYAML | nindent 8 }}
tolerations:
Expand Down
7 changes: 7 additions & 0 deletions assets/monitoring/grafana/v1alpha1/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
rbacv1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/runtime"
)

Expand All @@ -31,6 +32,12 @@ var (
return ParseObjectTemplateOrDie[*corev1.ServiceAccount]("grafana-sa", grafanaSATemplateString)
})

//go:embed "rolebinding.yaml"
grafanaRoleBindingTemplateString string
GrafanaRoleBindingTemplate = lazy.New(func() *assets.ObjectTemplate[*rbacv1.RoleBinding] {
return ParseObjectTemplateOrDie[*rbacv1.RoleBinding]("grafana-rolebinding", grafanaRoleBindingTemplateString)
})

//go:embed "configs.cm.yaml"
grafanaConfigsTemplateString string
GrafanaConfigsTemplate = lazy.New(func() *assets.ObjectTemplate[*corev1.ConfigMap] {
Expand Down
12 changes: 12 additions & 0 deletions assets/monitoring/grafana/v1alpha1/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: "{{ .scyllaDBMonitoringName }}-grafana"
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: scylladb:monitoring:grafana
subjects:
- kind: ServiceAccount
name: "{{ .scyllaDBMonitoringName }}-grafana"
namespace: "{{ .namespace }}"
19 changes: 19 additions & 0 deletions deploy/manager-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,25 @@ data:
hosts:
- scylla-manager-cluster-manager-dc-manager-rack-0

---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
namespace: scylla-manager
name: scylla-manager-to-scylla-pod
spec:
policyTypes:
- Ingress
podSelector:
matchLabels:
app.kubernetes.io/managed-by: scylla-operator
app.kubernetes.io/name: scylla
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: scylla-manager

---
apiVersion: v1
kind: Service
Expand Down
19 changes: 19 additions & 0 deletions deploy/manager-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,25 @@ data:
hosts:
- scylla-manager-cluster-manager-dc-manager-rack-0

---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
namespace: scylla-manager
name: scylla-manager-to-scylla-pod
spec:
policyTypes:
- Ingress
podSelector:
matchLabels:
app.kubernetes.io/managed-by: scylla-operator
app.kubernetes.io/name: scylla
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: scylla-manager

---
apiVersion: v1
kind: Service
Expand Down
17 changes: 17 additions & 0 deletions deploy/manager/dev/10_manager_networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
namespace: scylla-manager
name: scylla-manager-to-scylla-pod
spec:
policyTypes:
- Ingress
podSelector:
matchLabels:
app.kubernetes.io/managed-by: scylla-operator
app.kubernetes.io/name: scylla
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: scylla-manager
17 changes: 17 additions & 0 deletions deploy/manager/prod/10_manager_networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
namespace: scylla-manager
name: scylla-manager-to-scylla-pod
spec:
policyTypes:
- Ingress
podSelector:
matchLabels:
app.kubernetes.io/managed-by: scylla-operator
app.kubernetes.io/name: scylla
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: scylla-manager
153 changes: 153 additions & 0 deletions deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,91 @@ rules:
- patch
- update
- delete
- apiGroups:
- ""
resources:
- configmaps/finalizers
- secrets/finalizers
- pods/finalizers
verbs:
- update
- apiGroups:
- apps
resources:
- daemonsets/finalizers
verbs:
- update
- apiGroups:
- scylla.scylladb.com
resources:
- scyllaclusters/finalizers
- scylladbdatacenters/finalizers
- scylladbmonitorings/finalizers
verbs:
- update
- apiGroups:
- policy
resources:
- poddisruptionbudgets/finalizers
verbs:
- update
- apiGroups:
- scylla.scylladb.com
resources:
- nodeconfigs/finalizers
verbs:
- update
- apiGroups:
- ""
resources:
- configmaps/finalizers
- secrets/finalizers
- pods/finalizers
verbs:
- update
- apiGroups:
- apps
resources:
- daemonsets/finalizers
verbs:
- update
- apiGroups:
- scylla.scylladb.com
resources:
- scyllaclusters/finalizers
- scylladbdatacenters/finalizers
- scylladbmonitorings/finalizers
verbs:
- update
- apiGroups:
- policy
resources:
- poddisruptionbudgets/finalizers
verbs:
- update
- apiGroups:
- scylla.scylladb.com
resources:
- nodeconfigs/finalizers
verbs:
- update

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: scylladb:controller:aggregate-to-operator-openshift
labels:
rbac.operator.scylladb.com/aggregate-to-scylla-operator: "true"
rules:
- apiGroups:
- security.openshift.io
resourceNames:
- privileged
resources:
- securitycontextconstraints
verbs:
- use

---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down Expand Up @@ -27904,6 +27989,57 @@ rules:
- scyllaclusters
verbs:
- get
- apiGroups:
- ""
resources:
- configmaps/finalizers
- secrets/finalizers
verbs:
- update

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: scylladb:aggregate-to-scyllacluster-member-openshift
labels:
rbac.operator.scylladb.com/aggregate-to-scylla-member: "true"
rules:
- apiGroups:
- security.openshift.io
resourceNames:
- privileged
resources:
- securitycontextconstraints
verbs:
- use

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: scylladb:monitoring:grafana
aggregationRule:
clusterRoleSelectors:
- matchLabels:
rbac.operator.scylladb.com/aggregate-to-scylladb-monitoring-grafana: "true"

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: scylladb:aggregate-to-scylladb-monitoring-grafana-openshift
labels:
rbac.operator.scylladb.com/aggregate-to-scylladb-monitoring-grafana: "true"
rules:
- apiGroups:
- security.openshift.io
resourceNames:
- privileged
resources:
- securitycontextconstraints
verbs:
- use

---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down Expand Up @@ -27940,6 +28076,23 @@ rules:
verbs:
- get

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: scylladb:aggregate-to-scylladb-monitoring-prometheus-openshift
labels:
rbac.operator.scylladb.com/aggregate-to-scylladb-monitoring-prometheus: "true"
rules:
- apiGroups:
- security.openshift.io
resourceNames:
- privileged
resources:
- securitycontextconstraints
verbs:
- use

---
apiVersion: cert-manager.io/v1
kind: Certificate
Expand Down
Loading