- Kubernetes——使用NFS映射的目录
- 一、 使用NFS映射的目录
- 1.1 删除原有的deploy
- 1.2 删除原有的service
- 1.3 重新构建部署
- 1.3.1 切换至deploy部署脚本的目录
- 1.3.2 修改deploy.yml
- 1.3.3 重新创建部署
- 1.3.4 验证路径已经被容器内部映射进去
- Kubernetes其他文档列表
[root@k8s-master tomcat-deploy]# kubectl get deploy NAME READY UP-TO-DATE AVAILABLE AGE tomcat-deploy 2/2 2 2 132m [root@k8s-master tomcat-deploy]# kubectl delete deploy tomcat-deploy deployment.extensions "tomcat-deploy" deleted [root@k8s-master tomcat-deploy]# kubectl get deploy No resources found.1.2 删除原有的service
[root@k8s-master tomcat-deploy]# kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.11.3 重新构建部署 1.3.1 切换至deploy部署脚本的目录443/TCP 16d tomcat-service NodePort 10.108.52.85 8000:31000/TCP 146m [root@k8s-master tomcat-deploy]# kubectl delete service tomcat-service service "tomcat-service" deleted
1.3.2 修改deploy.yml这一步是基于已经使用yml部署过tomcat集群的情况,如果没有部署过,可重新写一份yml进行提交
把test-deploy.yml修改为:
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: tomcat-deploy spec: replicas: 2 template: metadata: labels: app: tomcat-cluster spec: # 宿主机下要挂载进来的目录 volumes: # 建立一个别名,叫什么都可以,有意义就行 - name: web-app hostPath: # 宿主机目录 path: /mnt containers: - name: tomcat-cluster image: tomcat:latest ports: - containerPort: 8080 volumeMounts: # 此处的name需要和spec.template.spec.volumes.name一致 - name: web-app # 挂载到pod内部容器的路径 mountPath: /usr/local/tomcat/webapps1.3.3 重新创建部署
[root@k8s-master tomcat-deploy]# kubectl create -f test-deploy.yml deployment.extensions/tomcat-deploy created [root@k8s-master tomcat-deploy]# kubectl get deploy NAME READY UP-TO-DATE AVAILABLE AGE tomcat-deploy 2/2 2 2 36m [root@k8s-master tomcat-deploy]# kubectl get pod NAME READY STATUS RESTARTS AGE tomcat-deploy-6678dccdc9-289cv 1/1 Running 0 36m tomcat-deploy-6678dccdc9-z7wft 1/1 Running 0 36m1.3.4 验证路径已经被容器内部映射进去
使用命令kubectl exec -ti [podName] bash
[root@k8s-master tomcat-deploy]# kubectl get pod NAME READY STATUS RESTARTS AGE tomcat-deploy-6678dccdc9-289cv 1/1 Running 0 36m tomcat-deploy-6678dccdc9-z7wft 1/1 Running 0 36m [root@k8s-master tomcat-deploy]# kubectl exec -ti tomcat-deploy-6678dccdc9-289cv bash root@tomcat-deploy-6678dccdc9-289cv:/usr/local/tomcat# ls BUILDING.txt CONTRIBUTING.md LICENSE NOTICE README.md RELEASE-NOTES RUNNING.txt bin conf lib logs native-jni-lib temp webapps webapps.dist work root@tomcat-deploy-6678dccdc9-289cv:/usr/local/tomcat# cd webapps root@tomcat-deploy-6678dccdc9-289cv:/usr/local/tomcat/webapps# ls a b.txt test.txtKubernetes其他文档列表
- 初学Kubernetes——k8s简介
- 初学Kubernetes——Kubernetes的安装
- 初学Kubernetes——使用Dashboard部署Tomcat集群
- 初学Kubernetes——使用Deployment脚本部署Tomcat集群
- 初学Kubernetes——使用NodePort的方式让外部访问Tomcat集群
- 初学Kubernetes——基于NFS文件文件集群共享
- 初学Kubernetes——使用NFS映射的目录
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)