Last active
December 23, 2017 09:26
-
-
Save h-sakano/f9ea33348d422db7eff0f6ce7d04ab68 to your computer and use it in GitHub Desktop.
GKEのコンテナ内のディレクトリにGCSバケットをマウントする ref: https://qiita.com/h-sakano/items/f82713347eb192586489
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
. | |
. | |
. | |
# These need to be set in /etc/apache2/envvars | |
User ${APACHE_RUN_USER} | |
Group ${APACHE_RUN_GROUP} | |
. | |
. | |
. |
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
#!/bin/bash | |
source /etc/apache2/envvars | |
chown -R www-data:www-data * | |
sudo -u www-data gcsfuse example-bucket ./ | |
exec apache2 -D FOREGROUND |
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
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 |
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
$ gcloud container clusters create example-cluster \ | |
--machine-type f1-micro \ | |
--scopes storage-full |
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
# docker run -it php:5.6-apache /bin/bash | |
# apt-get install -y lsb-release | |
# lsb_release -c -s | |
jessie |
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
. | |
. | |
. | |
: ${APACHE_RUN_USER:=www-data} | |
export APACHE_RUN_USER | |
: ${APACHE_RUN_GROUP:=www-data} | |
export APACHE_RUN_GROUP | |
. | |
. | |
. |
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
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"] |
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
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 |
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
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 |
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
$ gcloud container clusters get-credentials example-cluster --project example | |
$ kubectl create -f example.yaml |
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
$ kubectl get svc example |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment