Created
September 22, 2021 21:32
-
-
Save jessegoodier/5bfa5be476cfb6c9e21496b3faf0d1da to your computer and use it in GitHub Desktop.
non-root nginx container that will echo uri and host header
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: Namespace | |
metadata: | |
name: demo-app1 | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: demo-app1 | |
namespace: demo-app1 | |
labels: | |
app: demo-app1 | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: demo-app1 | |
template: | |
metadata: | |
labels: | |
app: demo-app1 | |
spec: | |
containers: | |
- name: demo-app1 | |
image: nginxinc/nginx-unprivileged | |
ports: | |
- containerPort: 8080 | |
protocol: TCP | |
resources: {} | |
imagePullPolicy: IfNotPresent | |
volumeMounts: | |
- mountPath: /etc/nginx/conf.d | |
name: default-conf | |
readOnly: true | |
volumes: | |
- name: default-conf | |
configMap: | |
name: nginx-echo | |
items: | |
- key: default.conf | |
path: default.conf | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: demo-app1 | |
namespace: demo-app1 | |
spec: | |
ports: | |
- name: demo-app1 | |
protocol: TCP | |
port: 8080 | |
targetPort: 8080 | |
selector: | |
app: demo-app1 | |
type: ClusterIP | |
--- | |
apiVersion: k8s.nginx.org/v1 | |
kind: VirtualServer | |
metadata: | |
name: demo-app1 | |
namespace: demo-app1 | |
spec: | |
ingressClassName: nginx | |
host: "hello.k4.nginx.rocks" | |
routes: | |
- path: / | |
action: | |
pass: demo-app1-upstream | |
upstreams: | |
- name: demo-app1-upstream | |
service: demo-app1 | |
port: 8080 | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: nginx-echo | |
namespace: demo-app1 | |
data: | |
default.conf: | | |
server { | |
listen 8080; | |
location / { | |
default_type text/plain; | |
expires -1; | |
return 200 'Server address: $server_addr:$server_port\nServer name: $hostname\nDate: $time_local\nURI: $request_uri\nRequest ID: $request_id\nHost header: $Host\n'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment