-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from awslabs/initial
Add project structure and a simple version of the driver
- Loading branch information
Showing
29 changed files
with
1,887 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/credentials | ||
bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#Copyright 2022 The Kubernetes Authors | ||
# | ||
#Licensed under the Apache License, Version 2.0 (the "License"); | ||
#you may not use this file except in compliance with the License. | ||
#You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
#Unless required by applicable law or agreed to in writing, software | ||
#distributed under the License is distributed on an "AS IS" BASIS, | ||
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
#See the License for the specific language governing permissions and | ||
#limitations under the License. | ||
|
||
# Download and verify the mountpoint's RPM in this container | ||
FROM public.ecr.aws/amazonlinux/amazonlinux:2023 as mp_builder | ||
|
||
# We need the full version of GnuPG | ||
RUN dnf install -y --allowerasing wget gnupg2 | ||
|
||
RUN MP_ARCH=`uname -p | sed s/aarch64/arm64/` && \ | ||
wget -q "https://s3.amazonaws.com/mountpoint-s3-release/latest/$MP_ARCH/mount-s3.rpm" && \ | ||
wget -q "https://s3.amazonaws.com/mountpoint-s3-release/latest/$MP_ARCH/mount-s3.rpm.asc" && \ | ||
wget -q https://s3.amazonaws.com/mountpoint-s3-release/public_keys/KEYS | ||
|
||
# Import the key and validate it has the fingerprint we expect | ||
RUN gpg --import KEYS && \ | ||
(gpg --fingerprint mountpoint-s3@amazon.com | grep "673F E406 1506 BB46 9A0E F857 BE39 7A52 B086 DA5A") | ||
|
||
# Verify the downloaded binary | ||
RUN gpg --verify mount-s3.rpm.asc | ||
|
||
# Build driver | ||
FROM --platform=$BUILDPLATFORM golang:1.21.1-bullseye as builder | ||
WORKDIR /go/src/github.com/kubernetes-sigs/aws-s3-csi-driver | ||
ADD . . | ||
RUN make bin | ||
|
||
FROM public.ecr.aws/amazonlinux/amazonlinux:2023 AS linux-amazon | ||
|
||
RUN yum install util-linux -y | ||
|
||
# Install MP | ||
COPY --from=mp_builder /mount-s3.rpm /mount-s3.rpm | ||
|
||
RUN dnf upgrade -y && \ | ||
dnf install -y ./mount-s3.rpm && \ | ||
dnf clean all && \ | ||
rm mount-s3.rpm | ||
|
||
RUN echo "user_allow_other" >> /etc/fuse.conf | ||
|
||
# Install driver | ||
COPY --from=builder /go/src/github.com/kubernetes-sigs/aws-s3-csi-driver/bin/aws-s3-csi-driver /bin/aws-s3-csi-driver | ||
|
||
ENTRYPOINT ["/bin/aws-s3-csi-driver"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#Copyright 2022 The Kubernetes Authors | ||
# | ||
#Licensed under the Apache License, Version 2.0 (the "License"); | ||
#you may not use this file except in compliance with the License. | ||
#You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
#Unless required by applicable law or agreed to in writing, software | ||
#distributed under the License is distributed on an "AS IS" BASIS, | ||
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
#See the License for the specific language governing permissions and | ||
#limitations under the License. | ||
|
||
VERSION=0.1.0 | ||
|
||
PKG=github.com/awslabs/aws-s3-csi-driver | ||
GIT_COMMIT?=$(shell git rev-parse HEAD) | ||
BUILD_DATE?=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") | ||
|
||
LDFLAGS?="-X ${PKG}/pkg/driver.driverVersion=${VERSION} -X ${PKG}/pkg/driver.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/driver.buildDate=${BUILD_DATE}" | ||
|
||
GO111MODULE=on | ||
GOPROXY=direct | ||
GOPATH=$(shell go env GOPATH) | ||
GOOS=$(shell go env GOOS) | ||
GOBIN=$(shell pwd)/bin | ||
|
||
REGISTRY?=151381207180.dkr.ecr.eu-west-1.amazonaws.com | ||
IMAGE?=$(REGISTRY)/s3-csi-driver | ||
TAG?=$(GIT_COMMIT) | ||
|
||
PLATFORM?=linux/amd64,linux/arm64 | ||
|
||
.EXPORT_ALL_VARIABLES: | ||
|
||
.PHONY: build_image | ||
build_image: | ||
DOCKER_BUILDKIT=1 docker build -t=${IMAGE}:${TAG} --platform=${PLATFORM} . | ||
|
||
.PHONY: push_image | ||
push_image: | ||
docker push ${IMAGE}:${TAG} | ||
|
||
.PHONY: login_registry | ||
login_registry: | ||
aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin ${REGISTRY} | ||
|
||
.PHONY: bin | ||
bin: | ||
mkdir -p bin | ||
CGO_ENABLED=0 GOOS=linux go build -ldflags ${LDFLAGS} -o bin/aws-s3-csi-driver ./cmd/ | ||
|
||
.PHONY: test | ||
test: | ||
go test -v -race ./pkg/... | ||
go test -v ./tests/sanity/... | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf bin/ && docker system prune |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
Copyright 2022 The Kubernetes Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/awslabs/aws-s3-csi-driver/pkg/driver" | ||
"k8s.io/klog/v2" | ||
) | ||
|
||
func main() { | ||
var ( | ||
endpoint = flag.String("endpoint", "unix://tmp/csi.sock", "CSI Endpoint") | ||
version = flag.Bool("version", false, "Print the version and exit") | ||
) | ||
klog.InitFlags(nil) | ||
flag.Parse() | ||
|
||
if *version { | ||
info, err := driver.GetVersionJSON() | ||
if err != nil { | ||
klog.Fatalln(err) | ||
} | ||
fmt.Println(info) | ||
os.Exit(0) | ||
} | ||
|
||
drv := driver.NewDriver(*endpoint) | ||
if err := drv.Run(); err != nil { | ||
klog.Fatalln(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
|
||
apiVersion: storage.k8s.io/v1 | ||
kind: CSIDriver | ||
metadata: | ||
name: s3.csi.aws.com | ||
spec: | ||
attachRequired: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
namespace: kube-system | ||
resources: | ||
- csidriver.yaml | ||
- node-daemonset.yaml | ||
- node-serviceaccount.yaml | ||
secretGenerator: | ||
- name: aws-credentials | ||
behavior: create | ||
literals: | ||
- dummy=dummy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
--- | ||
kind: DaemonSet | ||
apiVersion: apps/v1 | ||
metadata: | ||
name: s3-csi-node | ||
labels: | ||
app.kubernetes.io/name: aws-s3-csi-driver | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: s3-csi-node | ||
app.kubernetes.io/name: aws-s3-csi-driver | ||
template: | ||
metadata: | ||
labels: | ||
app: s3-csi-node | ||
app.kubernetes.io/name: aws-s3-csi-driver | ||
spec: | ||
nodeSelector: | ||
kubernetes.io/os: linux | ||
serviceAccountName: s3-csi-driver-sa | ||
priorityClassName: system-node-critical | ||
tolerations: | ||
- key: CriticalAddonsOnly | ||
operator: Exists | ||
- operator: Exists | ||
effect: NoExecute | ||
tolerationSeconds: 300 | ||
containers: | ||
- name: s3-plugin | ||
securityContext: | ||
privileged: true | ||
image: csi-driver | ||
imagePullPolicy: IfNotPresent | ||
args: | ||
- --endpoint=$(CSI_ENDPOINT) | ||
- --logtostderr | ||
- --v=5 | ||
env: | ||
- name: CSI_ENDPOINT | ||
value: unix:/csi/csi.sock | ||
volumeMounts: | ||
- name: kubelet-dir | ||
mountPath: /var/lib/kubelet | ||
mountPropagation: "Bidirectional" | ||
- name: plugin-dir | ||
mountPath: /csi | ||
- name: aws-credentials | ||
mountPath: /root/.aws | ||
ports: | ||
- containerPort: 9810 | ||
name: healthz | ||
protocol: TCP | ||
livenessProbe: | ||
failureThreshold: 5 | ||
httpGet: | ||
path: /healthz | ||
port: healthz | ||
initialDelaySeconds: 10 | ||
timeoutSeconds: 3 | ||
periodSeconds: 2 | ||
- name: node-driver-registrar | ||
image: public.ecr.aws/eks-distro/kubernetes-csi/node-driver-registrar:v2.7.0-eks-1-23-13 | ||
imagePullPolicy: IfNotPresent | ||
args: | ||
- --csi-address=$(ADDRESS) | ||
- --kubelet-registration-path=$(DRIVER_REG_SOCK_PATH) | ||
env: | ||
- name: ADDRESS | ||
value: /csi/csi.sock | ||
- name: DRIVER_REG_SOCK_PATH | ||
value: /var/lib/kubelet/plugins/s3.csi.aws.com/csi.sock | ||
- name: KUBE_NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
volumeMounts: | ||
- name: plugin-dir | ||
mountPath: /csi | ||
- name: registration-dir | ||
mountPath: /registration | ||
- name: liveness-probe | ||
image: public.ecr.aws/eks-distro/kubernetes-csi/livenessprobe:v2.9.0-eks-1-23-13 | ||
imagePullPolicy: IfNotPresent | ||
args: | ||
- --csi-address=/csi/csi.sock | ||
- --health-port=9810 | ||
volumeMounts: | ||
- mountPath: /csi | ||
name: plugin-dir | ||
volumes: | ||
- name: kubelet-dir | ||
hostPath: | ||
path: /var/lib/kubelet | ||
type: Directory | ||
- name: registration-dir | ||
hostPath: | ||
path: /var/lib/kubelet/plugins_registry/ | ||
type: Directory | ||
- name: plugin-dir | ||
hostPath: | ||
path: /var/lib/kubelet/plugins/s3.csi.aws.com/ | ||
type: DirectoryOrCreate | ||
- name: aws-credentials | ||
secret: | ||
secretName: aws-credentials |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
|
||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: s3-csi-driver-sa | ||
labels: | ||
app.kubernetes.io/name: aws-s3-csi-driver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- ../../base | ||
images: | ||
- name: csi-driver | ||
newName: 151381207180.dkr.ecr.eu-west-1.amazonaws.com/s3-csi-driver | ||
newTag: latest | ||
secretGenerator: | ||
- name: aws-credentials | ||
behavior: replace | ||
files: | ||
- credentials |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- ../../base | ||
images: | ||
- name: csi-driver | ||
newName: 151381207180.dkr.ecr.eu-west-1.amazonaws.com/s3-csi-driver | ||
newTag: v0.1.0 |
Oops, something went wrong.