Scenario-301: Use helm To Deploy Service I
- Objective: Know the basic usage of helm
- Requirements:
1. Use helm to deploy a mysql service with single instance
2. Customize helm deployment: configure mysql root password
- What's Helm? Why we need Helm?
Helm is the Kubernetes Package Manager.
Community provides well-organized deployment solutions for typical services
- Our focus is helm, thus we use mninikube for this study
minikube start
https://github.com/kubernetes/helm
https://github.com/kubernetes/charts/tree/master/stable/mysql
- Start Helm
cd challenges-kubernetes/Scenario-301/
helm init
helm repo update
helm list
- Create volume for mysql
Create folder to hold the data
minikube ssh
sudo mkdir -p /data
sudo chmod 777 /data
exit
Create pv with pv.yaml
kubectl apply -f ./pv.yaml
- Run helm Deployment
export mysqlRootPassword="secretpassword"
helm install --name mysql-release \
--set mysqlRootPassword=${mysqlRootPassword},mysqlUser=my-user,mysqlPassword=my-password,mysqlDatabase=my-database \
stable/mysql
helm status mysql-release
kubectl get pvc
kubectl get pv
kubectl get pod
export mysqlRootPassword="secretpassword"
kubectl run -i --tty --rm mysql-client --image=mysql --restart=Never -- mysql -hmysql-release-mysql -uroot -p${mysqlRootPassword}
show databases;
Press Ctrl+D to exit
## ,----------- Example
## | Denny-Laptop:~ mac$ kubectl run -i --tty --rm mysql-client --image=mysql --restart=Never -- mysql -hmysql-release-mysql -uroot -psecretpassword
## | If you don't see a command prompt, try pressing enter.
## |
## | mysql> show databases;
## | +--------------------+
## | | Database |
## | +--------------------+
## | | information_schema |
## | | my-database |
## | | mysql |
## | | performance_schema |
## | | sys |
## | +--------------------+
## | 5 rows in set (0.00 sec)
## `-----------
helm delete --purge mysql-release
kubectl delete -f ./pv.yaml
minikube delete
https://github.com/kubernetes/helm
https://github.com/kubernetes/charts/tree/master/stable/mysql