This module creates Kubernetes Persistent Volumes (PV) and Persistent Volume Claims (PVC) that can be used by a [gke-job-template].
gke-persistent-volume
works with Filestore and Google Cloud Storage. Each
gke-persistent-volume
can only be used with a single file system so if multiple
shared file systems are used then multiple gke-persistent-volume
modules are
needed in the blueprint.
NOTE: This is an experimental module and the functionality and documentation will likely be updated in the near future. This module has only been tested in limited capacity.
The following example creates a Filestore and then uses the
gke-persistent-volume
module to use the Filestore as shared storage in a
gke-job-template
.
- id: gke_cluster
source: modules/scheduler/gke-cluster
use: [network1]
settings:
master_authorized_networks:
- display_name: deployment-machine
cidr_block: <your-ip-address>/32
- id: datafs
source: modules/file-system/filestore
use: [network1]
settings:
local_mount: /data
- id: datafs-pv
source: modules/file-system/gke-persistent-volume
use: [datafs, gke_cluster]
- id: job-template
source: modules/compute/gke-job-template
use: [datafs-pv, compute_pool]
The following example creates a GCS bucket and then uses the
gke-persistent-volume
module to use the bucket as shared storage in a
gke-job-template
.
- id: gke_cluster
source: modules/scheduler/gke-cluster
use: [network1]
settings:
master_authorized_networks:
- display_name: deployment-machine
cidr_block: <your-ip-address>/32
- id: data-bucket
source: community/modules/file-system/cloud-storage-bucket
settings:
local_mount: /data
- id: datafs-pv
source: modules/file-system/gke-persistent-volume
use: [data-bucket, gke_cluster]
- id: job-template
source: modules/compute/gke-job-template
use: [datafs-pv, compute_pool, gke_cluster]
See example storage-gke.yaml blueprint for a complete example.
Since the gke-persistent-volume
module is making calls to the Kubernetes API
to create Kubernetes entities, the machine performing the deployment must be
authorized to connect to the Kubernetes API. You can add the
master_authorized_networks
settings block, as shown in the example above, with
the IP address of the machine performing the deployment. This will ensure that
the deploying machine can connect to the cluster.
The diagram below shows the valid use
relationships for the GKE Cluster Toolkit
modules. For example the gke-persistent-volume
module can use
a
gke-cluster
module and a filestore
module, as shown in the example above.
graph TD;
vpc-->|OneToMany|gke-cluster;
gke-cluster-->|OneToMany|gke-node-pool;
gke-node-pool-->|ManyToMany|gke-job-template;
gke-cluster-->|OneToMany|gke-persistent-volume;
gke-persistent-volume-->|ManyToMany|gke-job-template;
vpc-->|OneToMany|filestore;
filestore-->|OneToOne|gke-persistent-volume;
Copyright 2023 Google LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Name | Version |
---|---|
terraform | >= 1.0 |
>= 4.42 | |
kubectl | >= 1.7.0 |
local | >= 2.0.0 |
Name | Version |
---|---|
>= 4.42 | |
kubectl | >= 1.7.0 |
local | >= 2.0.0 |
No modules.
Name | Type |
---|---|
kubectl_manifest.pv | resource |
kubectl_manifest.pvc | resource |
local_file.debug_file | resource |
google_client_config.default | data source |
google_container_cluster.gke_cluster | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
capacity_gb | The storage capacity with which to create the persistent volume. | number |
n/a | yes |
cluster_id | An identifier for the GKE cluster in the format projects/{{project}}/locations/{{location}}/clusters/{{cluster}} |
string |
n/a | yes |
filestore_id | An identifier for a filestore with the format projects/{{project}}/locations/{{location}}/instances/{{name}} . |
string |
null |
no |
gcs_bucket_name | The gcs bucket to be used with the persistent volume. | string |
null |
no |
labels | GCE resource labels to be applied to resources. Key-value pairs. | map(string) |
n/a | yes |
network_storage | Network attached storage mount to be configured. | object({ |
n/a | yes |
Name | Description |
---|---|
persistent_volume_claims | An object that describes a k8s PVC created by this module. |