master
guppy 2023-06-01 16:44:22 +02:00
parent 9823945312
commit c27b52d16a
5 changed files with 19 additions and 41 deletions

View File

@ -3,7 +3,16 @@
name: "HostPath" name: "HostPath"
roles: roles:
- role: hostpath - role: hostpath
---
- hosts: all
name: "Install nfs package"
tasks:
- name: install common packages
become: yes
apt:
pkg: nfs-common
update_cache: yes
- hosts: control-plane - hosts: control-plane
name: "NFS" name: "NFS"
roles: roles:

View File

@ -1,29 +1,3 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: nginx-pv
spec:
storageClassName: ""
accessModes:
- ReadWriteMany
capacity:
storage: 1Gi
nfs:
server: 10.100.10.10
path: /share
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nginx-pvc
spec:
storageClassName: ""
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
@ -46,12 +20,12 @@ spec:
ports: ports:
- containerPort: 80 - containerPort: 80
volumeMounts: volumeMounts:
- mountPath: /var/www - mountPath: /usr/share/nginx/html/
name: nginx-pv name: nfs-pv
volumes: volumes:
- name: nginx-pv - name: nfs-pv
persistentVolumeClaim: persistentVolumeClaim:
claimName: nginx-pvc claimName: nfs-pvc
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service

View File

@ -10,4 +10,5 @@
copy: copy:
src: index.html src: index.html
dest: /data/ dest: /data/
mode: '0755'
when: "'K8s-worker-node2' in ansible_facts.hostname" when: "'K8s-worker-node2' in ansible_facts.hostname"

View File

@ -13,22 +13,16 @@
- name: template every yaml.j2 files - name: template every yaml.j2 files
template: template:
src: "{{item}}.j2" src: "nfs-pv-pvc.yaml.j2"
dest: "/tmp/nfs-server/{{item}}" dest: "/tmp/nfs-server/nfs-pv-pvc.yaml"
with_items:
- nfs-pv-pvc.yaml
- nfs-server-deployment-service.yaml
- nfs-dep-sc.yaml
- name: kubectl apply - name: kubectl apply
shell: | shell: |
kubectl apply -f nfs-pv-pvc.yaml kubectl apply -f nfs-pv-pvc.yaml
# kubectl apply -f nfs-dep-sc.yaml
# kubectl apply -f nfs-server-deployment-service.yaml
register: output register: output
args: args:
chdir: /tmp/nfs-server chdir: /tmp/nfs-server
- name: Print return information from the previous task - name: Resultat de kubectl
debug: debug:
var: output.stdout var: output.stdout

View File

@ -4,7 +4,7 @@
- import_playbook: flannel.yaml - import_playbook: flannel.yaml
- import_playbook: pre-join.yaml - import_playbook: pre-join.yaml
- import_playbook: kubernetes-worker.yaml - import_playbook: kubernetes-worker.yaml
- import_playbook: openebs.yaml #- import_playbook: openebs.yaml
- import_playbook: ingress-nginx.yaml - import_playbook: ingress-nginx.yaml
- import_playbook: purelb.yaml - import_playbook: purelb.yaml
#- import_playbook: metallb.yaml #- import_playbook: metallb.yaml