Mysql On Raspberry Kubernetes
Steps of creation
- Create Secrets:
- Create Glusterfs
- Creates Pv and PVC
- Create Mysql.yaml file
- Create mysql database, with user's permissions
- Expose Service
- Usefull links
1. Create secrets
https://kubernetes.io/docs/concepts/configuration/secret/
# Create files needed for rest of example.
$ echo -n 'admin' > ./username.txt
$ echo -n '1f2d1e2e67df' > ./password.txt
kubectl create secret generic db-user-pass --from-file=./username.txt --from-file=./password.txt
secret "db-user-pass" created
##Describe password
$ kubectl get secrets
$ kubectl describe secrets/db-user-pass
2. Create Glusterfs
...
3. Creates Pv and PVC
...
4. Create Mysql.yaml file
First try with hypriot/rpi-mysql, with no success due to lack of privillege to access root@localhost, via mysql -u root -p. But after several try I realize that db files store in shared pvc, are corrupted, and I have to delete them in order to get a clean initialization.
And it seems impossible to restart Mysql with --skip-grant-tables in a container, as I used in normal mysql instance.
\#Not working in K8 mysql container:
sudo service mysql stop
sudo /usr/bin/mysqld_safe --skip-grant-tables &
So I tried the arm Docker image file of tobi312/rpi-mysql, with empty data reportory and I was able to connect to db, with:
mysql -u root -p
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';
SHOW GRANTS FOR 'username'@'%';
5. Create mysql database, with user's permissions
```mysq_setpermission```
6. Expose service
I try first with a service declaration file .yaml, but with no success
External-Ip seems, not to be linked with internal IP container
After that I try to expose directl with following command, with success:
kc expose deploy mysql --name=mysql-svc --external-ip=192.168.1.30
7. Usefull links
- How to initialize grant permisson on startup
- Kubernetes par l'exemple
- Doc qui peut être intéressante sur l'install par défaut d'une debian
- kubernetes-engine-samples_mysql.yaml
Notes: Using shared directory may corrupt all new instances, if files get some errors. In this case, solution is to delete all files, and restart from a brand new install..
Attention l'utilisation d'un répertoire partagé peut véroler toutes les nouvelles instances, si les fichiers contiennent des erreurs. Dans ce cas là il faut les effacer, pour repartir d'une installation saine...