Public Information
This commit is contained in:
98
samples/generic/README.md
Normal file
98
samples/generic/README.md
Normal file
@@ -0,0 +1,98 @@
|
||||
# Generic Mount Example
|
||||
|
||||
This allows you to mount any pre-provisioned PVs, secret or configMap into any container.
|
||||
It can be used e.g. to mount migration nfs, cifs / samba shares into a pipeliner container.
|
||||
|
||||
Use the following format:
|
||||
|
||||
```
|
||||
mounts:
|
||||
generic:
|
||||
- name: <name>:
|
||||
path: <the path in the container, where you want to mount this>
|
||||
volumeName: <the name of the PV to be mounted>
|
||||
configMap: <the name of the configMap to bemounted>
|
||||
secret: <the name of the secret to bemounted>
|
||||
subPath: [a (optional) subpath to be used inside the PV]
|
||||
accessMode: <ReadWriteMany|ReadWriteOnce|ReadOnlyMany|ReadWriteOncePod>
|
||||
size: <size request>
|
||||
```
|
||||
|
||||
## Mounting generic secrets or configMaps
|
||||
|
||||
In this example, we create a secret with two sample files and a configMap with two sample files:
|
||||
|
||||
```
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: sample-generic-secret
|
||||
type: Opaque
|
||||
stringData:
|
||||
test1.txt: |
|
||||
This is a test file
|
||||
lets see if this works.
|
||||
test2.txt: |
|
||||
This is a second test file
|
||||
lets see if this works.
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: sample-generic-configmap
|
||||
data:
|
||||
test1.txt: |
|
||||
This is a test file
|
||||
lets see if this works.
|
||||
test2.txt: |
|
||||
This is a second test file
|
||||
lets see if this works.
|
||||
```
|
||||
|
||||
Then we use these objects to mount them as directory and as files:
|
||||
|
||||
```
|
||||
nappl:
|
||||
mounts:
|
||||
generic:
|
||||
# -- This shows how to mount the contents of a secret into
|
||||
# a directory
|
||||
- name: "sample-generic-secret"
|
||||
secret: "sample-generic-secret"
|
||||
path: "/mnt/secret"
|
||||
|
||||
# -- This shows how to mount the contents of a configMap into
|
||||
# a directory
|
||||
- name: "sample-generic-configmap"
|
||||
configMap: "sample-generic-configmap"
|
||||
path: "/mnt/configmap"
|
||||
|
||||
# -- This shows how to mount a file from a secret to a secret file
|
||||
- name: "sample-generic-secret-file"
|
||||
secret: "sample-generic-secret"
|
||||
path: "/mnt/secret-file.txt"
|
||||
subPath: "test1.txt"
|
||||
|
||||
# -- This shows how to mount a file from a configMap to a file
|
||||
- name: "sample-generic-configmap-file"
|
||||
configMap: "sample-generic-configmap"
|
||||
path: "/mnt/configmap-file.txt"
|
||||
subPath: "test2.txt"
|
||||
```
|
||||
|
||||
## Mounting generic PVs
|
||||
|
||||
Here is an example how to mount any pre-created PV:
|
||||
|
||||
```
|
||||
mounts:
|
||||
generic:
|
||||
# -- This shows how to mount a generic Persistent Volume
|
||||
- name: "migration"
|
||||
path: "/mnt/migration"
|
||||
subPath: "{{ .Release.Name }}-mig"
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
volumeName: my-migration-data-volume
|
||||
size: "512Gi"
|
||||
```
|
||||
45
samples/generic/build.sh
Executable file
45
samples/generic/build.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This sample script builds the example as described. It is also used to build the test environment in our lab,
|
||||
# so it should be well tested.
|
||||
#
|
||||
|
||||
# Make sure it fails immediately, if anything goes wrong
|
||||
set -e
|
||||
|
||||
# -- ENVironment variables:
|
||||
# CHARTS: The path to the source code
|
||||
# DEST: The path to the build destination
|
||||
# SAMPLE: The directory of the sample
|
||||
# NAME: The name of the sample, used as the .Release.Name
|
||||
# KUBE_CONTEXT: The name of the kube context, used to build this sample depending on where you run it against. You might have different Environments such as lab, dev, qa, prod, demo, local, ...
|
||||
|
||||
# Check, if we have the source code available
|
||||
if [ ! -d "$CHARTS" ]; then
|
||||
echo "ERROR Building $SAMPLE example: The Charts Sources folder is not set. Please make sure to run this script with the full Source Code available"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "$DEST" ]; then
|
||||
echo "ERROR Building $SAMPLE example: DEST folder not found."
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "$CHARTS/instance" ]; then
|
||||
echo "ERROR Building $SAMPLE example: Chart Sources in $CHARTS/instance not found. Are you running this script as a subscriber?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set the Variables
|
||||
SAMPLE="generic"
|
||||
NAME="sample-$SAMPLE"
|
||||
|
||||
# Output what is happening
|
||||
echo "Building $NAME"
|
||||
|
||||
# Create the manifest
|
||||
mkdir -p $DEST/instance
|
||||
helm template --debug \
|
||||
--values $SAMPLES/application/empty.yaml \
|
||||
--values $SAMPLES/environment/$KUBE_CONTEXT.yaml \
|
||||
--values $SAMPLES/resources/$KUBE_CONTEXT.yaml \
|
||||
--values $SAMPLES/generic/values.yaml \
|
||||
$NAME $CHARTS/instance > $DEST/instance/$SAMPLE.yaml
|
||||
24
samples/generic/content.yaml
Normal file
24
samples/generic/content.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: sample-generic-secret
|
||||
type: Opaque
|
||||
stringData:
|
||||
test1.txt: |
|
||||
This is a test file
|
||||
lets see if this works.
|
||||
test2.txt: |
|
||||
This is a second test file
|
||||
lets see if this works.
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: sample-generic-configmap
|
||||
data:
|
||||
test1.txt: |
|
||||
This is a test file
|
||||
lets see if this works.
|
||||
test2.txt: |
|
||||
This is a second test file
|
||||
lets see if this works.
|
||||
26
samples/generic/values.yaml
Normal file
26
samples/generic/values.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
nappl:
|
||||
mounts:
|
||||
generic:
|
||||
# -- This shows how to mount the contents of a secret into
|
||||
# a directory
|
||||
- name: "sample-generic-secret"
|
||||
secret: "sample-generic-secret"
|
||||
path: "/mnt/secret"
|
||||
|
||||
# -- This shows how to mount the contents of a configMap into
|
||||
# a directory
|
||||
- name: "sample-generic-configmap"
|
||||
configMap: "sample-generic-configmap"
|
||||
path: "/mnt/configmap"
|
||||
|
||||
# -- This shows how to mount a file from a secret to a secret file
|
||||
- name: "sample-generic-secret-file"
|
||||
secret: "sample-generic-secret"
|
||||
path: "/mnt/secret-file.txt"
|
||||
subPath: "test1.txt"
|
||||
|
||||
# -- This shows how to mount a file from a configMap to a file
|
||||
- name: "sample-generic-configmap-file"
|
||||
configMap: "sample-generic-configmap"
|
||||
path: "/mnt/configmap-file.txt"
|
||||
subPath: "test2.txt"
|
||||
Reference in New Issue
Block a user