Skip to content

Commit

Permalink
Merge pull request #649 from aws-samples/fsx-restructure
Browse files Browse the repository at this point in the history
Port FSxN lab to new workshop structure
  • Loading branch information
niallthomson authored Oct 9, 2023
2 parents c0ff2a5 + 1524932 commit 70f7c57
Show file tree
Hide file tree
Showing 17 changed files with 129 additions and 86 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
module "fsxn_driver" {
source = "github.com/NetApp/terraform-aws-netapp-fsxn-eks-addon.git?ref=v1.0"
}

data "aws_vpc" "selected_vpc_fsx" {
tags = {
created-by = "eks-workshop-v2"
env = local.addon_context.eks_cluster_id
}
}

data "aws_subnets" "private_subnets_fsx" {
tags = {
created-by = "eks-workshop-v2"
env = local.addon_context.eks_cluster_id
}

filter {
name = "tag:Name"
values = ["*Private*"]
}
}

resource "random_string" "fsx_password" {
length = 10
special = false
}

data "aws_route_table" "private" {
count = length(data.aws_subnets.private_subnets_fsx.ids)

vpc_id = data.aws_vpc.selected_vpc_fsx.id
subnet_id = data.aws_subnets.private_subnets_fsx.ids[count.index]
}

resource "aws_fsx_ontap_file_system" "fsxnassets" {
storage_capacity = 2048
subnet_ids = slice(data.aws_subnets.private_subnets_fsx.ids, 0, 2)
deployment_type = "MULTI_AZ_1"
throughput_capacity = 512
preferred_subnet_id = data.aws_subnets.private_subnets_fsx.ids[0]
security_group_ids = [aws_security_group.fsxn.id]
fsx_admin_password = random_string.fsx_password.result
route_table_ids = data.aws_route_table.private.*.id

tags = merge(
local.tags,
{
Name = "${local.addon_context.eks_cluster_id}-fsxn-assets"
}
)
}

resource "aws_fsx_ontap_storage_virtual_machine" "fsxnsvm" {
file_system_id = aws_fsx_ontap_file_system.fsxnassets.id
name = "fsxnsvm"
}

resource "aws_security_group" "fsxn" {
name_prefix = "security group for fsx access"
vpc_id = data.aws_vpc.selected_vpc_fsx.id
tags = merge(
local.tags,
{
Name = "${local.addon_context.eks_cluster_id}-fsxnsecuritygroup"
}
)
}

resource "aws_security_group_rule" "fsxn_inbound" {
description = "allow inbound traffic to eks"
from_port = 0
protocol = "-1"
to_port = 0
security_group_id = aws_security_group.fsxn.id
type = "ingress"
cidr_blocks = [data.aws_vpc.selected_vpc_fsx.cidr_block]
}

resource "aws_security_group_rule" "fsxn_outbound" {
description = "allow outbound traffic to anywhere"
from_port = 0
protocol = "-1"
security_group_id = aws_security_group.fsxn.id
to_port = 0
type = "egress"
cidr_blocks = [data.aws_vpc.selected_vpc_fsx.cidr_block]
}

output "environment" {
value = <<EOF
export FSXN_ID=${aws_fsx_ontap_file_system.fsxnassets.id}
export FSXN_ADMIN_PASSWORD=${random_string.fsx_password.result}
export FSXN_IP="${tolist(aws_fsx_ontap_file_system.fsxnassets.endpoints[0].management[0].ip_addresses)[0]}"
EOF
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
FSXN_IP
FSXN_IP
FSXN_ADMIN_PASSWORD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
varReference:
- kind: TridentBackendConfig
path: spec/managementLIF
path: spec/managementLIF
- kind: Secret
path: stringData/password
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ metadata:
type: Opaque
stringData:
username: fsxadmin
password: Netapp1!
password: $(FSXN_ADMIN_PASSWORD)
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,12 @@ vars:
apiVersion: v1
fieldref:
fieldpath: data.FSXN_IP
- name: FSXN_ADMIN_PASSWORD
objref:
kind: ConfigMap
name: fsxnconfig
apiVersion: v1
fieldref:
fieldpath: data.FSXN_ADMIN_PASSWORD
configurations:
- env-var-transformer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spec:
spec:
initContainers:
- name: copy
image: "public.ecr.aws/aws-containers/retail-store-sample-assets:latest"
image: "public.ecr.aws/aws-containers/retail-store-sample-assets:0.4.0"
command: ["/bin/sh", "-c", "cp -R /usr/share/nginx/html/assets/* /fsxnvolume"]
volumeMounts:
- name: fsxnvolume
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../../../../../manifests/assets
- ../../../../../base-application/assets
resources:
- fsxnpvclaim.yaml
patches:
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Now that we understand the FSxN storage class for Kubernetes let's create a [Per
First inspect the `fsxnpvclaim.yaml` file to see the parameters in the file and the claim of the specific storage size of 5GB from the Storage class `fsxn-sc-nfs` we created in the earlier step:

```file
fundamentals/storage/fsxn/deployment/fsxnpvclaim.yaml
manifests/modules/fundamentals/storage/fsxn/deployment/fsxnpvclaim.yaml
```

We'll also modify the assets service is two ways:
Expand All @@ -17,14 +17,14 @@ We'll also modify the assets service is two ways:
* Add an [init container](https://kubernetes.io/docs/concepts/workloads/pods/init-containers/) to copy the initial images to the FSxN volume

```kustomization
fundamentals/storage/fsxn/deployment/deployment.yaml
modules/fundamentals/storage/fsxn/deployment/deployment.yaml
Deployment/assets
```

We can apply the changes by running the following command:

```bash
$ kubectl apply -k /workspace/modules/fundamentals/storage/fsxn/deployment
$ kubectl apply -k ~/environment/eks-workshop/modules/fundamentals/storage/fsxn/deployment
namespace/assets unchanged
serviceaccount/assets unchanged
configmap/assets unchanged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ Now, we'll need to create a TridentBackendConfig object configured to use the pr

We'll be using Kustomize to create the backend and to ingest the environment variable `FSXN_IP` in the parameter`managementLIF` value in the configuration of the storage class object:

```kustomization
fundamentals/storage/fsxn/backend/fsxn-backend-nas.yaml
TridentBackendConfig/backend-fsxn-ontap-nas
```file
manifests/modules/fundamentals/storage/fsxn/backend/fsxn-backend-nas.yaml
```

Let's apply this kustomization:

```bash
$ kubectl apply -k /workspace/modules/fundamentals/storage/fsxn/backend
$ kubectl apply -k ~/environment/eks-workshop/modules/fundamentals/storage/fsxn/backend
configmap/fsxnconfig created
secret/backend-fsxn-ontap-nas-secret created
tridentbackendconfig.trident.netapp.io/backend-fsxn-ontap-nas created
Expand All @@ -58,15 +57,14 @@ Now, we'll need to create a StorageClass(https://kubernetes.io/docs/concepts/sto

We'll be using Kustomize to create for the storage class:

```kustomization
fundamentals/storage/fsxn/storageclass/fsxnstorageclass.yaml
StorageClass/fsxn-sc-nfs
```file
manifests/modules/fundamentals/storage/fsxn/storageclass/fsxnstorageclass.yaml
```

Let's apply this kustomization:

```bash
$ kubectl apply -k /workspace/modules/fundamentals/storage/fsxn/storageclass/
$ kubectl apply -k ~/environment/eks-workshop/modules/fundamentals/storage/fsxn/storageclass/
storageclass.storage.k8s.io/fsxn-sc-nfs created
```

Expand Down
10 changes: 8 additions & 2 deletions website/docs/fundamentals/storage/fsx-for-netapp-ontap/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ sidebar_position: 30
sidebar_custom_props: {"module": true}
---

:::caution

Provisioning the FSx For NetApp ONTAP file system and associated infrastructure can take up to 30 minutes. Please take that in to account before starting this lab, and expect the `prepare-environment` command to take longer than other labs you may have done.

:::

:::tip Before you start
Prepare your environment for this section:

```bash timeout=300 wait=30
$ reset-environment
```bash timeout=1800 wait=30
$ prepare-environment fundamentals/storage/fsxn
```

:::
Expand Down
5 changes: 1 addition & 4 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ const config = {
//[remarkBlueprintsAddon, {terraformDir: `${rootDir}/../terraform/local`}]
],
editUrl:
'https://github.com/aws-samples/eks-workshop-v2/tree/main/website',
exclude: [
'fundamentals/storage/fsx-for-netapp-ontap'
]
'https://github.com/aws-samples/eks-workshop-v2/tree/main/website'
},
theme: {
customCss: require.resolve('./src/css/custom.scss'),
Expand Down

0 comments on commit 70f7c57

Please sign in to comment.