-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance helper Pod interface and configuration.
* Make the helper Pod receive only environment variables instead of args (this changes the interface in a non-backward compatible way but is simpler to use and potentially provides more backward compatibility in the future). * Adds the manager options `--pvc-annotation[-required]` to pass through annotations from the PVC to the PV and to the helper Pod. * Merge the helper Pod's `data` VolumeMount with the one provided with the template to be able to specify `mountPropagation` within the template. * Rename `helperPod.yaml` to `helper-pod.yaml` (more convenient and if we break sth we can break this as well). * Expose `--helper-pod-timeout` option. * Provide a basic usage example of the new features (`examples/cache`). * Support forceful termination of the manager binary (2xCtrl+c - since this is annoying during development otherwise). Closes #164 Closes #165 Signed-off-by: Max Goltzsche <[email protected]>
- Loading branch information
1 parent
01eaa8c
commit 4e7b93f
Showing
28 changed files
with
695 additions
and
481 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
./.dapper | ||
./.cache | ||
./dist | ||
./examples/cache/testmount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Example cache provisioner | ||
|
||
This example shows how to use short-lived PersistentVolumes for caching. | ||
A [buildah](https://github.com/containers/buildah)-based helper Pod is used to provision a container file system based on an image as PersistentVolume and commit it when deprovisioning. | ||
Users can select the desired cache or rather the image using a PersistentVolumeClaim annotation that is passed through to the helper Pod as environment variable. | ||
|
||
While it is not part of this example caches could also be synchronized across nodes using an image registry. | ||
The [cache-provisioner](https://github.com/mgoltzsche/cache-provisioner) project aims to achieve this as well as other cache management features. | ||
|
||
## Test | ||
|
||
### Test the helper Pod separately | ||
|
||
The helper Pod can be tested separately using docker locally: | ||
```sh | ||
./helper-test.sh | ||
``` | ||
|
||
### Test the integration | ||
|
||
_Please note that a non-overlayfs storage directory (`/data/example-cache-storage`) must be configured._ | ||
_The provided configuration is known to work with minikube (`minikube start`) and kind (`kind create cluster; kind export kubeconfig`)._ | ||
|
||
Install the example kustomization: | ||
```sh | ||
kustomize build . | kubectl apply -f - | ||
``` | ||
|
||
If you want to test changes to the `local-path-provisioner` binary locally: | ||
```sh | ||
kubectl delete -n example-cache-storage deploy example-cache-local-path-provisioner | ||
( | ||
cd ../.. | ||
go build . | ||
./local-path-provisioner --debug start \ | ||
--namespace=example-cache-storage \ | ||
--configmap-name=example-cache-local-path-config \ | ||
--service-account-name=example-cache-local-path-provisioner-service-account \ | ||
--provisioner-name=storage.example.org/cache \ | ||
--pvc-annotation=storage.example.org \ | ||
--pvc-annotation-required=storage.example.org/cache-name | ||
) | ||
``` | ||
|
||
Within another terminal create an example Pod and PVC that pulls and runs a container image using [podman](https://github.com/containers/podman): | ||
```sh | ||
kubectl apply -f test-pod.yaml | ||
kubectl logs -f cached-build | ||
``` | ||
|
||
If the Pod and PVC are removed and recreated you can observe that, during the 2nd Pod execution on the same node, the image for the nested container doesn't need to be pulled again since it is cached: | ||
```sh | ||
kubectl delete -f test-pod.yaml | ||
kubectl apply -f test-pod.yaml | ||
kubectl logs -f cached-build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"nodePathMap": [ | ||
{ | ||
"node": "DEFAULT_PATH_FOR_NON_LISTED_NODES", | ||
"paths": ["/data/example-cache-storage"] | ||
}, | ||
{ | ||
"node": "minikube", | ||
"paths": ["/data/example-cache-storage"] | ||
}, | ||
{ | ||
"node": "kind-control-plane", | ||
"paths": ["/var/opt/example-cache-storage"] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: helper-pod | ||
spec: | ||
containers: | ||
- name: helper | ||
image: quay.io/buildah/stable:v1.18.0 | ||
imagePullPolicy: IfNotPresent | ||
securityContext: | ||
privileged: true | ||
hostPID: true | ||
volumeMounts: | ||
- name: data | ||
mountPropagation: Bidirectional |
Oops, something went wrong.