Created
April 23, 2020 11:46
-
-
Save plutov/34d904edaa07d57bc0c1b84bc42114e4 to your computer and use it in GitHub Desktop.
gcs-k8f-deployment-full.yml
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: v1 | |
kind: Secret | |
metadata: | |
name: sa-secret | |
data: | |
sa_json: YOUR_SERVICE_ACCOUNT_BASE64_KEY | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: gcs-k8s-example | |
labels: | |
app.kubernetes.io/name: gcs-k8s-example | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app.kubernetes.io/name: gcs-k8s-example | |
template: | |
metadata: | |
labels: | |
app.kubernetes.io/name: gcs-k8s-example | |
spec: | |
volumes: | |
- name: sa-volume | |
secret: | |
secretName: sa-secret | |
items: | |
- key: sa_json | |
path: sa_credentials.json | |
containers: | |
- name: gcs-k8s-example | |
image: "YOUR_IMAGE:latest" | |
imagePullPolicy: Always | |
volumeMounts: | |
- name: sa-volume | |
mountPath: /etc/gcp | |
readOnly: true | |
ports: | |
- name: http | |
containerPort: 3000 | |
protocol: TCP | |
env: | |
- name: GOOGLE_APPLICATION_CREDENTIALS | |
value: /etc/gcp/sa_credentials.json | |
securityContext: | |
privileged: true | |
capabilities: | |
add: | |
- SYS_ADMIN | |
lifecycle: | |
postStart: | |
exec: | |
command: ["gcsfuse", "-o", "nonempty,allow_other", "bucket-name", "/usr/share/nginx/bucket-data"] | |
preStop: | |
exec: | |
command: ["fusermount", "-u", "/usr/share/nginx/bucket-data"] | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: gcs-k8s-example | |
labels: | |
app.kubernetes.io/name: gcs-k8s-example | |
spec: | |
type: NodePort | |
ports: | |
- port: 3000 | |
targetPort: http | |
protocol: TCP | |
name: http | |
selector: | |
app.kubernetes.io/name: gcs-k8s-example |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment