Skip to content

Instantly share code, notes, and snippets.

@rhrn
Created May 1, 2019 13:36
Show Gist options
  • Save rhrn/583ece54f71bc76b2a23391026936f27 to your computer and use it in GitHub Desktop.
Save rhrn/583ece54f71bc76b2a23391026936f27 to your computer and use it in GitHub Desktop.
Kubernetes test nginx yaml
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-test-config
data:
nginx.conf: |
worker_processes 1;
error_log /dev/stdout info;
pid /tmp/nginx.pid;
events {
worker_connections 1024;
}
http {
## non-root
client_body_temp_path /tmp/client_temp 1 2;
proxy_temp_path /tmp/proxy_temp;
fastcgi_temp_path /tmp/fastcgi_temp 1 2;
uwsgi_temp_path /tmp/uwsgi_temp 1 2;
scgi_temp_path /tmp/scgi_temp 1 2;
charset utf-8;
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
include /etc/nginx/conf.d/*.conf;
}
default.conf: |
server {
listen 80;
server_name _;
location / {
add_header Content-Type text/html;
return 200 'Nginx test success';
}
}
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: nginx-test-deployment
spec:
replicas: 1
template:
metadata:
labels:
app: nginx-test-app
spec:
containers:
- name: nginx-test-container
image: nginx:alpine
ports:
- containerPort: 80
volumeMounts:
- name: nginx-test-volume
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
- name: nginx-test-volume
mountPath: /etc/nginx/conf.d/default.conf
subPath: default.conf
volumes:
- name: nginx-test-volume
configMap:
name: nginx-test-config
---
apiVersion: v1
kind: Service
metadata:
name: nginx-test-service
spec:
type: NodePort
selector:
app: nginx-test-app
ports:
- port: 80
targetPort: 80
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginx-test-ingress
annotations:
kubernetes.io/ingress.class: traefik # replace by ingress type eg. nginx
spec:
backend:
serviceName: nginx-test-service
servicePort: 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment