Explorar o código

Probando el mysql operator

Celestino Rey hai 7 meses
pai
achega
d99ba1629c

+ 56 - 0
MysqlOperator/README.md

@@ -0,0 +1,56 @@
+# MySQL Operator for Kubernetes Installation
+
+## Using Manifest Files with kubectl
+
+First deploy the Custom Resource Definition (CRDs):
+
+    kubectl apply -f https://raw.githubusercontent.com/mysql/mysql-operator/9.6.0-2.2.7/deploy/deploy-crds.yaml
+
+Then deploy MySQL Operator for Kubernetes:
+
+    kubectl apply -f https://raw.githubusercontent.com/mysql/mysql-operator/9.6.0-2.2.7/deploy/deploy-operator.yaml
+
+Verify the operator is running by checking the deployment inside the mysql-operator namespace:
+
+    kubectl get deployment -n mysql-operator mysql-operator
+
+    NAME             READY   UP-TO-DATE   AVAILABLE   AGE
+    mysql-operator   1/1     1            1           1h
+
+
+# MySQL InnoDB Cluster Installation
+
+## Using kubectl
+
+For creating a MySQL InnoDB Cluster, first create a secret with credentials for a MySQL root user used to perform administrative tasks in the cluster. For example:
+
+    kubectl create secret generic mypwds \
+        --from-literal=rootUser=root \
+        --from-literal=rootHost=% \
+        --from-literal=rootPassword="sakila"
+
+Define your MySQL InnoDB Cluster, which references the secret. For example:
+
+    apiVersion: mysql.oracle.com/v2
+    kind: InnoDBCluster
+    metadata:
+      name: mycluster
+    spec:
+      secretName: mypwds
+      tlsUseSelfSigned: true
+      instances: 3
+      router:
+        instances: 1
+
+Assuming it's saved as mycluster.yaml, deploy it:
+
+    kubectl apply -f mycluster.yaml
+
+This sample creates an InnoDB Cluster with three MySQL Server instances and one MySQL Router instance. The process can be observed using:
+
+    kubectl get innodbcluster --watch
+
+    NAME          STATUS    ONLINE   INSTANCES   ROUTERS   AGE
+    mycluster     PENDING   0        3           1         2m6s
+    ...
+    mycluster     ONLINE    3        3           1         10s

+ 10 - 0
MysqlOperator/mysql-innodb-cluster.yaml

@@ -0,0 +1,10 @@
+apiVersion: mysql.oracle.com/v2
+kind: InnoDBCluster
+metadata:
+  name: mycluster
+spec:
+  secretName: mypwds
+  tlsUseSelfSigned: true
+  instances: 1
+  router:
+    instances: 1

+ 8 - 0
MysqlOperator/secreto.yaml

@@ -0,0 +1,8 @@
+apiVersion: v1
+kind: Secret
+metadata:
+  name: mypwds
+data:
+  rootPassword: RHNhLTAyMTM=
+  rootUser: cm9vdA==
+  rootHost: JQ==

+ 2 - 2
WordpresSite/borraTodo.sh

@@ -1,8 +1,8 @@
-kubectl delete -f mysql-deployment.yaml
+#kubectl delete -f mysql-deployment.yaml
 kubectl delete -f wordpress-service.yaml
 kubectl delete -f wordpress-deployment.yaml
 kubectl delete -f php-deployment.yaml
-kubectl delete -f pvc-mysql.yaml
+#kubectl delete -f pvc-mysql.yaml
 kubectl delete -f pvc-wordpress.yaml
 kubectl delete -f wordpress-ingress.yaml
 kubectl delete -f wordpress-secrets.yaml

+ 2 - 2
WordpresSite/creaTodo.sh

@@ -1,8 +1,8 @@
-kubectl create -f mysql-deployment.yaml
+#kubectl create -f mysql-deployment.yaml
 kubectl create -f wordpress-deployment.yaml
 kubectl create -f wordpress-service.yaml
 kubectl create -f php-deployment.yaml
-kubectl create -f pvc-mysql.yaml
+#kubectl create -f pvc-mysql.yaml
 kubectl create -f pvc-wordpress.yaml
 kubectl create -f wordpress-ingress.yaml
 kubectl create -f wordpress-secrets.yaml

+ 1 - 1
WordpresSite/php-deployment.yaml

@@ -44,7 +44,7 @@ spec:
               name: phpmyadm
           env:
             - name: PMA_HOST
-              value: wordpress-mysql
+              value: mycluster.default.svc.cluster.local
             - name: PMA_PORT
               value: "3306"
             - name: MYSQL_ROOT_PASSWORD

+ 1 - 1
WordpresSite/pvc-wordpress.yaml

@@ -10,5 +10,5 @@ spec:
     - ReadWriteOnce
   resources:
     requests:
-      storage: 1Gi
+      storage: 2Gi
 ---

+ 1 - 1
WordpresSite/wordpress-deployment.yaml

@@ -23,7 +23,7 @@ spec:
         name: wordpress
         env:
         - name: WORDPRESS_DB_HOST
-          value: wordpress-mysql 
+          value: mycluster.default.svc.cluster.local
         - name: WORDPRESS_DB_PASSWORD
           valueFrom:
             secretKeyRef:

+ 4 - 7
WordpresSite/wordpress-service.yaml

@@ -6,14 +6,11 @@ metadata:
   labels:
     app: wordpress
 spec:
-  #type: NodePort
-  #ports:
-  #- port: 80
-  #nodePort: 30088
-  #targetPort: wordpress
+  type: NodePort
   ports:
-    - port: 80
-  type: LoadBalancer
+  - port: 80
+    nodePort: 30088
+    targetPort: wordpress
   selector:
     app: wordpress
     tier: frontend