Welcome to my GitHub

Github.com/zq2599/blog…

Content: all original article classification summary and supporting source code, involving Java, Docker, Kubernetes, DevOPS, etc.;

Group of CDH and K8S +

  1. Learning K8S often use network storage, so want to find a stable NFS service, just at home qunhui DS218+ open for a long time, space and enough, used to provide NFS service is quite appropriate, this article is set up and use the process of note;
  2. The picture below is the appearance of DS218+ just bought, with two NAS hard disks, which have been in stable service:

The full text overview

  1. Set up the NFS;
  2. Install NFS applications on an NFS client.
  3. Settings on K8S;
  4. Create a storage volume.
  5. Create a Tomcat
  6. Accessing the Tomcat Service

Environmental information

  1. CDH System: DSM 6.2.2-24922 Update 4
  2. Kubernetes: 1.15
  3. Kubernetes CentOS Linux release 7.7.1908
  4. Helm: 2.16.1

Refer to the article

This paper focuses on K8S combat, so a certain K8S foundation is required, please refer to:

  1. Kubespray2.11 Install Kubernets 1.15
  2. Deploying and Experiencing Helm(version 2.16.1)
  3. Ubuntu16 installing and using NFS

If you have already prepared Qunhui, K8S and Helm, let’s do the actual combat.

Set up the NFS

  1. Web login to Qunhui, Control Panel -> Shared folder;

2. Add a shared folder:3. Next comes the encryption Settings. Here, no encryption is set, and click Next directly:4. Advanced Settings page, please set as required, here for simple and direct next step:5. Click Apply to create folder and then set NFS as shown below:6. Make a note of NFS /volume1/nfs-tomcat in red box 1 and click on red box 2:You can see nfS-Tomcat in red box 2. This is the local disk directory corresponding to the NFS directory. Click the right mouse button on it and choose Properties:8. In the pop-up property page, add a permission configuration, please set according to your actual needs, here to save trouble set to anyone can operate:At this point, the NFS Settings on the CDH are completed, and then run an application in K8S to use the NFS storage.

An NFS client is installed

Yum install nfs-utils -y yum install nfs-utils -y yum install nfs-utils -y yum install nfs-utils -y

Create a PersistentVolume (PV)

PV is a common storage type in K8S.

  1. SSH login to K8S;
  2. Create namespace: kubectl create namespace tomcat-test
  3. Yaml: /volume1/nfs-tomcat: /volume1/nfs-tomcat: /volume1/nfs-tomcat: /volume1/nfs-tomcat: /volume1
apiVersion: v1
kind: PersistentVolume
metadata:
 name: pv-tomcat-test
 namespace: tomcat-test
 labels:
   pv: pv-tomcat-test
spec:
 capacity:
   storage: 10Gi
 accessModes:
   - ReadWriteOnce
 persistentVolumeReclaimPolicy: Recycle
 nfs:
   path: /volume1/nfs-tomcat
   server: 192.168. 5042.
Copy the code
  1. Create PV: kubectl apply-f tomcat-test-pv.yaml
  2. The PV named pV-tomcat-test is in the Available state, indicating that it can be used by K8S.

6. Now that PV has been created successfully, create Tomcat at Helm to use this PV.

Create a Tomcat

  1. Increase the helm warehouse (warehouse) with a tomcat: helm repo add bitnami charts.bitnami.com/bitnami
  2. Download Chart of Tomcat: Helm Fetch Bitnami /tomcat
  3. After chart is downloaded successfully, the tomcat configuration package tomcat-6.2.4. TGZ is displayed in the current directory. Decompress the package tar -zxvf tomcat-6.2.4.tgz
  4. After unzipping the tomcat folder, go inside and open the templates/ PVc.yaml file. Everything stays the same, just add the following red box at the end:

5. The content in the red box above is easy to understand: Add a selector and use the PV 6 you just created. Run the following command to create tomcat: helm install –name-template tomcat001 -f values.yaml. –namespace tomcat-test 7. The other PV is still idle, indicating that the selector set in PVc. yaml is valid:The tomcat service port is mapped to port 30512 of the host computer:9. Browser access host IP:30512, tomcat welcome page can be opened normally:10. Go back to the Homepage of Qunhui and open File Station. You can see that many contents have been written in the nfS-Tomcat directory, which are internal tomcat files:So far, K8S has successfully used the NFS service provided by Qunhui. In the future study of K8S, there is a stable NFS service, and thanks to the security of Qunhui file system, data security has also been improved.

Welcome to pay attention to the public number: programmer Xin Chen

Wechat search “programmer Xin Chen”, I am Xin Chen, looking forward to enjoying the Java world with you…

Github.com/zq2599/blog…