exemples.yaml
parent
47c6cf891f
commit
9823945312
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
- hosts: worker-node
|
||||||
|
name: "HostPath"
|
||||||
|
roles:
|
||||||
|
- role: hostpath
|
||||||
|
---
|
||||||
|
- hosts: control-plane
|
||||||
|
name: "NFS"
|
||||||
|
roles:
|
||||||
|
- role: nfs
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
- name: install dep packages
|
||||||
|
become: yes
|
||||||
|
apt:
|
||||||
|
pkg:
|
||||||
|
- nfs-common
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
|
- name:
|
||||||
|
file:
|
||||||
|
path: /tmp/nfs-server
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: template every yaml.j2 files
|
||||||
|
template:
|
||||||
|
src: "{{item}}.j2"
|
||||||
|
dest: "/tmp/nfs-server/{{item}}"
|
||||||
|
with_items:
|
||||||
|
- nfs-pv-pvc.yaml
|
||||||
|
- nfs-server-deployment-service.yaml
|
||||||
|
- nfs-dep-sc.yaml
|
||||||
|
|
||||||
|
- name: kubectl apply
|
||||||
|
shell: |
|
||||||
|
kubectl apply -f nfs-pv-pvc.yaml
|
||||||
|
# kubectl apply -f nfs-dep-sc.yaml
|
||||||
|
# kubectl apply -f nfs-server-deployment-service.yaml
|
||||||
|
register: output
|
||||||
|
args:
|
||||||
|
chdir: /tmp/nfs-server
|
||||||
|
|
||||||
|
- name: Print return information from the previous task
|
||||||
|
debug:
|
||||||
|
var: output.stdout
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
apiVersion: storage.k8s.io/v1
|
||||||
|
kind: StorageClass
|
||||||
|
metadata:
|
||||||
|
name: nfs-client
|
||||||
|
provisioner: external-nfs
|
||||||
|
parameters:
|
||||||
|
archiveOnDelete: "false"
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nfs-client-provisioner
|
||||||
|
labels:
|
||||||
|
app: nfs-client-provisioner
|
||||||
|
# replace with namespace where provisioner is deployed
|
||||||
|
namespace: default
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: nfs-client-provisioner
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: nfs-client-provisioner
|
||||||
|
spec:
|
||||||
|
serviceAccountName: nfs-client-provisioner
|
||||||
|
containers:
|
||||||
|
- name: nfs-client-provisioner
|
||||||
|
image: registry.k8s.io/sig-storage/nfs-subdir-external-provisioner:v4.0.2
|
||||||
|
volumeMounts:
|
||||||
|
- name: nfs-client-root
|
||||||
|
mountPath: /persistentvolumes
|
||||||
|
env:
|
||||||
|
- name: PROVISIONER_NAME
|
||||||
|
value: external-nfs
|
||||||
|
- name: NFS_SERVER
|
||||||
|
value: {{ nfsserver.ip }}
|
||||||
|
- name: NFS_PATH
|
||||||
|
value: {{ nfsserver.share }}
|
||||||
|
volumes:
|
||||||
|
- name: nfs-client-root
|
||||||
|
nfs:
|
||||||
|
server: {{ nfsserver.ip }}
|
||||||
|
path: {{ nfsserver.share }}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolume
|
||||||
|
metadata:
|
||||||
|
name: nfs-pv
|
||||||
|
spec:
|
||||||
|
capacity:
|
||||||
|
storage: 100Mi
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteMany
|
||||||
|
nfs:
|
||||||
|
path: "{{ nfsserver.share }}"
|
||||||
|
server: "{{ nfsserver.ip }}"
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: nfs-pvc
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteMany
|
||||||
|
storageClassName: ""
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 100Mi
|
||||||
|
volumeName: nfs-pv
|
||||||
|
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: nfs-server
|
||||||
|
spec:
|
||||||
|
clusterIP: {{ nfsserver.ip }}
|
||||||
|
clusterIPs:
|
||||||
|
- {{ nfsserver.ip }}
|
||||||
|
ports:
|
||||||
|
- name: 111-tcp
|
||||||
|
port: 111
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: 111
|
||||||
|
- name: 111-udp
|
||||||
|
port: 111
|
||||||
|
protocol: UDP
|
||||||
|
targetPort: 111
|
||||||
|
- name: 2049-tcp
|
||||||
|
port: 2049
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: 2049
|
||||||
|
- name: 2049-udp
|
||||||
|
port: 2049
|
||||||
|
protocol: UDP
|
||||||
|
targetPort: 2049
|
||||||
|
- name: 32765-udp
|
||||||
|
port: 32765
|
||||||
|
protocol: UDP
|
||||||
|
targetPort: 32765
|
||||||
|
- name: 32765-tcp
|
||||||
|
port: 32765
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: 32765
|
||||||
|
selector:
|
||||||
|
role: nfs-server
|
||||||
|
sessionAffinity: None
|
||||||
|
type: ClusterIP
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nfs-server
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
role: nfs-server
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
role: nfs-server
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nfs-server
|
||||||
|
image: erichough/nfs-server
|
||||||
|
env:
|
||||||
|
- name: NFS_EXPORT_0
|
||||||
|
value: '/mnt/stage *(rw,sync,no_subtree_check,fsid=100)'
|
||||||
|
- name: NFS_LOG_LEVEL
|
||||||
|
value: DEBUG # doesn't debug client connections for some reason
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /mnt/stage
|
||||||
|
name: nfs-stage-src
|
||||||
|
- mountPath: /lib/modules # mounting modules into container
|
||||||
|
name: lib-modules
|
||||||
|
readOnly: true # make sure it's readonly
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- hostPath: # using hostpath to get modules from the host
|
||||||
|
path: /lib/modules
|
||||||
|
type: Directory
|
||||||
|
name: lib-modules
|
||||||
|
- name: nfs-stage-src
|
||||||
|
emptyDir: {}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
nfsserver:
|
||||||
|
ip: 192.168.1.159
|
||||||
|
share: /share
|
||||||
|
#ip: 192.168.1.251
|
||||||
|
#share: /media/2T
|
||||||
Loading…
Reference in New Issue