Skip to content

Instantly share code, notes, and snippets.

@Topher-the-Geek
Last active February 7, 2021 18:32
Show Gist options
  • Select an option

  • Save Topher-the-Geek/730dcca1808a44247aa338f1a65f28bd to your computer and use it in GitHub Desktop.

Select an option

Save Topher-the-Geek/730dcca1808a44247aa338f1a65f28bd to your computer and use it in GitHub Desktop.

Revisions

  1. Topher-the-Geek revised this gist Feb 7, 2021. No changes.
  2. Topher-the-Geek created this gist Feb 7, 2021.
    87 changes: 87 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,87 @@
    # Simple PHP app served through AWS Application Load Balancer to Kubernetes cluster.
    # Assumes you have setup a Kubernetes cluster with AWS Load Balancer Controller and External DNS
    # https://kubernetes-sigs.github.io/aws-load-balancer-controller/latest/
    # https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/aws.md
    # https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/alb-ingress.md
    # There's a couple place holders near the bottom to be filled in.

    apiVersion: v1
    kind: ConfigMap
    metadata:
    name: view-headers
    labels:
    k8s-app: view-headers
    data:
    index.php: |
    <html>
    <head>
    <title>PHP Test</title>
    </head>
    <body>
    <?php
    $headers = getallheaders();
    foreach($headers as $key=>$val){
    echo $key . ': ' . $val . '<br>';
    }
    ?>
    </body>
    </html>
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: view-headers
    spec:
    selector:
    matchLabels:
    run: view-headers
    replicas: 2
    template:
    metadata:
    labels:
    run: view-headers
    spec:
    containers:
    - name: php
    image: php:7.2-apache
    ports:
    - containerPort: 80
    volumeMounts:
    - name: view-headers
    mountPath: /var/www/html/
    volumes:
    - name: view-headers
    configMap:
    name: view-headers
    ---
    kind: Service
    apiVersion: v1
    metadata:
    name: view-headers
    labels:
    run: view-headers
    spec:
    type: NodePort
    selector:
    run: view-headers
    ports:
    - port: 80
    targetPort: 80
    ---
    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
    name: view-headers
    annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/certificate-arn: <Your AWS CertificateManager Cert, or remove this line>
    spec:
    rules:
    - host: view-headers.<Your Route53 Hosted Zone>
    http:
    paths:
    - path: /*
    backend:
    serviceName: view-headers
    servicePort: 80