Skip to content

Instantly share code, notes, and snippets.

@jakubhajek
Created February 21, 2021 20:39
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 jakubhajek/5aaeb42d3a62729d7542bd3631138bd3 to your computer and use it in GitHub Desktop.
Save jakubhajek/5aaeb42d3a62729d7542bd3631138bd3 to your computer and use it in GitHub Desktop.
K8S config: nginx +web dav with pvc, configmap, env
apiVersion: v1
data:
dav.conf: |
location /upload {
alias upload/data;
client_body_temp_path upload/client_tmp;
dav_methods PUT DELETE MKCOL COPY MOVE;
client_max_body_size 1500m;
create_full_put_path on;
dav_access group:rw all:r;
}
kind: ConfigMap
metadata:
creationTimestamp: null
name: dav
# k create cm upload-file --from-file=default.conf
# curl -T file.mp3 http://localhost/upload
server {
listen 80 default_server;
listen [::]:80;
server_name localhost ;
location /upload {
root /usr/share/nginx/html;
#alias upload/data;
client_body_temp_path /usr/share/nginx/html/upload/client_tmp;
dav_methods PUT DELETE MKCOL COPY MOVE;
client_max_body_size 128m;
create_full_put_path on;
dav_access group:rw all:r;
}
}
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: nginx-with-pvc
name: nginx-with-pvc
spec:
replicas: 1
selector:
matchLabels:
app: nginx-with-pvc
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: nginx-with-pvc
spec:
containers:
- image: nginx:latest
name: nginx
#command: ["sleep", "3600"]
ports:
- containerPort: 80
name: "http-server"
env:
- name: ENV_1
values: "val1"
resources: {}
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: wolumenik
- name: upload
mountPath: "/etc/nginx/conf.d/default.conf"
subPath: "default.conf"
initContainers:
- name: create-dir
image: busybox:1.31.1
command: ["sh", "-c", "mkdir -pv /usr/share/nginx/html/upload/client_tmp && chown -Rv 101.101 /usr/share/nginx/html/*"]
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: wolumenik
volumes:
- name: wolumenik
#emptyDir: {}
persistentVolumeClaim:
claimName: nginx-pvc
- name: upload
configMap:
name: upload-file
status: {}
---
apiVersion: v1
kind: Service
metadata:
name: nginx-with-pvc
spec:
type: ClusterIP
selector:
app: nginx-with-pvc
ports:
- port: 80
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
component: "nginx-test-with-pvc"
name: nginx-pvc
spec:
accessModes:
# ReadWriteOnce -- the volume can be mounted as read-write by a single node
# ReadOnlyMany -- the volume can be mounted read-only by many nodes
# ReadWriteMany -- the volume can be mounted as read-write by many nodes
- ReadWriteOnce
# storageClassName: "temporary-class"
resources:
requests:
storage: "128Mi"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment