Skip to content

Commit cf9d65c

Browse files
Merge branch 'testing'
Change-Id: I74796031180ff3334869b6411d76ebfd8c2b1248
2 parents d0ed8bb + 07cca01 commit cf9d65c

File tree

133 files changed

+10919
-1840
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+10919
-1840
lines changed

.gitignore

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
# Mac .DS_Store
1+
# Linux
2+
*~
3+
._*
4+
.directory
5+
6+
# Windows
7+
Thumbs.db
8+
[Dd]esktop.ini
9+
10+
# OSX
211
.DS_Store
312

413
# Terraform Binaries
@@ -13,17 +22,27 @@
1322
# Terraform local .tfvars
1423
*.tfvars
1524

25+
# Terratest files
26+
TerraformOptions.json
27+
.test-data
28+
1629
# Packer variables
1730
*.pkrvars.hcl
1831
*.auto.pkrvars.hcl
1932
*.pkrvars.json
2033
*.auto.pkrvars.json
2134

2235
# Exclude Specific Packer Variables File
23-
!image/internal-build/image.pkrvars.hcl
36+
!/image/cloudbuild.pkrvars.hcl
37+
!/image/internal-build/image.pkrvars.hcl
2438

2539
# Service Account
2640
service-account-key.json
2741

2842
# Build files
29-
image/resources.tgz
43+
/image.manifest.json
44+
/image/resources.tgz
45+
46+
# Development files
47+
go.work
48+
go.work.sum

Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This provides a convenient way to quickly run all the basic tests locally.
2+
# When running in CI/CD (eg. Cloud Build) these steps should be separated out
3+
# so they can run in parallel, and to log the output from each step independently.
4+
5+
.PHONY: default test
6+
default:
7+
8+
.PHONY: filter-exports-test
9+
test: filter-exports-test
10+
filter-exports-test:
11+
$(MAKE) -C image/resources/filter-exports test
12+
13+
.PHONY: knfsd-agent-test
14+
test: knfsd-agent-test
15+
knfsd-agent-test:
16+
$(MAKE) -C image/resources/knfsd-agent test
17+
18+
.PHONY: knfsd-fsidd-test
19+
test: knfsd-fsidd-test
20+
knfsd-fsidd-test:
21+
$(MAKE) -C image/resources/knfsd-fsidd test
22+
23+
.PHONY: knfsd-metrics-agent-test
24+
test: knfsd-metrics-agent-test
25+
knfsd-metrics-agent-test:
26+
$(MAKE) -C image/resources/knfsd-metrics-agent test
27+
28+
.PHONY: netapp-exports-test
29+
test: netapp-exports-test
30+
netapp-exports-test:
31+
$(MAKE) -C image/resources/netapp-exports test
32+
33+
.PHONY: mig-scaler-test
34+
test: mig-scaler-test
35+
mig-scaler-test:
36+
$(MAKE) -C tools/mig-scaler test
37+

cloudbuild.yaml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
# timeout needs to be longer than the total run time, with some padding to allow
17+
# enough time to gracefully tear down resources. Otherwise if Cloud Build aborts
18+
# a build in the middle of Packer or Terraform GCP resources will be left behind.
19+
timeout: 18000s # 5h
20+
21+
substitutions:
22+
_REGION: ${LOCATION}
23+
_ZONE: ${LOCATION}-a
24+
_NETWORK: projects/${PROJECT_ID}/global/networks/default
25+
_SUBNETWORK: projects/${PROJECT_ID}/regions/${_REGION}/subnetworks/default
26+
_WORKER_POOL: ""
27+
28+
# This is to support running the various tests (e.g. smoke tests) with an
29+
# existing image. Useful when developing the tests themselves.
30+
# At the moment the image build step is unconditional, so you'll need to
31+
# comment out the image build step while developing tests.
32+
_IMAGE_NAME: nfs-test-${BUILD_ID}
33+
34+
options:
35+
dynamicSubstitutions: true
36+
pool:
37+
name: ${_WORKER_POOL}
38+
env:
39+
- CI=cloudbuild
40+
- PROJECT_ID=${PROJECT_ID}
41+
- REGION=${_REGION}
42+
- ZONE=${_ZONE}
43+
- NETWORK=${_NETWORK}
44+
- SUBNETWORK=${_SUBNETWORK}
45+
- BUILD_ID=${BUILD_ID}
46+
- IMAGE_NAME=${_IMAGE_NAME}
47+
48+
steps:
49+
- name: golang:1.20
50+
id: filter-exports:test
51+
dir: image/resources/filter-exports
52+
script: make test
53+
waitFor: ['-']
54+
timeout: 1200s # 20m
55+
56+
- name: golang:1.20
57+
id: knfsd-agent:test
58+
dir: image/resources/knfsd-agent
59+
script: make test
60+
waitFor: ['-']
61+
timeout: 1200s # 20m
62+
63+
- name: golang:1.20
64+
id: knfsd-metrics-agent:test
65+
dir: image/resources/knfsd-metrics-agent
66+
script: make test
67+
waitFor: ['-']
68+
timeout: 1200s # 20m
69+
70+
- name: golang:1.20
71+
id: netapp-exports:test
72+
dir: image/resources/netapp-exports
73+
script: make test
74+
waitFor: ['-']
75+
timeout: 1200s # 20m
76+
77+
- name: golang:1.20
78+
id: mig-scaler:test
79+
dir: tools/mig-scaler
80+
script: make test
81+
waitFor: ['-']
82+
timeout: 1200s # 20m
83+
84+
85+
- name: gcr.io/cloud-builders/docker
86+
id: knfsd-fsidd:database-up
87+
dir: image/resources/knfsd-fsidd
88+
script: ./test.sh up
89+
waitFor: ['-']
90+
timeout: 1200s # 20m
91+
92+
- name: golang:1.20
93+
id: knfsd-fsidd:test
94+
dir: image/resources/knfsd-fsidd
95+
script: ./test.sh run
96+
waitFor: ['knfsd-fsidd:database-up']
97+
timeout: 1200s # 20m
98+
99+
- name: gcr.io/cloud-builders/docker
100+
id: knfsd-fsidd:database-down
101+
dir: image/resources/knfsd-fsidd
102+
script: ./test.sh down
103+
waitFor: ['knfsd-fsidd:test']
104+
timeout: 1200s # 20m
105+
106+
# For a production build you would want to set an image_family, and use a more
107+
# readable image_name (if you leave image_name blank packer will default it to
108+
# "{image_family}-{timestamp}").
109+
# Using BUILD_ID for test images to easily associate a test image with a
110+
# specific build. Though this isn't very useful in normal use as BUILD_ID is
111+
# just a random UUID.
112+
# Not using an image_family for the test builds, as you wouldn't want to
113+
# deploy the latest test build. It might be the latest main or the latest pull
114+
# request, who knows?
115+
# If you wanted to run these tests yourself as part of CI/CD before releasing
116+
# an image for general use, to avoid building the image twice, once the tests
117+
# are complete you could copy the image to a proper image_family and more
118+
# usable name (such as using a timestamp or version tag).
119+
- name: hashicorp/packer:1.9
120+
id: knfsd-image:build
121+
script: |
122+
packer init image &&
123+
packer build \
124+
-var-file=image/cloudbuild.pkrvars.hcl \
125+
-var project=${PROJECT_ID} \
126+
-var zone=${ZONE} \
127+
-var build_instance_name=nfs-build-${BUILD_ID} \
128+
-var image_family="" \
129+
-var image_name=${IMAGE_NAME} \
130+
-var subnetwork=${SUBNETWORK} \
131+
image
132+
timeout: 7200s # 2h
133+
134+
- name: ${_DOCKER_REPOSITORY}/knfsd-terratest:1.0
135+
id: knfsd-image:test
136+
dir: image/smoke-tests
137+
script: make test
138+
env:
139+
- TF_VAR_project=${PROJECT_ID}
140+
- TF_VAR_region=${_REGION}
141+
- TF_VAR_zone=${_ZONE}
142+
- TF_VAR_network=${_NETWORK}
143+
- TF_VAR_subnetwork=${_SUBNETWORK}
144+
- TF_VAR_proxy_image=${_IMAGE_NAME}
145+
timeout: 3600s # 1h
146+
147+
- name: ${_DOCKER_REPOSITORY}/knfsd-terratest:1.0
148+
id: examples:tests
149+
dir: testing/examples
150+
script: make test
151+
env:
152+
- TF_VAR_project=${PROJECT_ID}
153+
- TF_VAR_region=${_REGION}
154+
- TF_VAR_zone=${_ZONE}
155+
- TF_VAR_network=${_NETWORK}
156+
- TF_VAR_subnetwork=${_SUBNETWORK}
157+
- TF_VAR_proxy_image=${_IMAGE_NAME}
158+
- TF_VAR_proxy_service_account=${_PROXY_SERVICE_ACCOUNT}
159+
timeout: 3600s # 1h

deployment/database/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
terraform {
18-
required_version = ">=1.2.0"
18+
required_version = ">=1.3.0"
1919
}
2020

2121
resource "random_id" "name" {

deployment/metrics/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
terraform {
18-
required_version = ">=1.2.0"
18+
required_version = ">=1.3.0"
1919
}
2020

2121
locals {

deployment/terraform-module-knfsd/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
terraform {
18-
required_version = ">=1.2.0"
18+
required_version = ">=1.3.0"
1919
}
2020

2121
locals {

deployment/terraform-module-knfsd/modules/dns_round_robin/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
terraform {
18-
required_version = ">=1.2.0"
18+
required_version = ">=1.3.0"
1919
}
2020

2121
data "google_compute_instance_group" "proxy" {

deployment/terraform-module-knfsd/modules/loadbalancer/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
terraform {
18-
required_version = ">=1.2.0"
18+
required_version = ">=1.3.0"
1919
}
2020

2121
# Load Balancer backend service for the Knfsd Cluster

examples/basic/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Basic Example
2+
3+
This example provides a very simple, minimal, deployment.
4+
This can be used to verify that the KNFSD caching proxy can be deployed, and can connect to the source NFS server.
5+
6+
For simplicity this example uses some settings that are not recommended for production:
7+
8+
* `AUTO_CREATE_FIREWALL_RULES = true`.
9+
10+
This setting automatically creates the firewall rules required for health checks.
11+
Normally for production you should create the firewall rules yourself.
12+
If you try and deploy more than one KNFSD proxy cluster with `AUTO_CREATE_FIREWALL_RULES` set to true Terraform will fail because the firewall rule already exists.
13+
14+
You will still need to create firewall rules to allow NFS traffic from the proxy to the source, and the clients to the proxy.
15+
See [Firewall configuration](../../deployment/firewall.md).
16+
17+
* `FSID_MODE = "static"`
18+
19+
This deploys the KNFSD proxy cluster without a shared FSID database.
20+
In production it is recommended to use a shared (external) FSID database to ensure that all the KNFSD proxy instances in the cluster allocate the same FSID to each export.
21+
22+
* Uses the default Compute Service Account.
23+
24+
For best practice you should create a specific Service Account for the KNFSD proxy cluster to use.
25+
A Service Account is required when using an external FSID database.
26+
27+
## Inputs
28+
29+
* `project` - (Required) The ID of the GCP project where the KNFSD caching proxy will be deployed.
30+
31+
* `region` - (Required) The GCP region where the KNFSD caching proxy will be deployed.
32+
33+
* `zone` - (Required) The GCP zone where the KNFSD caching proxy will be deployed.
34+
35+
* `name` - (Required) The name of the deployment. Resources created will be prefixed with this name.
36+
37+
* `network` - (Optional) The GCP network to attach the KNFSD caching proxy to. Defaults to "default".
38+
39+
* `subnetwork` - (Optional) The GCP subnetwork to attach the KNFSD caching proxy to. Defaults to "default".
40+
41+
* `proxy_image` - (Required) The Compute Image to use for the KNFSD caching proxy. This should be built using the image build script in <../../image/>.
42+
43+
* `export_map` - (Required) A list of NFS exports to mount from the source and re-export in the format `<SOURCE_IP>;<SOURCE_EXPORT>;<TARGET_EXPORT>`. See [KNFSD Deployment](../../deployment/README.md) for more details.
44+
45+
## Outputs
46+
47+
* `project` - GCP project where the resources were created.
48+
49+
* `region` - GCP region where the resources were created.
50+
51+
* `zone` - GCP zone where the resources were created.
52+
53+
* `proxy_instance_group` - Name of the KNFSD proxy instance group.
54+
55+
* `proxy_host` - DNS name of the KNFSD proxy group.

0 commit comments

Comments
 (0)