- Understand Azure Files
- We are going to write a Deployment Manifest for NGINX Application which will have its static content served from Azure File Shares in app1 folder
- We are going to mount the file share to a specific path
mountPath: "/usr/share/nginx/html/app1"
in the Nginx container
- We will define our own custom storage class with desired permissions
- Standard_LRS - standard locally redundant storage (LRS)
- Standard_GRS - standard geo-redundant storage (GRS)
- Standard_ZRS - standard zone redundant storage (ZRS)
- Standard_RAGRS - standard read-access geo-redundant storage (RA-GRS)
- Premium_LRS - premium locally redundant storage (LRS)
-
With default AKS created storage classes only below two options are available for us.
- Standard_LRS - standard locally redundant storage (LRS)
- Premium_LRS - premium locally redundant storage (LRS)
-
Important Note: Azure Files support premium storage in AKS clusters that run Kubernetes 1.13 or higher, minimum premium file share is 100GB
-
Kube Manifests
- 01-Storage-Class.yml
- 02-Persistent-Volume-Claim.yml
- 03-Nginx-Deployment.yml
- 04-Nginx-Service.yml
-
nginx-files
- file1.html
- file2.html
-
k8s Deployment maniest - core item for review
volumeMounts:
- name: my-azurefile-volume
mountPath: "/usr/share/nginx/html/app1"
volumes:
- name: my-azurefile-volume
persistentVolumeClaim:
claimName: my-azurefile-pvc
# Deploy
kubectl apply -f kube-manifests-v1/
# Verify SC, PVC, PV
kubectl get sc, pvc, pv
# Verify Pod
kubectl get pods
kubectl describe pod <pod-name>
# Get Load Balancer Public IP
kubectl get svc
# Access Application
http://<External-IP-from-get-service-output>
http://<External-IP-from-get-service-output>/app1/index.html
- Go to Storage Accounts
- Select and Open storage account under resoure group mc_aks-rg1_aksdemo1_eastus
- In Overview, go to File Shares
- Open File share with name which starts as kubernetes-dynamic-pv-xxxxxx
- Click on Upload and upload
- file1.html
- file2.html
# URLs
http://<External-IP-from-get-service-output>/app1/file1.html
http://<External-IP-from-get-service-output>/app1/file2.html
# Delete
kubectl delete -f kube-manifests-v1/
- Kube Manifests
- 01-Persistent-Volume-Claim.yml
- 02-Nginx-Deployment.yml
- 03-Nginx-Service.yml
- nginx-files
- file1.html
- file2.html
# Deploy
kubectl apply -f kube-manifests-v2/
# Verify SC, PVC, PV
kubectl get sc, pvc, pv
# Verify Pod
kubectl get pods
kubectl describe pod <pod-name>
# Get Load Balancer Public IP
kubectl get svc
# Access Application
http://<External-IP-from-get-service-output>
- Go to Storage Accounts
- Select and Open storage account under resoure group mc_aks-rg1_aksdemo1_eastus
- In Overview, go to File Shares
- Open File share with name which starts as kubernetes-dynamic-pv-xxxxxx
- Click on Upload and upload
- file1.html
- file2.html
# URLs
http://<External-IP-from-get-service-output>/app1/file1.html
http://<External-IP-from-get-service-output>/app1/file2.html
# Delete
kubectl delete -f kube-manifests-v2/