Skip to content

Instantly share code, notes, and snippets.

@kieranajp
Last active February 13, 2020 20:47
Show Gist options
  • Save kieranajp/f861feada2a2fc2835c98c857e95170f to your computer and use it in GitHub Desktop.
Save kieranajp/f861feada2a2fc2835c98c857e95170f to your computer and use it in GitHub Desktop.
Kubernetes example files used in tech talk Feb 2020
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cron
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: cron
image: busybox
args:
- /bin/sh
- -c
- date; echo Hello from Kube
restartPolicy: OnFailure
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
labels:
tier: backend
spec:
replicas: 3
selector:
matchLabels:
app: my-app
tier: backend
template:
metadata:
labels:
app: my-app
tier: backend
spec:
volumes:
- name: config
configMap:
name: nginx-config
items:
- key: config
path: site.conf
containers:
- name: nginx
image: nginx:1.17
ports:
- containerPort: 80
volumeMounts:
- name: config
mountPath: /etc/nginx/conf.d
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 15
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
- name: php
image: php:7.4-fpm
resources:
requests:
cpu: 250m
memory: 100Mi
ports:
- name: fpm
containerPort: 9000
protocol: TCP
---
kind: Service
apiVersion: v1
metadata:
name: my-app
spec:
type: LoadBalancer
selector:
app: my-app
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
labels:
tier: backend
data:
config : |
server {
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location = / {
add_header Content-Type text/plain;
return 200 'hello world';
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass localhost:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment