I am trying to deploy an nginx server in Kubernetes. I am just trying to get a server up and look at it through a loadbalancer while also being able to modify the nginx config.
Using the below configuration I can not get the nginx webserver pod to start.
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-696c84fd7b-dr9hv 0/1 Error 3 55s
looking at the pod log I get the following:
$ kubectl logs nginx-696c84fd7b-dr9hv
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: /etc/nginx/conf.d/default.conf is not a file or does not exist, exiting
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2020/06/30 22:52:03 [emerg] 1#1: no "events" section in configuration
nginx: [emerg] no "events" section in configuration
I assume I am doing something wrong with the config. Do I need to change it to overwrite the or create the default.conf?
FYI - This is coming up in an AWS EKS cluster.
Here is the entire yaml I am launching using "kubectl create -f nginx_deployment.yaml":
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-conf
data:
nginx.conf: |
http {
server {
location / {
return 200 'Eureka!!';
add_header Content-Type text/plain;
}
}
}
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 1
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
volumeMounts:
- mountPath: /etc/nginx # mount nginx-conf volumn to /etc/nginx
readOnly: true
name: nginx-conf
volumes:
- name: nginx-conf
configMap:
name: nginx-conf # place ConfigMap `nginx-conf` on /etc/nginx
items:
- key: nginx.conf
path: nginx.conf
- name: log
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 80
selector:
app: nginx
I tried replacing ir to be default.conf but then it just hangs forever in the "ContainerCreaing" state.
Changes made in the deployment section -
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 1
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
volumeMounts:
- mountPath: /etc/nginx/conf.d # mount nginx-conf volumn to /etc/nginx
readOnly: true
name: nginx-conf
volumes:
- name: nginx-conf
configMap:
name: nginx-conf # place ConfigMap `nginx-conf` on /etc/nginx
items:
- key: default.conf
path: default.conf
- name: log
emptyDir: {}