标签:toc data lib tom sse mnt replicat clust meta
service 与 endpoint 是通过namespace相同,name相同,相互关联的
创建endpoint
[root@k8s-master glusterfs]# cat glusterfs-ep.yaml
apiVersion: v1
kind: Endpoints
metadata:
name: glusterfs
namespace: tomcat
subsets:
- addresses:
- ip: 10.0.0.11
- ip: 10.0.0.12
- ip: 10.0.0.13
ports:
- port: 49152
protocol: TCP
[root@k8s-master glusterfs]# cat glusterfs-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: glusterfs
namespace: tomcat
spec:
ports:
- port: 49152
protocol: TCP
targetPort: 49152
sessionAffinity: None
type: ClusterIP
使用yml文件创建
tomcat-mysql配置文件修改
[root@k8s-master tomcat_demo]# cat mysql-rc.yml
apiVersion: v1
kind: ReplicationController
metadata:
namespace: tomcat
name: mysql
spec:
replicas: 1
selector:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
volumes:
- name: mysql
glusterfs:
path: oldxu
endpoints: glusterfs
containers:
- name: mysql
image: 10.0.0.11:5000/mysql:5.7
volumeMounts:
- name: mysql
mountPath: /var/lib/mysql
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: '123456'
删除旧的,按照新的yml文件创建
kubectl delete -f .
kubectl create -f .
提示,这里可能会有坑,原因:数据库创建时,目录必须是空的,否则无法创建数据库,我们删除/mnt的所有数据即可
标签:toc data lib tom sse mnt replicat clust meta
原文地址:https://www.cnblogs.com/yangxiaoni/p/12031609.html