Skip to content

Instantly share code, notes, and snippets.

@matthewpalmer
matthewpalmer / pod.yaml
Created Jun 9, 2018
Example Kubernetes YAML for the multi-container adapter design pattern
View pod.yaml
# Example YAML configuration for the adapter pattern.
# It defines a main application container which writes
# the current date and system usage information to a log file
# every five seconds.
# The adapter container reads what the application has written and
# reformats it into a structure that a hypothetical monitoring
# service requires.
@matthewpalmer
matthewpalmer / pod.yaml
Last active Mar 24, 2021
Example Kubernetes pod for the multi-container sidecar design pattern
View pod.yaml
# Example YAML configuration for the sidecar pattern.
# It defines a main application container which writes
# the current date to a log file every five seconds.
# The sidecar container is nginx serving that log file.
# (In practice, your sidecar is likely to be a log collection
# container that uploads to external storage.)
# To run:
@matthewpalmer
matthewpalmer / pod.yaml
Created Jul 21, 2018
kubernetes nginx php-fpm pod
View pod.yaml
# Create a pod containing the PHP-FPM application (my-php-app)
# and nginx, each mounting the `shared-files` volume to their
# respective /var/www/html directories.
kind: Pod
apiVersion: v1
metadata:
name: phpfpm-nginx-example
spec:
volumes:
@matthewpalmer
matthewpalmer / pod.yaml
Created Oct 22, 2018
Example for using NFS volume in pod
View pod.yaml
# Create a pod that reads and writes to the
# NFS server via an NFS volume.
kind: Pod
apiVersion: v1
metadata:
name: pod-using-nfs
spec:
# Add the server as an NFS volume for the pod
volumes:
View config-map.yaml
kind: ConfigMap
apiVersion: v1
metadata:
name: example-configmap
data:
# Configuration values can be set as key-value properties
database: mongodb
database_uri: mongodb://localhost:27017
# Or set as complete file contents (even JSON!)
View pod.yaml
kind: Pod
apiVersion: v1
metadata:
name: pod-using-configmap
spec:
# Add the ConfigMap as a volume to the Pod
volumes:
# `name` here must match the name
# specified in the volume mount
View pod-env-var.yaml
kind: Pod
apiVersion: v1
metadata:
name: pod-env-var
spec:
containers:
- name: env-var-configmap
image: nginx:1.7.9
envFrom:
- configMapRef:
View deployment.yaml
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: nginx-deployment
spec:
# A deployment's specification really only
# has a few useful options
# 1. How many copies of each pod do we want?
replicas: 3
@matthewpalmer
matthewpalmer / pod.yaml
Created Oct 22, 2018
Pod using NFS volume
View pod.yaml
# Create a pod that reads and writes to the
# NFS server via an NFS volume.
kind: Pod
apiVersion: v1
metadata:
name: pod-using-nfs
spec:
# Add the server as an NFS volume for the pod
volumes:
View gist:3bfecedbbe75addf062813557bd07c70
nfs ⟩ kubectl exec -it pod-using-nfs sh
/ # cat /var/nfs/dates.txt
Mon Oct 22 00:47:36 UTC 2018
Mon Oct 22 00:47:41 UTC 2018
Mon Oct 22 00:47:46 UTC 2018
nfs ⟩ kubectl exec -it nfs-server-pod sh
# cat /exports/dates.txt