Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
k8s_basic_storage [2020/05/25 12:13] – [Dynamic Provisioning] andonovj | k8s_basic_storage [2020/05/25 12:49] (current) – [Dynamic Provisioning] andonovj | ||
---|---|---|---|
Line 138: | Line 138: | ||
< | < | ||
+ | apiVersion: v1 | ||
kind: Pod | kind: Pod | ||
metadata: | metadata: | ||
Line 241: | Line 242: | ||
=====Dynamic Provisioning===== | =====Dynamic Provisioning===== | ||
- | Let's configure Dynamic storage. | + | Let's configure Dynamic storage. |
Now, for Dynamic provisioning with NFS I had to re-configure the cluster. In a nutshell make sure that teh API IP which you give when you initiate the cluster has the same subnet of the pod network. | Now, for Dynamic provisioning with NFS I had to re-configure the cluster. In a nutshell make sure that teh API IP which you give when you initiate the cluster has the same subnet of the pod network. | ||
Line 281: | Line 283: | ||
* Claim | * Claim | ||
- | ====Create the Components==== | + | ====Create the Deployment, |
- | + | ||
- | ===Create Deployment=== | + | |
You can see the deployment, | You can see the deployment, | ||
Line 498: | Line 498: | ||
</ | </ | ||
- | ===Create Claim=== | + | ====Create |
With Dynamic provisioning, | With Dynamic provisioning, | ||
Line 515: | Line 515: | ||
requests: | requests: | ||
storage: 10Mi | storage: 10Mi | ||
+ | ubuntu@k8s-master: | ||
+ | </ | ||
+ | |||
+ | ====Verify==== | ||
+ | We can verify the configuration as follows: | ||
+ | |||
+ | |||
+ | < | ||
ubuntu@k8s-master: | ubuntu@k8s-master: | ||
NAME CAPACITY | NAME CAPACITY | ||
Line 542: | Line 550: | ||
</ | </ | ||
+ | ====Create a Pod with Dynamic Provisioning==== | ||
+ | We can of course create a pod which will be using the NFS, let's create NGINX pod for example: | ||
+ | |||
+ | < | ||
+ | apiVersion: apps/v1 | ||
+ | kind: Deployment | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: nginx | ||
+ | name: nfs-nginx | ||
+ | spec: | ||
+ | replicas: 1 | ||
+ | selector: | ||
+ | matchLabels: | ||
+ | app: nginx | ||
+ | template: | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: nginx | ||
+ | spec: | ||
+ | volumes: | ||
+ | - name: nfs # | ||
+ | persistentVolumeClaim: | ||
+ | claimName: nfs # same name of pvc that was created | ||
+ | containers: | ||
+ | - image: nginx | ||
+ | name: nginx | ||
+ | volumeMounts: | ||
+ | - name: nfs # name of volume should match claimName volume | ||
+ | mountPath: mydata2 # mount inside of contianer | ||
+ | ubuntu@k8s-master: | ||
+ | deployment.apps/ | ||
+ | ubuntu@k8s-master: | ||
+ | NAME READY | ||
+ | nfs-nginx-6b4db6f57-4mczr | ||
+ | nfs-provisioner-7795cf6f4-d7m2l | ||
+ | ubuntu@k8s-master: | ||
+ | </ | ||
+ | |||
+ | Even an ubuntu pod: | ||
+ | < | ||
+ | ubuntu@k8s-master: | ||
+ | apiVersion: v1 | ||
+ | kind: Pod | ||
+ | metadata: | ||
+ | name: first-pod | ||
+ | spec: | ||
+ | volumes: | ||
+ | - name: fast10m | ||
+ | persistentVolumeClaim: | ||
+ | claimName: nfs | ||
+ | containers: | ||
+ | - name: ctr1 | ||
+ | image: ubuntu: | ||
+ | command: | ||
+ | - /bin/bash | ||
+ | - " | ||
+ | - "sleep 60m" | ||
+ | volumeMounts: | ||
+ | - mountPath: "/ | ||
+ | name: fast10m | ||
+ | ubuntu@k8s-master: | ||
+ | NAME READY | ||
+ | first-pod | ||
+ | nfs-nginx-6b4db6f57-4mczr | ||
+ | nfs-provisioner-7795cf6f4-d7m2l | ||
+ | ubuntu@k8s-master: | ||
+ | </ | ||
+ | |||
+ | Eurika, finally we are done with both types of privisioning |