-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from ApplauseOSS/feat/pv
feat: add support for PersistentVolume
- Loading branch information
Showing
7 changed files
with
226 additions
and
10 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
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,42 @@ | ||
import copy | ||
|
||
from deploy_config_generator.utils import yaml_dump | ||
from deploy_config_generator.output import kube_common | ||
|
||
|
||
class OutputPlugin(kube_common.OutputPlugin): | ||
|
||
NAME = 'kube_pv' | ||
DESCR = 'Kubernetes PersistentVolume output plugin' | ||
FILE_EXT = '.yaml' | ||
|
||
DEFAULT_CONFIG = { | ||
'fields': { | ||
'kube_pvs': dict( | ||
metadata=dict( | ||
type='dict', | ||
required=True, | ||
fields=copy.deepcopy(kube_common.METADATA_FIELD_SPEC), | ||
), | ||
spec=dict( | ||
type='dict', | ||
required=True, | ||
fields=copy.deepcopy(kube_common.PERSISTENT_VOLUME_FIELD_SPEC), | ||
), | ||
), | ||
} | ||
} | ||
|
||
def generate_output(self, app_vars): | ||
# Basic structure | ||
data = { | ||
'apiVersion': 'v1', | ||
'kind': 'PersistentVolume', | ||
'spec': dict(), | ||
} | ||
data['metadata'] = self.build_metadata(app_vars['APP']['metadata']) | ||
data['spec'] = self.build_generic(app_vars['APP']['spec'], self._plugin_config['fields']['kube_pvs']['spec']['fields']) | ||
|
||
data = self._template.render_template(data, app_vars) | ||
output = yaml_dump(data) | ||
return (output, self.get_output_filename_suffix(data)) |
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,46 @@ | ||
<!-- | ||
NOTE: this document is automatically generated. Any manual changes will get overwritten. | ||
--> | ||
# kube_pv | ||
|
||
Kubernetes PersistentVolume output plugin | ||
|
||
### Parameters | ||
|
||
|
||
#### Deploy config section: kube_pvs | ||
|
||
Name | Type | Required | Default | Description | ||
--- | --- | --- | --- | --- | ||
`metadata`|`dict`|yes|| | ||
`metadata . annotations`|`dict`|no|| | ||
`metadata . labels`|`dict`|no|| | ||
`metadata . name`|`str`|no|| | ||
`metadata . namespace`|`str`|no|| | ||
`spec`|`dict`|yes|| | ||
`spec . access_modes`|`list` (of `str`)|yes|| | ||
`spec . capacity`|`dict`|yes|| | ||
`spec . capacity . storage`|`str`|no|| | ||
`spec . claim_ref`|`dict`|no|| | ||
`spec . claim_ref . api_version`|`str`|no|| | ||
`spec . claim_ref . kind`|`str`|no|| | ||
`spec . claim_ref . name`|`str`|no|| | ||
`spec . claim_ref . namespace`|`str`|no|| | ||
`spec . csi`|`dict`|no|| | ||
`spec . csi . driver`|`str`|no|| | ||
`spec . csi . fs_type`|`str`|no|| | ||
`spec . csi . read_only`|`bool`|no|| | ||
`spec . csi . volume_attributes`|`dict` (of `str`)|no|| | ||
`spec . csi . volume_handle`|`str`|no|| | ||
`spec . mount_options`|`list` (of `str`)|no|| | ||
`spec . nfs`|`dict`|no|| | ||
`spec . nfs . path`|`str`|yes|| | ||
`spec . nfs . server`|`str`|yes|| | ||
`spec . node_affinity`|`dict`|no|| | ||
`spec . node_affinity . required`|`dict`|no|| | ||
`spec . node_affinity . required . node_selector_terms`|`list` (of `dict`)|no|| | ||
`spec . persistent_volume_reclaim_policy`|`str`|no|| | ||
`spec . storage_class_name`|`str`|no|| | ||
`spec . volume_mode`|`str`|no|| | ||
|
||
|
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
18 changes: 18 additions & 0 deletions
18
tests/integration/kube_basic/expected_output/kube_pv-001-test-pv.yaml
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,18 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolume | ||
metadata: | ||
name: test-pv | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
capacity: | ||
storage: 8Gi | ||
mountOptions: | ||
- hard | ||
- nfsvers=4.1 | ||
nfs: | ||
path: /tmp | ||
server: 172.17.0.2 | ||
persistentVolumeReclaimPolicy: Recycle | ||
storageClassName: slow | ||
volumeMode: Filesystem |