Example how to use ConfigMap from file in Kubernetes

This is reverseproxy.conf - a config for reverse proxy for Nginx:

server {
    listen       80;
    server_name  localhost;

    location / {
        proxy_bind 127.0.0.1;
        proxy_pass http://127.0.0.1:8080;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}
Create a ConfigMap from the above file:
kubectl create cm nginx-config --from-file=reverseproxy.conf
Let's have a Pod config which have 2 containers - nginx.yml, which will use created ConfigMap:
apiVersion: v1
kind: Pod
metadata:
  name: helloworld-nginx
  labels:
    app: helloworld-nginx
spec:
  containers:
  - name: nginx
    image: nginx
    ports:
    - containerPort: 80
    volumeMounts:
    - name: config-volume
      mountPath: /etc/nginx/conf.d
  - name: k8s-demo
    image: dmitritelinov/hw-node
    ports:
    - containerPort: 8080
  volumes:
    - name: config-volume
      configMap:
        name: nginx-config
        items:
        - key: reverseproxy.conf
          path: reverseproxy.conf
The image dmitritelinov/hw-node is created from simple NodeJS app.

Expose the Pod. Create a Service object - nginx-service.yml:
apiVersion: v1
kind: Service
metadata:
  name: helloworld-nginx-service
spec:
  ports:
  - port: 80
    protocol: TCP
  selector:
    app: helloworld-nginx
  type: NodePort
If you are on Minikube, get Service URL:
$ minikube service helloworld-nginx-service --url
http://192.168.39.249:30945
Access the below URL:
$ curl http://192.168.39.249:30945
Hello, world!