Merge pull request #90 from Weilbyte/Weilbyte/kustomize
Add Kustomize support
This commit is contained in:
commit
c0409446f6
123
README.md
123
README.md
|
|
@ -24,7 +24,126 @@ $ helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/n
|
||||||
--set nfs.path=/exported/path
|
--set nfs.path=/exported/path
|
||||||
```
|
```
|
||||||
|
|
||||||
### Without Helm
|
### With Kustomize
|
||||||
|
|
||||||
|
**Step 1: Get connection information for your NFS server**
|
||||||
|
|
||||||
|
Make sure your NFS server is accessible from your Kubernetes cluster and get the information you need to connect to it. At a minimum you will need its hostname and exported share path.
|
||||||
|
|
||||||
|
**Step 2: Add the base resource**
|
||||||
|
|
||||||
|
Create a `kustomization.yaml` file in a directory of your choice, and add the [deploy](https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/tree/master/deploy) directory as a base. This will use the kustomization file within that directory as our base.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
namespace: nfs-provisioner
|
||||||
|
bases:
|
||||||
|
- github.com/kubernetes-sigs/nfs-subdir-external-provisioner//deploy
|
||||||
|
```
|
||||||
|
|
||||||
|
**Step 3: Create namespace resource**
|
||||||
|
|
||||||
|
Create a file with your namespace resource. The name can be anything as it will get overwritten by the namespace in your kustomization file.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# namespace.yaml
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: nfs-provisioner
|
||||||
|
```
|
||||||
|
|
||||||
|
**Step 4: Configure deployment**
|
||||||
|
|
||||||
|
To configure the deployment, you will need to patch it's container variables with the connection information for your NFS Server.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# patch_nfs_details.yaml
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: nfs-client-provisioner
|
||||||
|
name: nfs-client-provisioner
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nfs-client-provisioner
|
||||||
|
env:
|
||||||
|
- name: NFS_SERVER
|
||||||
|
value: <YOUR_NFS_SERVER_IP>
|
||||||
|
- name: NFS_PATH
|
||||||
|
value: <YOUR_NFS_SERVER_SHARE>
|
||||||
|
volumes:
|
||||||
|
- name: nfs-client-root
|
||||||
|
nfs:
|
||||||
|
server: <YOUR_NFS_SERVER_IP>
|
||||||
|
path: <YOUR_NFS_SERVER_SHARE>
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace occurrences of `<YOUR_NFS_SERVER_IP>` and `<YOUR_NFS_SERVER_SHARE>` with your connection information.
|
||||||
|
|
||||||
|
**Step 5: Add resources and deploy**
|
||||||
|
|
||||||
|
Add the namespace resource and patch you created in earlier steps.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
namespace: nfs-provisioner
|
||||||
|
bases:
|
||||||
|
- github.com/kubernetes-sigs/nfs-subdir-external-provisioner//deploy
|
||||||
|
resources:
|
||||||
|
- namespace.yaml
|
||||||
|
patchesStrategicMerge:
|
||||||
|
- patch_nfs_details.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
Deploy (run inside directory with your kustomization file):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
kubectl apply -k .
|
||||||
|
```
|
||||||
|
|
||||||
|
**Step 6: Finally, test your environment!**
|
||||||
|
|
||||||
|
Now we'll test your NFS subdir external provisioner by creating a persistent volume claim and a pod that writes a test file to the volume. This will make sure that the provisioner is provisioning and that the NFS server is reachable and writable.
|
||||||
|
|
||||||
|
Deploy the test resources:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/nfs-subdir-external-provisioner/master/deploy/test-claim.yaml -f https://raw.githubusercontent.com/kubernetes-sigs/nfs-subdir-external-provisioner/master/deploy/test-pod.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
Now check your NFS Server for the `SUCCESS` inside the PVC's directory.
|
||||||
|
|
||||||
|
Delete the test resources:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ kubectl delete -f https://raw.githubusercontent.com/kubernetes-sigs/nfs-subdir-external-provisioner/master/deploy/test-claim.yaml -f https://raw.githubusercontent.com/kubernetes-sigs/nfs-subdir-external-provisioner/master/deploy/test-pod.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
Now check the PVC's directory has been deleted.
|
||||||
|
|
||||||
|
**Step 7: Deploying your own PersistentVolumeClaims**
|
||||||
|
|
||||||
|
To deploy your own PVC, make sure that you have the correct `storageClassName` (by default `managed-nfs-storage`). You can also patch the StorageClass resource to change it, like so:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# kustomization.yaml
|
||||||
|
namespace: nfs-provisioner
|
||||||
|
resources:
|
||||||
|
- github.com/kubernetes-sigs/nfs-subdir-external-provisioner//deploy
|
||||||
|
- namespace.yaml
|
||||||
|
patches:
|
||||||
|
- target:
|
||||||
|
kind: StorageClass
|
||||||
|
name: managed-nfs-storage
|
||||||
|
patch: |-
|
||||||
|
- op: replace
|
||||||
|
path: /metadata/name
|
||||||
|
value: <YOUR-STORAGECLASS-NAME>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Manually
|
||||||
|
|
||||||
**Step 1: Get connection information for your NFS server**
|
**Step 1: Get connection information for your NFS server**
|
||||||
|
|
||||||
|
|
@ -181,7 +300,7 @@ To build your own custom container image from this repository, you will have to
|
||||||
```sh
|
```sh
|
||||||
make build
|
make build
|
||||||
make container
|
make container
|
||||||
# `nfs-subdir-external-provisioner:latest` will be created.
|
# `nfs-subdir-external-provisioner:latest` will be created.
|
||||||
# Note: This will build a single-arch image that matches the machine on which container is built.
|
# Note: This will build a single-arch image that matches the machine on which container is built.
|
||||||
# To upload this to your custom registry, say `quay.io/myorg` and arch as amd64, you can use
|
# To upload this to your custom registry, say `quay.io/myorg` and arch as amd64, you can use
|
||||||
# docker tag nfs-subdir-external-provisioner:latest quay.io/myorg/nfs-subdir-external-provisioner-amd64:latest
|
# docker tag nfs-subdir-external-provisioner:latest quay.io/myorg/nfs-subdir-external-provisioner-amd64:latest
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
resources:
|
||||||
|
- class.yaml
|
||||||
|
- rbac.yaml
|
||||||
|
- deployment.yaml
|
||||||
Loading…
Reference in New Issue