Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Allow to mount EFS via arbitrary DNS name #1070

Merged
merged 1 commit into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions aws/efs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ If you are new to Kubernetes or to PersistentVolumes this quick start will get y
wget https://raw.githubusercontent.com/kubernetes-incubator/external-storage/master/aws/efs/deploy/manifest.yaml
```

- In the configmap section change the `file.system.id:` and `aws.region:` to match the details of the EFS you created.
- In the configmap section change the `file.system.id:` and `aws.region:` to match the details of the EFS you created. Change `dns.name` if you want to mount by your own DNS name and not by AWS's `*file-system-id*.efs.*aws-region*.amazonaws.com`.

- In the deployment section change the `server:` to the DNS endpoint of the EFS you created.

Expand Down Expand Up @@ -113,6 +113,7 @@ Create a configmap containing the [**File system ID**](http://docs.aws.amazon.co
$ kubectl create configmap efs-provisioner \
--from-literal=file.system.id=fs-47a2c22e \
--from-literal=aws.region=us-west-2 \
--from-literal=dns.name="" \ # if you want to mount by your own DNS name and not by AWS's `*file-system-id*.efs.*aws-region*.amazonaws.com`.
--from-literal=provisioner.name=example.com/aws-efs
```

Expand Down Expand Up @@ -253,7 +254,7 @@ It's not needed but it is helpful if you are going to use your EFS for other thi
volumes:
- name: pv-volume
nfs:
server: {{ efs_file_system_id }}.efs.{{ aws_region }}.amazonaws.com
server: {{ efs_file_system_id }}.efs.{{ aws_region }}.amazonaws.com # or the same value as `dns.name`/DNS_NAME if you want to mount by your own DNS name and not by AWS's `*file-system-id*.efs.*aws-region*.amazonaws.com`.
path: /
```

Expand Down
7 changes: 6 additions & 1 deletion aws/efs/cmd/efs-provisioner/efs-provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const (
provisionerNameKey = "PROVISIONER_NAME"
fileSystemIDKey = "FILE_SYSTEM_ID"
awsRegionKey = "AWS_REGION"
dnsNameKey = "DNS_NAME"
)

type efsProvisioner struct {
Expand All @@ -64,7 +65,11 @@ func NewEFSProvisioner(client kubernetes.Interface) controller.Provisioner {
glog.Fatalf("environment variable %s is not set! Please set it.", awsRegionKey)
}

dnsName := getDNSName(fileSystemID, awsRegion)
dnsName := os.Getenv(dnsNameKey)
glog.Errorf("%v", dnsName)
if dnsName == "" {
dnsName = getDNSName(fileSystemID, awsRegion)
}

mountpoint, source, err := getMount(dnsName)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions aws/efs/deploy/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ data:
file.system.id: fs-47a2c22e
aws.region: us-west-2
provisioner.name: example.com/aws-efs
dns.name: ""
6 changes: 6 additions & 0 deletions aws/efs/deploy/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ spec:
configMapKeyRef:
name: efs-provisioner
key: aws.region
- name: DNS_NAME
valueFrom:
configMapKeyRef:
name: efs-provisioner
key: dns.name
optional: true
- name: PROVISIONER_NAME
valueFrom:
configMapKeyRef:
Expand Down
7 changes: 7 additions & 0 deletions aws/efs/deploy/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ data:
file.system.id: yourEFSsystemid
aws.region: regionyourEFSisin
provisioner.name: example.com/aws-efs
dns.name: ""
---
kind: Deployment
apiVersion: extensions/v1beta1
Expand Down Expand Up @@ -35,6 +36,12 @@ spec:
configMapKeyRef:
name: efs-provisioner
key: aws.region
- name: DNS_NAME
valueFrom:
configMapKeyRef:
name: efs-provisioner
key: dns.name
optional: true
- name: PROVISIONER_NAME
valueFrom:
configMapKeyRef:
Expand Down
6 changes: 6 additions & 0 deletions aws/efs/deploy/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ spec:
configMapKeyRef:
name: efs-provisioner
key: aws.region
- name: DNS_NAME
valueFrom:
configMapKeyRef:
name: efs-provisioner
key: dns.name
optional: true
volumeMounts:
- name: pv-volume
mountPath: /persistentvolumes
Expand Down