1
00:00:02,150 --> 00:00:06,030
So now let's add this EFS file system

2
00:00:06,030 --> 00:00:07,180
as a volume.

3
00:00:07,180 --> 00:00:09,630
And at the moment, this integration,

4
00:00:09,630 --> 00:00:13,780
this driver provided by AWS for EFS

5
00:00:13,780 --> 00:00:16,210
only works with persistent volumes.

6
00:00:16,210 --> 00:00:18,600
So that's what I'll add here.

7
00:00:18,600 --> 00:00:20,970
For that, we can add a new file here

8
00:00:20,970 --> 00:00:22,620
in our kubernetes folder

9
00:00:22,620 --> 00:00:26,470
and I'll name is users-pv.yaml.

10
00:00:26,470 --> 00:00:29,920
Alternatively, of course, we add it into the same YAML file

11
00:00:29,920 --> 00:00:31,990
as we used before.

12
00:00:31,990 --> 00:00:33,750
And actually, let's do that.

13
00:00:33,750 --> 00:00:35,010
I'll delete the new file

14
00:00:35,010 --> 00:00:36,610
and go to users.yaml

15
00:00:36,610 --> 00:00:39,350
and add my persistent volume here.

16
00:00:39,350 --> 00:00:41,830
Add three dashes above the service

17
00:00:41,830 --> 00:00:44,550
and then add the persistent volume here

18
00:00:44,550 --> 00:00:48,050
by specifying an apiVersion of v1.

19
00:00:48,050 --> 00:00:50,970
And setting the kind to PersistentVolume.

20
00:00:52,210 --> 00:00:55,223
Make sure you don't have any typo here.

21
00:00:56,350 --> 00:00:58,900
Also, by the way, now that I think about it,

22
00:00:58,900 --> 00:01:01,960
make sure that you have a users folder,

23
00:01:01,960 --> 00:01:05,900
an empty users folder in your users-api folder

24
00:01:05,900 --> 00:01:08,280
so that when this is pushed,

25
00:01:08,280 --> 00:01:10,040
when the updated image is pushed,

26
00:01:10,040 --> 00:01:12,550
we also do have that folder there

27
00:01:12,550 --> 00:01:15,940
so that writing to that folder succeeds.

28
00:01:15,940 --> 00:01:18,950
Now, for the moment, however, let's go back to users.yaml

29
00:01:18,950 --> 00:01:21,960
to this PersistentVolume definition, which we're adding.

30
00:01:21,960 --> 00:01:25,060
And then add some metadata here.

31
00:01:25,060 --> 00:01:29,960
Give it a name of efs-pv, for example,

32
00:01:29,960 --> 00:01:33,100
for Elastic File System persistent volume.

33
00:01:33,100 --> 00:01:34,923
And add a specification.

34
00:01:35,900 --> 00:01:38,660
Now, here there are various things which we can set up.

35
00:01:38,660 --> 00:01:40,631
For example, the capacity.

36
00:01:40,631 --> 00:01:44,050
Though actually, in EFS's case,

37
00:01:44,050 --> 00:01:46,040
that doesn't matter too much.

38
00:01:46,040 --> 00:01:48,290
You find that here in the official docs

39
00:01:48,290 --> 00:01:50,160
on the GitHub page as well.

40
00:01:50,160 --> 00:01:52,090
You can specify a capacity

41
00:01:52,090 --> 00:01:54,300
but due to the nature of EFS,

42
00:01:54,300 --> 00:01:55,903
that doesn't really matter.

43
00:01:56,780 --> 00:01:59,270
So here, I will just add a capacity,

44
00:01:59,270 --> 00:02:02,833
a storage capacity of five gigabytes let's say.

45
00:02:03,990 --> 00:02:06,260
And we also add a volumeMode of Filesystem.

46
00:02:07,450 --> 00:02:09,830
And this does matter and is important.

47
00:02:09,830 --> 00:02:12,800
volumeMode should be Filesystem

48
00:02:12,800 --> 00:02:15,743
because EFS is a file system service.

49
00:02:16,820 --> 00:02:21,810
Now, for the accessModes, here I wanna allow ReadWriteMany

50
00:02:22,670 --> 00:02:26,920
so that multiple nodes can actually use that volume

51
00:02:26,920 --> 00:02:29,320
so that if our pods would be distributed

52
00:02:29,320 --> 00:02:30,620
across multiple nodes,

53
00:02:30,620 --> 00:02:33,360
which could happen, we do have two nodes after all

54
00:02:33,360 --> 00:02:36,200
so that all these pods could use that file system

55
00:02:36,200 --> 00:02:38,090
and that volume.

56
00:02:38,090 --> 00:02:42,993
And then also add a storageClassName of efs-sc here.

57
00:02:45,100 --> 00:02:48,410
Last but not least, add the csi option here

58
00:02:48,410 --> 00:02:50,510
and then nested below that,

59
00:02:50,510 --> 00:02:55,510
the driver name, which is efs.csi.aws.com.

60
00:02:56,860 --> 00:03:00,210
And identifier, you, by the way, find on the official docs

61
00:03:00,210 --> 00:03:02,363
if you dive into the examples there.

62
00:03:03,850 --> 00:03:08,420
And then add the volumeHandle option here

63
00:03:08,420 --> 00:03:11,470
and set this equal to your file system ID.

64
00:03:11,470 --> 00:03:14,336
So this ID for the created file system.

65
00:03:14,336 --> 00:03:18,933
This should be added here as a volumeHandle value.

66
00:03:21,080 --> 00:03:24,060
Now, let me come back to that StorageClass here.

67
00:03:24,060 --> 00:03:27,690
Previously, we used the standard StorageClass.

68
00:03:27,690 --> 00:03:29,941
Here we need a specific StorageClass

69
00:03:29,941 --> 00:03:32,060
for the Elastic File System

70
00:03:32,060 --> 00:03:32,940
but at the moment,

71
00:03:32,940 --> 00:03:36,530
this doesn't exist yet on our Kubernetes cluster.

72
00:03:36,530 --> 00:03:39,440
We can see this if we run kubectl get sc

73
00:03:39,440 --> 00:03:42,180
to get a list of all storage classes.

74
00:03:42,180 --> 00:03:46,763
There we see there is not efs-sc storage class.

75
00:03:47,880 --> 00:03:49,500
To get that class,

76
00:03:49,500 --> 00:03:52,140
we can go back to this GitHub repository

77
00:03:52,140 --> 00:03:54,050
of the EFS driver

78
00:03:54,050 --> 00:03:57,610
and here on the examples/kubernetes folder

79
00:03:57,610 --> 00:03:59,940
on Static Provisioning,

80
00:03:59,940 --> 00:04:04,520
there specs, you find the storageclass.yaml file

81
00:04:04,520 --> 00:04:07,540
and you can just copy this code here

82
00:04:07,540 --> 00:04:10,760
and add this as another resource definition

83
00:04:10,760 --> 00:04:13,280
above the PersistentVolume.

84
00:04:13,280 --> 00:04:16,459
This configures this StorageClass by pointing

85
00:04:16,459 --> 00:04:18,170
at this driver.

86
00:04:18,170 --> 00:04:21,653
The driver itself already was installed by us.

87
00:04:23,140 --> 00:04:24,543
And with that, we have the StorageClass

88
00:04:24,543 --> 00:04:25,993
and the PersistentVolume.

89
00:04:26,860 --> 00:04:31,220
Now we just need to claim that volume from inside our pod,

90
00:04:31,220 --> 00:04:33,650
from inside our container to be specific

91
00:04:33,650 --> 00:04:36,573
so that our container uses this as a volume.

92
00:04:37,560 --> 00:04:40,670
For that, in the deployment resource here

93
00:04:40,670 --> 00:04:43,753
of our users.yaml file,

94
00:04:44,790 --> 00:04:47,980
next to the containers option,

95
00:04:47,980 --> 00:04:50,130
add a volumes option.

96
00:04:50,130 --> 00:04:52,570
So on the same level as containers.

97
00:04:52,570 --> 00:04:54,330
And there, add a dash

98
00:04:54,330 --> 00:04:56,950
because I wanna register one volume here

99
00:04:56,950 --> 00:04:58,930
and give it any name of your choice.

100
00:04:58,930 --> 00:05:01,973
Like efs-vol.

101
00:05:03,000 --> 00:05:06,660
And as a type, which is the next key you have to add here,

102
00:05:06,660 --> 00:05:08,997
add persistentVolumeClaim.

103
00:05:10,260 --> 00:05:12,990
And that's, of course, all something I already explained

104
00:05:12,990 --> 00:05:15,210
in an earlier course section.

105
00:05:15,210 --> 00:05:16,880
I'm just going through that slowly

106
00:05:16,880 --> 00:05:18,393
so that we're all onboard.

107
00:05:19,370 --> 00:05:21,890
Here, you should add a claimName

108
00:05:21,890 --> 00:05:25,923
and here, we need to specify our persistentVolumeClaim name.

109
00:05:26,890 --> 00:05:30,370
Now, of course, we haven't created a claim yet.

110
00:05:30,370 --> 00:05:32,810
So let's also do that first.

111
00:05:32,810 --> 00:05:35,220
Scroll up again and then maybe here,

112
00:05:35,220 --> 00:05:38,600
above the service, add three more dashes

113
00:05:38,600 --> 00:05:41,480
and between that, so between the PersistentVolume

114
00:05:41,480 --> 00:05:42,840
and the Service,

115
00:05:42,840 --> 00:05:47,040
add another definition with apiVersion: v1

116
00:05:47,040 --> 00:05:49,787
of kind PersistentVolumeClaim.

117
00:05:53,150 --> 00:05:54,943
With a capital P though.

118
00:05:56,250 --> 00:05:59,160
And here, we wanna give that claim a name.

119
00:05:59,160 --> 00:06:04,160
Maybe name it efs-pvc for PersistentVolumeClaim.

120
00:06:05,710 --> 00:06:08,143
And give it a spec, a configuration

121
00:06:08,143 --> 00:06:13,143
where we request the ReadWriteMany accessModes

122
00:06:16,796 --> 00:06:18,848
and that should be accessModes here.

123
00:06:18,848 --> 00:06:21,640
So we add the ReadWriteMany access mode here

124
00:06:21,640 --> 00:06:22,653
with a dash.

125
00:06:23,530 --> 00:06:28,340
We add a storageClassName of efs-sc

126
00:06:28,340 --> 00:06:31,820
to use that StorageClass, which is getting created up there,

127
00:06:31,820 --> 00:06:34,390
which is also used by the PersistentVolume

128
00:06:34,390 --> 00:06:37,160
and we must use the same StorageClass here

129
00:06:37,160 --> 00:06:40,950
for the claim as we use for the PersistentVolume itself.

130
00:06:40,950 --> 00:06:42,410
And then let's add resources,

131
00:06:42,410 --> 00:06:44,210
which we request here.

132
00:06:44,210 --> 00:06:47,610
And let's request some storage

133
00:06:47,610 --> 00:06:50,873
and actually here, I'll request the full five gigabytes.

134
00:06:51,750 --> 00:06:53,610
Now we've got the claim created,

135
00:06:53,610 --> 00:06:56,930
now we can use this claimName down there

136
00:06:56,930 --> 00:06:59,443
when we wanna get access to the claim in our pod.

137
00:07:00,520 --> 00:07:03,440
So that's the next thing we've gotta do here.

138
00:07:03,440 --> 00:07:06,250
And with that access gained here,

139
00:07:06,250 --> 00:07:09,040
on the container next to env,

140
00:07:09,040 --> 00:07:11,280
so on the same level as env,

141
00:07:11,280 --> 00:07:13,607
we can add our volumeMounts

142
00:07:13,607 --> 00:07:18,190
to mount this volume into a specific path in the container.

143
00:07:18,190 --> 00:07:20,240
Now, we can have multiple volumeMounts,

144
00:07:20,240 --> 00:07:21,670
hence the dash here

145
00:07:21,670 --> 00:07:23,500
and then we specify the name

146
00:07:23,500 --> 00:07:25,480
of the volume which you wanna use.

147
00:07:25,480 --> 00:07:28,470
So here, efs-vol.

148
00:07:28,470 --> 00:07:31,440
And then as a second field,

149
00:07:31,440 --> 00:07:35,320
the mountPath, so the path inside of the container.

150
00:07:35,320 --> 00:07:38,830
And here, that's actually /app

151
00:07:38,830 --> 00:07:40,920
because that's our working directory

152
00:07:40,920 --> 00:07:44,780
into which this entire folder structure here is copied

153
00:07:44,780 --> 00:07:47,730
and then /users because we're writing

154
00:07:47,730 --> 00:07:49,640
to that users subfolder,

155
00:07:49,640 --> 00:07:52,433
which I also created as an empty folder here.

156
00:07:53,290 --> 00:07:57,273
So our mountPath in the container is /app/users.

157
00:07:58,620 --> 00:08:00,230
And that should be all.

158
00:08:00,230 --> 00:08:02,520
That should be the configuration we need here

159
00:08:02,520 --> 00:08:06,730
to add this CSI EFS driver as a volume

160
00:08:06,730 --> 00:08:09,620
to this deployment.

161
00:08:09,620 --> 00:08:11,264
We created a StorageClass,

162
00:08:11,264 --> 00:08:13,613
we created a PersistentVolume,

163
00:08:14,630 --> 00:08:16,630
a PersistentVolumeClaim,

164
00:08:16,630 --> 00:08:19,200
and we connected all of that to our pod

165
00:08:19,200 --> 00:08:21,853
and then, of course, finally, to the container.

