Skip to content

Commit e046149

Browse files
authored
Merge branch 'main' into add_monitor_fsxn_with_arvest
2 parents 116accc + 7b0da35 commit e046149

File tree

22 files changed

+1467
-164
lines changed

22 files changed

+1467
-164
lines changed

EKS/FSxN-as-PVC-for-EKS/README.md

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ Run the following commands to clone the repo and change into the directory where
7676
terraform files are located:
7777
```bash
7878
git clone https://github.com/NetApp/FSx-ONTAP-samples-scripts.git
79-
cd FSx-ONTAP-samples-scripts/Solutions/FSxN-as-PVC-for-EKS/terraform
79+
cd FSx-ONTAP-samples-scripts/EKS/FSxN-as-PVC-for-EKS/terraform
8080
```
8181
### Make any desired changes to the variables.tf file.
8282
Variables that can be changed include:
8383
- aws_region - The AWS region where you want to deploy the resources.
8484
- aws_secrets_region - The region where the fsx password secret will be created.
8585
- fsx_name - The name you want applied to the FSx for NetApp ONTAP File System. Must not already exist.
86-
- fsx_password_secret_name - A base name of the AWS SecretsManager secret that will hold the FSxN password.
86+
- secret_name_prefix - The base name of the AWS SecretsManager secrets that will be created that will hold the FSxN adminstrator, and SVM, passwords.
8787
A random string will be appended to this name to ensure uniqueness.
8888
- fsx_storage_capacity - The storage capacity of the FSx for NetApp ONTAP File System.
8989
Read the "description" of the variable to see the valid range.
@@ -109,32 +109,23 @@ the following is an example of last part of the output of a successful deploymen
109109
```bash
110110
Outputs:
111111

112-
eks-cluster-name = "fsx-eks-DB0H69vL"
113-
eks-jump-server = "Instance ID: i-0e99a61431a39d327, Public IP: 54.244.16.198"
114-
fsx-id = "fs-0887a493cXXXXXXXX"
115-
fsx-management-ip = "198.19.255.174"
116-
fsx-password-secret-arn = "arn:aws:secretsmanager:us-west-2:759995400000:secret:fsx-eks-secret-3b8bde97-Fst5rj"
117-
fsx-password-secret-name = "fsx-eks-secret-3b8bde97"
112+
Outputs:
113+
114+
eks-cluster-name = "eksfs-eks-lutuycvJ"
115+
eks-jump-server = "Instance ID: i-00de97f46e3c9a617, Public IP: 54.213.93.236"
116+
fsx-id = "fs-04f1b48f8da639a7f"
117+
fsx-management-ip = "198.19.255.245"
118+
fsx-password-secret-arn = "arn:aws:secretsmanager:us-west-2:759995470648:secret:keith-eksfs-fsxn-55fd4eb7-4Oy2ab"
119+
fsx-password-secret-name = "eksfs-fsxn-55fd4eb7"
118120
fsx-svm-name = "ekssvm"
119121
region = "us-west-2"
120-
vpc-id = "vpc-03ed6b1867d76e1a9"
122+
svm-password-secret-arn = "arn:aws:secretsmanager:us-west-2:759995470648:secret:keith-eksfs-svm-6ad11609-nApoUp"
123+
svm-password-secret-name = "eksfs-svm-6ad11609"
124+
vpc-id = "vpc-0791cc0566462082b"
121125
```
122126
:bulb: **Tip:** You will use the values in the commands below, so probably a good idea to copy the output somewhere
123127
so you can easily reference it later.
124128

125-
> [!IMPORTANT]
126-
> Note that an FSxN File System was created, with a vserver (a.k.a. SVM). The default username
127-
> for the FSxN File System is 'fsxadmin'. And the default username for the vserver is 'vsadmin'. The
128-
> password for both of these users is the same and is what is stored in the AWS SecretsManager secret
129-
> shown above. Since Terraform was used to create the secret, the password is stored in
130-
> plain text in its "state" database and therefore it is **HIGHLY** recommended that you change
131-
> the password to something else by first changing the passwords via the AWS Management Console and
132-
> then updating the password in the AWS SecretsManager secret. You can update the 'username' key in
133-
> the secret if you want, but it must be a vserver admin user, not a system level user. This secret
134-
> is used by Astra Trident and it will always login via the vserver management LIF and therefore it
135-
> must be a vserver admin user. If you want to create a separate secret for the 'fsxadmin' user,
136-
> feel free to do so.
137-
138129
### SSH to the jump server to complete the setup
139130
Use the following command to 'ssh' to the jump server:
140131
```bash
@@ -164,7 +155,7 @@ Note that if you are using an SSO to authenticate with AWS, then the actual user
164155
you need to add is slightly different than what is output from the above command.
165156
The following command will take the output from the above command and format it correctly:
166157

167-
:warning: **Warning:** Only run this command if you are using an SSO to authenticate with aws.
158+
:warning: **Caution:** Only run this command if you are using an SSO to authenticate with aws.
168159
```bash
169160
user_ARN=$(aws sts get-caller-identity | jq -r '.Arn' | awk -F: '{split($6, parts, "/"); printf "arn:aws:iam::%s:role/aws-reserved/sso.amazonaws.com/%s\n", $5, parts[2]}')
170161
echo $user_ARN
@@ -246,12 +237,12 @@ other files you'll need to complete the setup.
246237
After making the following substitutions in the commands below:
247238
- \<fsx-id> with the FSxN ID.
248239
- \<fsx-svm-name> with the name of the SVM that was created.
249-
- \<secret-arn> with the ARN of the AWS SecretsManager secret that holds the FSxN password.
240+
- \<secret-arn> with the ARN of the AWS SecretsManager secret that holds the SVM password (not the FSxN password).
250241

251242
Run them to configure Trident to use the FSxN file system that was
252243
created earlier using the `terraform --apply` command:
253244
```
254-
cd ~/FSx-ONTAP-samples-scripts/Solutions/FSxN-as-PVC-for-EKS
245+
cd ~/FSx-ONTAP-samples-scripts/EKS/FSxN-as-PVC-for-EKS
255246
mkdir temp
256247
export FSX_ID=<fsx-id>
257248
export FSX_SVM_NAME=<fsx-svm-name>
@@ -281,7 +272,7 @@ kubectl get tridentbackendconfig -n trident --output=json | jq '.items[] | .stat
281272
```
282273
Once you have resolved any issues, you can remove the failed backend by running:
283274

284-
:warning: **Warning:** Only run this command if the backend is in a failed state and you are ready to get rid of it.
275+
:warning: **Caution:** Only run this command if the backend is in a failed state and you are ready to get rid of it.
285276
```bash
286277
kubectl delete -n trident -f temp/backend-tbc-ontap-nas.yaml
287278
```
@@ -336,7 +327,7 @@ You will want to login as the 'fsxadmin' user, using the password stored in the
336327
You can find the IP address of the FSxN file system in the output from the `terraform apply` command, or
337328
from the AWS console. Here is an example of logging in and listing all the volumes on the system:
338329
```bash
339-
ubuntu@ip-10-0-4-125:~/FSx-ONTAP-samples-scripts/Solutions/FSxN-as-PVC-for-EKS$ ssh -l fsxadmin 198.19.255.174
330+
ubuntu@ip-10-0-4-125:~/FSx-ONTAP-samples-scripts/EKS/FSxN-as-PVC-for-EKS$ ssh -l fsxadmin 198.19.255.174
340331
([email protected]) Password:
341332

342333
FsxId0887a493c777c5122::> volume show

EKS/FSxN-as-PVC-for-EKS/terraform/eks-cluster.tf

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ resource "aws_iam_policy" "trident_policy" {
8181
{
8282
"Action": "secretsmanager:GetSecretValue",
8383
"Effect": "Allow",
84-
"Resource": aws_secretsmanager_secret_version.fsx_secret_password.arn
84+
"Resource": module.svm_rotate_secret.secret_arn
8585
}
8686
],
8787
})
@@ -122,11 +122,3 @@ data "cloudinit_config" "cloudinit" {
122122
content = file("scripts/iscsi.sh")
123123
}
124124
}
125-
126-
data "aws_eks_cluster" "eks" {
127-
name = module.eks.cluster_name
128-
}
129-
130-
data "aws_eks_cluster_auth" "eks" {
131-
name = module.eks.cluster_name
132-
}
Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,40 @@
11
#
2-
# Generate a random password for FSx
3-
resource "random_string" "fsx_password" {
4-
length = 8
5-
min_lower = 1
6-
min_numeric = 1
7-
min_special = 0
8-
min_upper = 1
9-
numeric = true
10-
special = true
11-
override_special = "@$%^&*()_+="
12-
}
13-
14-
provider "aws" {
15-
alias = "secrets_provider"
16-
region = var.aws_secrets_region
17-
}
18-
#
19-
# Store the password in AWS Secrets Manager
20-
resource "aws_secretsmanager_secret" "fsx_secret_password" {
21-
provider = aws.secrets_provider
22-
name = "${var.fsx_password_secret_name}-${random_id.id.hex}"
23-
}
24-
resource "aws_secretsmanager_secret_version" "fsx_secret_password" {
25-
provider = aws.secrets_provider
26-
secret_id = aws_secretsmanager_secret.fsx_secret_password.id
27-
secret_string = jsonencode({username = "vsadmin", password = random_string.fsx_password.result})
2+
# Instantiate an AWS secret for the FSx ONTAP file system. It will set the initial password for the file system.
3+
module "fsxn_rotate_secret" {
4+
source = "github.com/Netapp/FSx-ONTAP-samples-scripts/Management-Utilities/fsxn-rotate-secret/terraform"
5+
fsx_region = var.aws_region
6+
secret_region = var.aws_secrets_region
7+
aws_account_id = var.aws_account_id
8+
secret_name_prefix = var.secret_name_prefix
9+
fsx_id = aws_fsx_ontap_file_system.eksfs.id
2810
}
2911
#
30-
# Note that this allows traffic from both the private and public subnets. However
31-
# the security groups only allow traffic from the public subnet over port 22 when
32-
# the source has the jump server SG assigned to it. So, basically, it only allows traffic
33-
# from the jump server from the public subnet.
12+
# Create a FSxN file system.
3413
resource "aws_fsx_ontap_file_system" "eksfs" {
3514
storage_capacity = var.fsxn_storage_capacity
3615
subnet_ids = module.vpc.private_subnets
3716
deployment_type = "MULTI_AZ_1"
3817
throughput_capacity = var.fsxn_throughput_capacity
3918
preferred_subnet_id = module.vpc.private_subnets[0]
4019
security_group_ids = [aws_security_group.fsx_sg.id]
41-
fsx_admin_password = random_string.fsx_password.result
42-
route_table_ids = concat(module.vpc.private_route_table_ids, module.vpc.public_route_table_ids)
20+
route_table_ids = concat(module.vpc.private_route_table_ids, module.vpc.public_route_table_ids)
4321
tags = {
4422
Name = var.fsx_name
4523
}
4624
}
4725
#
26+
# Instantiate an AWS secret for the storage virtual machine. It will set the initial password for the SVM.
27+
module "svm_rotate_secret" {
28+
source = "github.com/Netapp/FSx-ONTAP-samples-scripts/Management-Utilities/fsxn-rotate-secret/terraform"
29+
fsx_region = var.aws_region
30+
secret_region = var.aws_secrets_region
31+
aws_account_id = var.aws_account_id
32+
secret_name_prefix = var.secret_name_prefix
33+
svm_id = aws_fsx_ontap_storage_virtual_machine.ekssvm.id
34+
}
35+
#
4836
# Create a vserver and assign the 'vsadmin' the same password as fsxadmin.
4937
resource "aws_fsx_ontap_storage_virtual_machine" "ekssvm" {
5038
file_system_id = aws_fsx_ontap_file_system.eksfs.id
5139
name = "ekssvm"
52-
svm_admin_password = random_string.fsx_password.result
5340
}

EKS/FSxN-as-PVC-for-EKS/terraform/outputs.tf

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
output "region" {
2-
description = "AWS region"
32
value = var.aws_region
43
}
54

65
output "fsx-password-secret-name" {
7-
value = aws_secretsmanager_secret.fsx_secret_password.name
6+
value = module.fsxn_rotate_secret.secret_name
87
}
98

109
output "fsx-password-secret-arn" {
11-
value = aws_secretsmanager_secret_version.fsx_secret_password.arn
10+
value = module.fsxn_rotate_secret.secret_arn
11+
}
12+
13+
output "svm-password-secret-name" {
14+
value = module.svm_rotate_secret.secret_name
15+
}
16+
17+
output "svm-password-secret-arn" {
18+
value = module.svm_rotate_secret.secret_arn
1219
}
1320

1421
output "fsx-svm-name" {
@@ -24,7 +31,7 @@ output "fsx-management-ip" {
2431
}
2532

2633
output "eks-cluster-name" {
27-
value = data.aws_eks_cluster.eks.id
34+
value = module.eks.cluster_name
2835
}
2936

3037
output "vpc-id" {
Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,42 @@
11
variable "aws_region" {
2-
default = "us-west-2"
3-
description = "aws region where you want the resources deployed."
2+
description = "The AWS region where you want the resources deployed."
3+
type = string
44
}
55

66
variable "aws_secrets_region" {
7-
default = "us-west-2"
8-
description = "The region where you want the FSxN secret stored within AWS Secrets Manager."
7+
description = "The AWS region where you want the FSxN and SVM secrets stored within AWS Secrets Manager."
8+
type = string
9+
}
10+
11+
variable "aws_account_id" {
12+
description = "The AWS account ID. Used to create very specific permissions in the IAM role for the EKS cluster."
13+
type = string
914
}
1015

1116
variable "fsx_name" {
12-
default = "eksfs"
1317
description = "The name you want assigned to the FSxN file system."
18+
default = "eksfs"
1419
}
1520

16-
variable "fsx_password_secret_name" {
21+
variable "secret_name_prefix" {
22+
description = "The base name of the secrets (FSxN and SVM) to create within the AWS Secrets Manager. A random string will be appended to the end of the secreate name to ensure no name conflict."
1723
default = "fsx-eks-secret"
18-
description = "The base name of the secret to create within the AWS Secrets Manager that will contain the FSxN password. A random string will be appended to the end of the secreate name to ensure no name conflict."
1924
}
2025

2126
variable "fsxn_storage_capacity" {
22-
default = 1024
2327
description = "The storage capacity, in GiBs, to be allocated to the FSxN clsuter. Must be at least 1024, and less than 196608."
28+
type = number
29+
default = 1024
2430
validation {
2531
condition = var.fsxn_storage_capacity >= 1024 && var.fsxn_storage_capacity < 196608
2632
error_message = "The storage capacity must be at least 1024, and less than 196608."
2733
}
2834
}
2935

3036
variable "fsxn_throughput_capacity" {
31-
default = 128
3237
description = "The throughput capacity to be allocated to the FSxN cluster. Must be 128, 256, 512, 1024, 2048, 4096."
38+
type = string # Set to a string so it can be used in a "contains()" function.
39+
default = 128
3340
validation {
3441
condition = contains([128, 256, 512, 1024, 2048, 4096], var.fsxn_throughput_capacity)
3542
error_message = "The throughput capacity must be 128, 256, 512, 1024, 2048, or 4096."
@@ -38,34 +45,38 @@ variable "fsxn_throughput_capacity" {
3845
#
3946
# Keep in mind that key pairs are regional, so pick one that is in the region specified above.
4047
variable "key_pair_name" {
41-
default = "MUST REPLACE WITH YOUR KEY PAIR NAME"
4248
description = "The key pair to associate with the jump server."
49+
default = "MUST REPLACE WITH YOUR KEY PAIR NAME"
50+
type = string
4351
validation {
4452
condition = var.key_pair_name != "MUST REPLACE WITH YOUR KEY PAIR NAME"
4553
error_message = "You must specify a key pair name."
4654
}
4755
}
4856

4957
variable "secure_ips" {
50-
default = ["0.0.0.0/0"]
5158
description = "List of CIDRs that are allowed to ssh into the jump server."
59+
default = ["0.0.0.0/0"]
5260
}
5361

5462
################################################################################
5563
# Don't change any variables below this line.
5664
################################################################################
5765

5866
variable "trident_version" {
59-
default = "v24.2.0-eksbuild.1"
6067
description = "The version of Astra Trident to 'add-on' to the EKS cluster."
68+
default = "v24.2.0-eksbuild.1"
69+
type = string
6170
}
6271

6372
variable "kubernetes_version" {
64-
default = 1.29
6573
description = "kubernetes version"
74+
default = 1.29
75+
type = string
6676
}
6777

6878
variable "vpc_cidr" {
69-
default = "10.0.0.0/16"
7079
description = "default CIDR range of the VPC"
80+
default = "10.0.0.0/16"
81+
type = string
7182
}

0 commit comments

Comments
 (0)