github地址:https://github.com/freegroup/kube-s3
DaemonSet的配置 mountPath: /var/s3:shared 在containerd引擎下变成了路径/var/s3:shared
修改mountPath去掉shared, 添加:mountPropagation: Bidirectional
yaml如下:
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
app: s3-provider
name: s3-provider
spec:
selector:
matchLabels:
app: s3-provider
template:
metadata:
labels:
app: s3-provider
spec:
containers:
- name: s3fuse
image: kube-s3:1.0
lifecycle:
preStop:
exec:
command: ["/bin/sh","-c","umount -f /var/s3"]
securityContext:
privileged: true
envFrom:
- secretRef:
name: s3-config
volumeMounts:
- name: mntdatas3fs
mountPath: /var/s3
mountPropagation: Bidirectional
volumes:
- name: mntdatas3fs
hostPath:
path: /mnt/data-s3-fs
example_pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: nginx:1.20.0
name: s3-test-container
volumeMounts:
- name: mntdatas3fs
mountPath: /var/s3
volumes:
- name: mntdatas3fs
hostPath:
path: /mnt/data-s3-fs/
DockerFfile
FROM alpine:latest
ENV MNT_POINT /var/s3
ENV S3_REGION ''
VOLUME /var/s3
ARG S3FS_VERSION=v1.91
RUN apk --update add bash fuse libcurl libxml2 libstdc++ libgcc alpine-sdk automake autoconf libxml2-dev fuse-dev curl-dev git; \
git clone https://github.com/s3fs-fuse/s3fs-fuse.git; \
cd s3fs-fuse; \
git checkout tags/${S3FS_VERSION}; \
./autogen.sh; \
./configure --prefix=/usr ; \
make; \
make install; \
make clean; \
rm -rf /var/cache/apk/*; \
apk del git automake autoconf;
RUN mkdir -p "$MNT_POINT"
CMD echo "${AWS_KEY}:${AWS_SECRET_KEY}" > /etc/passwd-s3fs && \
chmod 0400 /etc/passwd-s3fs && \
/usr/bin/s3fs $S3_BUCKET $MNT_POINT -f -o url=${S3_URL},endpoint=${S3_REGION},allow_other,use_cache=/tmp,max_stat_cache_size=1000,stat_cache_expire=900,retries=5,connect_timeout=10,use_path_request_style
Secret
apiVersion: v1
kind: Secret
metadata:
name: s3-config
stringData:
S3_URL: http://_your_s3_url
S3_BUCKET: bucket_name
AWS_KEY: xxxxx
AWS_SECRET_KEY: xxxxx
网友评论