Skip to content

Instantly share code, notes, and snippets.

@thapakazi
Last active January 29, 2021 15:12
Show Gist options
  • Save thapakazi/81a288817fe12147ae17df232e66d3f5 to your computer and use it in GitHub Desktop.
Save thapakazi/81a288817fe12147ae17df232e66d3f5 to your computer and use it in GitHub Desktop.
simple nginx pod mounting custom config file
    #create config map
    curl -sL https://git.io/Jt80f  > /tmp/site.conf
    kubectl create cm nginx-config --from-file=/tmp/site.conf -o yaml --dry-run=client
    
    #lets see it in action, will ya ? 
    kubectl create cm nginx-config --from-file=/tmp/site.conf 
    
    kubectl apply -f https://git.io/Jt8uz 
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx-config
name: nginx-config
spec:
containers:
- image: nginx
name: nginx-config
volumeMounts:
- name: my-site
mountPath: /etc/nginx/conf.d
volumes:
- name: my-site
configMap:
name: nginx-config
items:
- key: site.conf
path: site.conf
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
server {
listen 80;
listen [::]:80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /google{
rewrite ^/google(.*)$ https://google.com/search?q=$1 redirect;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment