k8s部署mysql5.6
mysql.yaml
[root@k8s01 dh-env]# cat mysql.yaml
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: dh-mysql
namespace: dh-test
spec:
selector:
matchLabels:
app: dh-mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: dh-mysql
spec:
containers:
- image: mysql:5.6
name: dh-mysql
env:
# Use secret in real usage
- name: MYSQL_ROOT_PASSWORD
value: mysql123456
ports:
- containerPort: 3306
name: dh-mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-data
---
apiVersion: v1
kind: Service
metadata:
name: dh-mysql-svc
namespace: dh-test
spec:
ports:
- port: 3306
nodePort: 31296
selector:
app: dh-mysql
type: NodePort
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-data
namespace: dh-test
labels:
app: dh-mysql
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
storageClassName: managed-nfs-storage
[root@k8s01 ~]# kubectl get -n dh-test po
NAME READY STATUS RESTARTS AGE
dh-mysql-676575fb97-5gg8x 1/1 Running 0 124m
[root@k8s01 ~]# kubectl get -n dh-test svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
dh-mysql-svc NodePort 10.99.180.111 <none> 3306:31296/TCP 16h
版权声明:
本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
爱吃可爱多!
喜欢就支持一下吧
打赏
微信
支付宝