Skip to content

Instantly share code, notes, and snippets.

@h-sakano
Last active December 23, 2017 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h-sakano/f9ea33348d422db7eff0f6ce7d04ab68 to your computer and use it in GitHub Desktop.
Save h-sakano/f9ea33348d422db7eff0f6ce7d04ab68 to your computer and use it in GitHub Desktop.
GKEのコンテナ内のディレクトリにGCSバケットをマウントする ref: https://qiita.com/h-sakano/items/f82713347eb192586489
.
.
.
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
.
.
.
#!/bin/bash
source /etc/apache2/envvars
chown -R www-data:www-data *
sudo -u www-data gcsfuse example-bucket ./
exec apache2 -D FOREGROUND
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: example
spec:
replicas: 1
template:
metadata:
labels:
app: example
tier: frontend
environment : production
spec:
containers:
- image: gcr.io/example/example_image:0.0.0
imagePullPolicy: Always
name: example
ports:
- containerPort: 80
name: example
securityContext:
privileged: true
---
apiVersion: v1
kind: Service
metadata:
name: example
labels:
app: example
spec:
selector:
app: example
tier: frontend
environment : production
type: LoadBalancer
ports:
- port: 80
protocol: TCP
targetPort: 80
$ gcloud container clusters create example-cluster \
--machine-type f1-micro \
--scopes storage-full
# docker run -it php:5.6-apache /bin/bash
# apt-get install -y lsb-release
# lsb_release -c -s
jessie
.
.
.
: ${APACHE_RUN_USER:=www-data}
export APACHE_RUN_USER
: ${APACHE_RUN_GROUP:=www-data}
export APACHE_RUN_GROUP
.
.
.
FROM php:5.6-apache
WORKDIR /path/to/DocumentRoot
# gcsfuse-[バージョン名]を指定する
RUN echo "deb http://packages.cloud.google.com/apt gcsfuse-jessie main" | tee /etc/apt/sources.list.d/gcsfuse.list
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
RUN groupadd fuse
RUN usermod -aG fuse www-data
RUN apt-get update -y && apt-get install -y \
gcsfuse \
sudo \
vim
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod a+x /usr/local/bin/entrypoint.sh
EXPOSE 80 443
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
docker build -f ./Dockerfile -t example_image:0.0.0 .
docker tag example_image:0.0.0 gcr.io/example/example_image:0.0.0
gcloud docker -- push gcr.io/example/example_image:0.0.0
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: example
spec:
replicas: 1
template:
metadata:
labels:
app: example
tier: frontend
environment : production
spec:
containers:
- image: gcr.io/example/example_image:0.0.0
imagePullPolicy: Always
name: example
ports:
- containerPort: 80
name: example
securityContext:
privileged: true
---
apiVersion: v1
kind: Service
metadata:
name: example
labels:
app: example
spec:
selector:
app: example
tier: frontend
environment : production
type: LoadBalancer
ports:
- port: 80
protocol: TCP
targetPort: 80
$ gcloud container clusters get-credentials example-cluster --project example
$ kubectl create -f example.yaml
$ kubectl get svc example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment