diff --git a/README.md b/README.md index 9199101b5..a43b5ecbc 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ The MySQL Operator provides the following core features: ## Requirements - * Kubernetes 1.7.0 + + * Kubernetes 1.8.0 + ## Contributing diff --git a/cmd/mysql-operator/app/mysql_operator.go b/cmd/mysql-operator/app/mysql_operator.go index db8055df4..9d7a0ae90 100644 --- a/cmd/mysql-operator/app/mysql_operator.go +++ b/cmd/mysql-operator/app/mysql_operator.go @@ -73,11 +73,6 @@ func Run(s *options.MySQLOperatorServer) error { kubeClient := kubernetes.NewForConfigOrDie(kubeconfig) mysqlopClient := mysqlop.NewForConfigOrDie(kubeconfig) - serverVersion, err := kubeClient.Discovery().ServerVersion() - if err != nil { - glog.Fatalf("Failed to discover Kubernetes API server version: %v", err) - } - // Shared informers (non namespace specific). operatorInformerFactory := informers.NewFilteredSharedInformerFactory(mysqlopClient, resyncPeriod(s)(), s.Namespace, nil) kubeInformerFactory := kubeinformers.NewFilteredSharedInformerFactory(kubeClient, resyncPeriod(s)(), s.Namespace, nil) @@ -88,12 +83,10 @@ func Run(s *options.MySQLOperatorServer) error { *s, mysqlopClient, kubeClient, - serverVersion, operatorInformerFactory.Mysql().V1().MySQLClusters(), kubeInformerFactory.Apps().V1beta1().StatefulSets(), kubeInformerFactory.Core().V1().Pods(), kubeInformerFactory.Core().V1().Services(), - kubeInformerFactory.Core().V1().ConfigMaps(), 30*time.Second, s.Namespace, ) diff --git a/contrib/manifests/rbac.yaml b/contrib/manifests/rbac.yaml index ea7973dd0..a00f491c9 100644 --- a/contrib/manifests/rbac.yaml +++ b/contrib/manifests/rbac.yaml @@ -3,45 +3,141 @@ apiVersion: v1 kind: ServiceAccount metadata: name: mysql-operator + --- apiVersion: v1 kind: ServiceAccount metadata: name: mysql-agent + --- apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRole +kind: Role metadata: name: mysql-operator rules: - apiGroups: - - "*" + - "" resources: - - "*" + - pods verbs: - - "*" + - get + - list + - patch + - update + - watch + + - apiGroups: + - "" + resources: + - secrets + verbs: + - create + + - apiGroups: + - "" + resources: + - services + verbs: + - create + - get + - list + - watch + + - apiGroups: + - apps + resources: + - statefulsets + verbs: + - create + - get + - list + - patch + - update + - watch + + - apiGroups: + - mysql.oracle.com + resources: + - mysqlbackups + - mysqlbackupschedules + - mysqlclusters + - mysqlrestores + verbs: + - get + - list + - patch + - update + - watch + + - apiGroups: + - mysql.oracle.com + resources: + - mysqlbackups + verbs: + - create + --- apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRoleBinding +kind: ClusterRole +metadata: + name: mysql-agent +rules: + - apiGroups: + - "" + resources: + - pods + verbs: + - get + - list + - patch + - update + - watch + + - apiGroups: + - "" + resources: + - secrets + verbs: + - get + + - apiGroups: + - mysql.oracle.com + resources: + - mysqlbackups + - mysqlbackupschedules + - mysqlclusters + - mysqlrestores + verbs: + - get + - list + - patch + - update + - watch + +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: RoleBinding metadata: name: mysql-operator roleRef: apiGroup: rbac.authorization.k8s.io - kind: ClusterRole + kind: Role name: mysql-operator subjects: - kind: ServiceAccount name: mysql-operator namespace: + --- -kind: ClusterRoleBinding +kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1beta1 metadata: name: mysql-agent roleRef: apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: mysql-operator + kind: Role + name: mysql-agent subjects: - kind: ServiceAccount name: mysql-agent diff --git a/docs/tutorial.md b/docs/tutorial.md index e203a2dd8..d74396cb0 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -47,10 +47,10 @@ To install the chart in a cluster without RBAC with the release name `my-release $ helm install --name my-release mysql-operator ``` -If your cluster has RBAC enabled then you will need to run: +If your cluster has RBAC disabled then you will need to run: ```console -$ helm install --name my-release mysql-operator --set rbac.enabled=true +$ helm install --name my-release mysql-operator --set rbac.enabled=false ``` The above command deploys the MySQL Operator on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. @@ -73,11 +73,38 @@ The following tables lists the configurable parameters of the MySQL-operator cha Parameter | Description | Default --------- | ----------- | ------- -`rbac.enabled` | If true, enables RBAC | `false` +`rbac.enabled` | If true, enables RBAC | `true` `operator.namespace` | Controls the namespace in which the operator is deployed | `mysql-operator` ## Create a simple MySQL cluster +The first time you create a MySQL Cluster in a namespace you need to create the +`mysql-agent` ServiceAccount and RoleBinding in that namespace: + +```bash +$ cat < "${KUBECONFIG}" - ginkgo -nodes=4 -v test/e2e -- \ + ginkgo \ + -nodes=5 \ + -v \ + test/e2e -- \ --kubeconfig="${KUBECONFIG}" \ --operator-version="$(cat dist/version.txt)" \ --s3-access-key="${S3_ACCESS_KEY}" \