Last active
December 28, 2023 08:16
-
-
Save mateothegreat/5e0fc1b2116376163d5c725f6dd70404 to your computer and use it in GitHub Desktop.
Mounting Google Cloud Storage Bucket inside of Kubernetes Pod
This file contains hidden or 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
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: motion | |
spec: | |
selector: | |
matchLabels: | |
app: motion | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
app: motion | |
spec: | |
imagePullSecrets: | |
- name: regcred | |
containers: | |
- name: motion | |
image: docker.io/appsoa/docker-alpine-motion:3.4 | |
imagePullPolicy: Always | |
command: ["/entrypoint.sh"] | |
args: ["run.sh", "/conf/tested.30fps.1pic.conf", "stable.conf"] | |
ports: | |
- containerPort: 8081 | |
securityContext: | |
privileged: true | |
capabilities: | |
add: ["SYS_ADMIN"] | |
lifecycle: | |
postStart: | |
exec: | |
command: ["gcsfuse", "-o", "nonempty", "streaming-platform-vod-01", "/storage-bucket"] | |
preStop: | |
exec: | |
command: ["fusermount", "-u", "/storage-bucket"] | |
resources: | |
limits: | |
cpu: 200m | |
memory: 300Mi | |
requests: | |
cpu: 100m | |
memory: 300Mi | |
volumeMounts: | |
- name: gcloud-key | |
mountPath: /var/secrets/google | |
env: | |
- name: GOOGLE_APPLICATION_CREDENTIALS | |
value: /var/secrets/google/key.json | |
volumes: | |
- name: gcloud-key | |
configMap: | |
name: gcloud-key |
This file contains hidden or 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
# __ __ | |
# __ ______ ____ ___ ____ _/ /____ ____ ____/ / | |
# / / / / __ \/ __ `__ \/ __ `/ __/ _ \/ __ \/ __ / | |
# / /_/ / /_/ / / / / / / /_/ / /_/ __/ /_/ / /_/ / | |
# \__, /\____/_/ /_/ /_/\__,_/\__/\___/\____/\__,_/ | |
# /____ matthewdavis.io, holla! | |
# | |
FROM node:9.2-alpine | |
ENV GOPATH /go | |
# ENV GOOGLE_APPLICATION_CREDENTIALS=/key.json | |
ENV GCSFUSE_USER=gcsfuse | |
ENV GCSFUSE_MOUNTPOINT=/mnt/gcs | |
ENV GCSFUSE_DEBUG= | |
ENV GCSFUSE_DEBUG_FUSE= | |
ENV GCSFUSE_DEBUG_GCS=1 | |
ENV GCSFUSE_DEBUG_HTTP= | |
ENV GCSFUSE_DEBUG_INVARIANTS= | |
ENV GCSFUSE_DIR_MODE= | |
ENV GCSFUSE_FILE_MODE= | |
ENV GCSFUSE_LIMIT_BPS= | |
ENV GCSFUSE_LIMIT_OPS= | |
ENV GCSFUSE_CACHE_STAT_TTL= | |
ENV GCSFUSE_CACHE_TYPE_TTL= | |
RUN apk \ | |
--update \ | |
--no-cache \ | |
--virtual build-dependencies \ | |
add \ | |
git ffmpeg ffmpeg-dev make autoconf automake gcc g++ libjpeg-turbo-dev go fuse fuse-dev gettext bash | |
RUN git clone --depth 1 https://github.com/Motion-Project/motion.git && \ | |
cd motion && \ | |
autoreconf -fiv && \ | |
./configure --prefix /usr/local && \ | |
make && \ | |
make install | |
RUN go get -u github.com/googlecloudplatform/gcsfuse && \ | |
ln -s /go/bin/gcsfuse /usr/local/bin/gcsfuse && \ | |
rm -rf /go/pkg/ /go/src/ && \ | |
gcsfuse --help && \ | |
mkdir /storage-bucket | |
COPY key.json /key.json | |
COPY entrypoint.sh /entrypoint.sh | |
COPY conf /conf | |
COPY run.sh /bin/run.sh | |
COPY platform-api-client-eventemitter /platform-api-client-eventemitter | |
RUN chmod +x /bin/run.sh | |
WORKDIR /platform-api-client-eventemitter | |
RUN yarn install && \ | |
yarn run build && \ | |
bin/client send -h | |
VOLUME /conf | |
WORKDIR / | |
ENTRYPOINT ["run.sh"] | |
CMD ["/conf/tested.30fps.1pic.conf", "stable.conf"] |
This file contains hidden or 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
#!/bin/sh | |
# | |
# Mount google cloud storage bucket | |
# | |
gcsfuse -o nonempty streaming-platform-vod-01 /storage-bucket | |
# | |
# If there are anymore arguments passed to the entrypoint, | |
# invoke the sh shell and pass the value as a command string. | |
# | |
/bin/sh -c "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment