Skip to content

Instantly share code, notes, and snippets.

@sidpalas
Last active November 13, 2024 23:08
Show Gist options
  • Select an option

  • Save sidpalas/e388f1a63bacc4c365d6cebf366f492d to your computer and use it in GitHub Desktop.

Select an option

Save sidpalas/e388f1a63bacc4c365d6cebf366f492d to your computer and use it in GitHub Desktop.

Revisions

  1. sidpalas revised this gist Mar 1, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion maintenance-page.yaml
    Original file line number Diff line number Diff line change
    @@ -114,5 +114,5 @@ spec:
    service:
    name: maintenance-page
    port:
    number: 8080
    number: 80
    # Can still have other paths defined
  2. sidpalas revised this gist Oct 30, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion maintenance-page.yaml
    Original file line number Diff line number Diff line change
    @@ -102,7 +102,7 @@ metadata:
    annotations:
    kubernetes.io/ingress.class: nginx
    nginx.org/rewrites: serviceName=maintenance-page rewrite=/;
    name: my-ingress
    name: maintenance-page
    spec:
    rules:
    - host: maintenance.devopsdirective.com
  3. sidpalas revised this gist Oct 30, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions maintenance-page.yaml
    Original file line number Diff line number Diff line change
    @@ -24,6 +24,7 @@ data:
    article { display: block; text-align: left; width: 650px; margin: 0 auto; }
    a { color: #dc8100; text-decoration: none; }
    a:hover { color: #333; text-decoration: none; }
    img { border-radius: 50%; }
    default.conf: |-
    # NGINX CONFIGURATION GOES HERE
    server {
  4. sidpalas created this gist Oct 30, 2022.
    117 changes: 117 additions & 0 deletions maintenance-page.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,117 @@
    apiVersion: v1
    kind: ConfigMap
    metadata:
    name: maintenance-page
    data:
    maintenance.html: |-
    <!--HTML GOES HERE-->
    <!doctype html>
    <title>Site Maintenance</title>
    <link rel="stylesheet" href="maintenance.css">
    <article>
    <h1>We&rsquo;ll be back soon!</h1>
    <div>
    <p>Sorry for the inconvenience but we&rsquo;re performing some maintenance at the moment. If you need to you can always <a href="mailto:#">contact us</a>, otherwise we&rsquo;ll be back online shortly!</p>
    <p>&mdash; The Team</p>
    </div>
    <div><img src="https://pbs.twimg.com/profile_images/1326958623587700736/_sXRf1ch_400x400.jpg"></div>
    </article>
    maintenance.css: |-
    /* CSS GOES HERE */
    body { text-align: center; padding: 150px; background-color: #D3D3D3;}
    h1 { font-size: 50px; }
    body { font: 20px Helvetica, sans-serif; color: #333; }
    article { display: block; text-align: left; width: 650px; margin: 0 auto; }
    a { color: #dc8100; text-decoration: none; }
    a:hover { color: #333; text-decoration: none; }
    default.conf: |-
    # NGINX CONFIGURATION GOES HERE
    server {
    listen 80 default_server;
    server_name _ ;
    location / {
    if (-f /usr/share/nginx/html/maintenance/maintenance.html) {
    return 503;
    }
    }
    # for all routes, return maintenance page
    error_page 503 @maintenance;
    location @maintenance {
    root /usr/share/nginx/html/maintenance/;
    rewrite ^(.*)$ /maintenance.html break;
    }
    # allow images and css to be retrieved
    location ~* \.(png|jpg|jpeg|css) {
    root /usr/share/nginx/html/maintenance/;
    }
    }
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: maintenance-page
    labels:
    app: maintenance-page
    spec:
    replicas: 1
    selector:
    matchLabels:
    app: maintenance-page
    template:
    metadata:
    labels:
    app: maintenance-page
    spec:
    containers:
    - name: nginx
    image: nginx:1.23
    ports:
    - containerPort: 80
    volumeMounts:
    # Because no subPath is specified, all keys in configmap willb
    # be mounted as files at the specified mountPath
    - name: config-volume
    mountPath: /usr/share/nginx/html/maintenance/
    - name: config-volume
    mountPath: /etc/nginx/conf.d/default.conf
    subPath: default.conf
    volumes:
    - name: config-volume
    configMap:
    name: maintenance-page
    ---
    apiVersion: v1
    kind: Service
    metadata:
    name: maintenance-page
    spec:
    selector:
    app: maintenance-page
    ports:
    - protocol: TCP
    port: 80
    targetPort: 80
    ---
    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
    annotations:
    kubernetes.io/ingress.class: nginx
    nginx.org/rewrites: serviceName=maintenance-page rewrite=/;
    name: my-ingress
    spec:
    rules:
    - host: maintenance.devopsdirective.com
    http:
    paths:
    - path: /
    pathType: Prefix
    backend:
    service:
    name: maintenance-page
    port:
    number: 8080
    # Can still have other paths defined