Created
November 5, 2019 16:16
-
-
Save aschmidt75/fb3d71729e93619024889d85de572b68 to your computer and use it in GitHub Desktop.
k8s-sample-nginx-conf-deployment
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: v1 | |
kind: ConfigMap | |
metadata: | |
name: nginx-conf | |
data: | |
nginx.conf: | | |
user nginx; | |
worker_processes 3; | |
error_log /var/log/nginx/error.log; | |
events { | |
worker_connections 10240; | |
} | |
http { | |
log_format main | |
'remote_addr:$remote_addr\t' | |
'time_local:$time_local\t' | |
'method:$request_method\t' | |
'uri:$request_uri\t' | |
'host:$host\t' | |
'status:$status\t' | |
'bytes_sent:$body_bytes_sent\t' | |
'referer:$http_referer\t' | |
'useragent:$http_user_agent\t' | |
'forwardedfor:$http_x_forwarded_for\t' | |
'request_time:$request_time'; | |
access_log /var/log/nginx/access.log main; | |
server { | |
listen 80; | |
server_name _; | |
location / { | |
} | |
} | |
include /etc/nginx/virtualhost/virtualhost.conf; | |
} | |
virtualhost.conf: | | |
upstream app { | |
server app:8080; | |
keepalive 1024; | |
} | |
server { | |
listen 80 default_server; | |
root /usr/local/app; | |
access_log /var/log/nginx/app.access_log main; | |
error_log /var/log/nginx/app.error_log; | |
location / { | |
proxy_pass http://app/; | |
proxy_http_version 1.1; | |
} | |
} |
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: apps/v1 | |
kind: Deployment | |
metadata: | |
creationTimestamp: null | |
labels: | |
run: webserver1 | |
name: webserver1 | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
run: webserver1 | |
strategy: {} | |
template: | |
metadata: | |
creationTimestamp: null | |
labels: | |
run: webserver1 | |
spec: | |
containers: | |
- image: nginx | |
name: webserver1 | |
resources: {} | |
ports: | |
- containerPort: 80 | |
protocol: TCP | |
volumeMounts: | |
- mountPath: /etc/nginx # mount nginx-conf volumn to /etc/nginx | |
readOnly: true | |
name: nginx-conf | |
- mountPath: /var/log/nginx | |
name: log | |
volumes: | |
- name: nginx-conf | |
configMap: | |
name: nginx-conf # place ConfigMap `nginx-conf` on /etc/nginx | |
items: | |
- key: nginx.conf | |
path: nginx.conf | |
- key: virtualhost.conf | |
path: virtualhost/virtualhost.conf # dig directory | |
- name: log | |
emptyDir: {} | |
status: {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment