Skip to content

Commit 0626b5e

Browse files
author
Power Cloud Robot
authored
Merge pull request ppc64le-cloud#76 from valen-mascarenhas14/master
Ansible playbook added for knative & tekton
2 parents 851c4f9 + 0ef8313 commit 0626b5e

File tree

6 files changed

+220
-0
lines changed

6 files changed

+220
-0
lines changed

group_vars/all

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,6 @@ etcd_version: v3.5.9
7979
cni_plugins_version: v1.3.0
8080
cni_plugins_url: https://github.com/containernetworking/plugins/releases/download
8181
cni_plugins_tarball: "cni-plugins-linux-{{ ansible_architecture }}-{{ cni_plugins_version }}.tgz"
82+
83+
# NFS server details
84+
nfs_directory: "/var/nfsshare"

install-k8s-kn-tkn.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
- name: Install Runtime and Kubernetes
2+
hosts:
3+
- masters
4+
- workers
5+
roles:
6+
- runtime
7+
- download-k8s
8+
- install-k8s
9+
10+
- name: Install networking - calico
11+
hosts: masters
12+
roles:
13+
- install-calico
14+
15+
- name: Install nfs server & client
16+
hosts: masters
17+
roles:
18+
- install-nfs

roles/install-nfs/files/class.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: storage.k8s.io/v1
2+
kind: StorageClass
3+
metadata:
4+
name: managed-nfs-storage
5+
provisioner: fuseim.pri/ifs # or choose another name, must match deployment's env PROVISIONER_NAME'
6+
parameters:
7+
archiveOnDelete: "false"

roles/install-nfs/files/rbac.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: nfs-client-provisioner
5+
# replace with namespace where provisioner is deployed
6+
namespace: default
7+
---
8+
kind: ClusterRole
9+
apiVersion: rbac.authorization.k8s.io/v1
10+
metadata:
11+
name: nfs-client-provisioner-runner
12+
rules:
13+
- apiGroups: [""]
14+
resources: ["persistentvolumes"]
15+
verbs: ["get", "list", "watch", "create", "delete"]
16+
- apiGroups: [""]
17+
resources: ["persistentvolumeclaims"]
18+
verbs: ["get", "list", "watch", "update"]
19+
- apiGroups: ["storage.k8s.io"]
20+
resources: ["storageclasses"]
21+
verbs: ["get", "list", "watch"]
22+
- apiGroups: [""]
23+
resources: ["events"]
24+
verbs: ["create", "update", "patch"]
25+
---
26+
kind: ClusterRoleBinding
27+
apiVersion: rbac.authorization.k8s.io/v1
28+
metadata:
29+
name: run-nfs-client-provisioner
30+
subjects:
31+
- kind: ServiceAccount
32+
name: nfs-client-provisioner
33+
# replace with namespace where provisioner is deployed
34+
namespace: default
35+
roleRef:
36+
kind: ClusterRole
37+
name: nfs-client-provisioner-runner
38+
apiGroup: rbac.authorization.k8s.io
39+
---
40+
kind: Role
41+
apiVersion: rbac.authorization.k8s.io/v1
42+
metadata:
43+
name: leader-locking-nfs-client-provisioner
44+
# replace with namespace where provisioner is deployed
45+
namespace: default
46+
rules:
47+
- apiGroups: [""]
48+
resources: ["endpoints"]
49+
verbs: ["get", "list", "watch", "create", "update", "patch"]
50+
---
51+
kind: RoleBinding
52+
apiVersion: rbac.authorization.k8s.io/v1
53+
metadata:
54+
name: leader-locking-nfs-client-provisioner
55+
# replace with namespace where provisioner is deployed
56+
namespace: default
57+
subjects:
58+
- kind: ServiceAccount
59+
name: nfs-client-provisioner
60+
# replace with namespace where provisioner is deployed
61+
namespace: default
62+
roleRef:
63+
kind: Role
64+
name: leader-locking-nfs-client-provisioner
65+
apiGroup: rbac.authorization.k8s.io

roles/install-nfs/tasks/main.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
- name: Install prereq & nfs client packages
3+
yum:
4+
name: "{{ packages }}"
5+
state: present
6+
vars:
7+
packages:
8+
- nfs-utils
9+
- nfs4-acl-tools
10+
11+
- name: Create nfs share folder
12+
file:
13+
path: "{{ nfs_directory }}"
14+
state: directory
15+
mode: 0755
16+
recurse: yes
17+
18+
- name: Add shared directory in exports file
19+
ansible.builtin.lineinfile:
20+
path: /etc/exports
21+
regexp: "{{ nfs_directory }}"
22+
line: "{{ nfs_directory }} *(rw,sync,no_root_squash)"
23+
state: present
24+
25+
- name: Start services
26+
block:
27+
- name: Start rpcbind
28+
systemd:
29+
name: rpcbind
30+
enabled: yes
31+
state: restarted
32+
33+
- name: Start nfs-server
34+
systemd:
35+
name: nfs-server
36+
enabled: yes
37+
state: restarted
38+
39+
- name: Expose shared directory to nfs server
40+
command: exportfs -arv
41+
42+
- name: Copy nfs client resource files to /tmp
43+
copy:
44+
src: "{{ item }}"
45+
dest: /tmp/
46+
with_fileglob:
47+
- "*"
48+
49+
- name: Fetch NFS server host IP
50+
shell: kubectl get nodes -o wide | grep 'master' | awk '{print $6}'
51+
register: nfs_server_ip
52+
53+
- name: Deploy NFS client provisioner
54+
template:
55+
src: nfs-client-provisioner.yaml.j2
56+
dest: /tmp/deployment.yaml
57+
vars:
58+
nfs_server: "{{ nfs_server_ip.stdout }}"
59+
60+
- name: remove taint
61+
command: "kubectl taint nodes --all node-role.kubernetes.io/control-plane-"
62+
63+
- name: Apply RBAC configuration
64+
command: kubectl create -f /tmp/rbac.yaml
65+
ignore_errors: true
66+
67+
- name: Apply StorageClass configuration
68+
command: kubectl create -f /tmp/class.yaml
69+
ignore_errors: true
70+
71+
- name: Apply Deployment configuration
72+
command: kubectl create -f /tmp/deployment.yaml
73+
ignore_errors: true
74+
75+
- name: Wait for pods to start
76+
command: >
77+
kubectl get pods -l app=nfs-client-provisioner
78+
-o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}'
79+
register: pod_status
80+
retries: 20
81+
delay: 6
82+
until: pod_status.stdout == "True"
83+
84+
- name: Mark managed-nfs-storage as default storage class
85+
command: >
86+
kubectl patch storageclass managed-nfs-storage
87+
-p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: nfs-client-provisioner
5+
labels:
6+
app: nfs-client-provisioner
7+
namespace: default
8+
spec:
9+
replicas: 1
10+
strategy:
11+
type: Recreate
12+
selector:
13+
matchLabels:
14+
app: nfs-client-provisioner
15+
template:
16+
metadata:
17+
labels:
18+
app: nfs-client-provisioner
19+
spec:
20+
serviceAccountName: nfs-client-provisioner
21+
containers:
22+
- name: nfs-client-provisioner
23+
image: k8s.gcr.io/sig-storage/nfs-subdir-external-provisioner:v4.0.2
24+
volumeMounts:
25+
- name: nfs-client-root
26+
mountPath: /persistentvolumes
27+
env:
28+
- name: PROVISIONER_NAME
29+
value: fuseim.pri/ifs
30+
- name: NFS_SERVER
31+
valueFrom:
32+
fieldRef:
33+
fieldPath: status.hostIP
34+
- name: NFS_PATH
35+
value: {{ nfs_directory }}
36+
volumes:
37+
- name: nfs-client-root
38+
nfs:
39+
server: "{{ nfs_server }}"
40+
path: {{ nfs_directory }}

0 commit comments

Comments
 (0)