Commit 08624ea2 authored by Vũ Hoàng Nam's avatar Vũ Hoàng Nam

Add Ansbible playbooks for config NFS-server in Ubuntu.

parent f090b339
......@@ -11,3 +11,10 @@ spec:
image: nigelpoulton/k8sbook:1.0
ports:
- containerPort: 8080
resources:
requests:
memory: "128Mi"
cpu: "500m"
limits:
memory: "512Mi"
cpu: "1000m"
\ No newline at end of file
### Connect Minikube to NFS server
[defaults]
inventory=inventory.ini
private_key_file=~/.ssh/ansible
[nfs]
192.168.67.9
[nfs:vars]
ansible_user=jay
\ No newline at end of file
# To connect NFS server from MacOS
# Set the 'insecure', 'all-squash', 'anonuid' and 'anongid' options in the /etc/exports file
# Use the full 'nfs://[server-IP]/path/nfs_share_dir' path in Finder's Connect to Server
{{ nfs_share_dir }} {{ subnet_ip }}(rw,all_squash,sync,no_subtree_check,anonuid=65534,anongid=65534,insecure)
\ No newline at end of file
---
- name: Set up a NFS server in ubuntu
hosts: all
become: true
vars:
subnet_ip: 192.168.67.0/24
nfs_share_dir: /var/nfs/k8s
tasks:
- name: Install nfs-kernel-server
ansible.builtin.apt:
name: nfs-kernel-server
state: present
- name: Create share dicrectory
ansible.builtin.file:
path: /var/nfs/k8s
state: directory
mode: '0777'
- name: Change ownership of a directory
ansible.builtin.file:
path: /var/nfs/k8s
state: directory
recurse: true
owner: nobody
group: nogroup
- name: Config the NFS
ansible.builtin.template:
src: nfs-config.j2
dest: /etc/exports
owner: root
group: root
mode: '0644'
notify: Restart nfs-kernel-server service
handlers:
- name: Restart nfs-kernel-server service
ansible.builtin.service:
name: nfs-kernel-server
state: restarted
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-pv
spec:
capacity:
storage: 1Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Recycle
storageClassName: slow
mountOptions:
- hard
- nfsvers=4.1
nfs:
path: /tmp
server: 172.17.0.2
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment