Skip to content

Instantly share code, notes, and snippets.

@tfogo
Last active September 10, 2018 18:48
Show Gist options
  • Save tfogo/170c4889502ac2347d5110048e4a7a92 to your computer and use it in GitHub Desktop.
Save tfogo/170c4889502ac2347d5110048e4a7a92 to your computer and use it in GitHub Desktop.
apiVersion: v1
kind: Deployment
metadata:
name: devops
labels:
env: prod
spec:
replicas: 10
# Update strategy used by this deployment
strategy:
rollingUpdate:
# Maximum number of pods created during an update
# over the desired number. Here the max is 12.
maxSurge: 20%
# Number of pods that can be unavailble during an update
maxUnavailable: 0
selector:
# Pods with this label will be part of the deployment
matchLabels:
app: devops
template:
metadata:
name: devops
# Make sure this matches the matchLabels
labels:
app: devops
spec:
# Define a configMap as a volume
volumes:
- name: config-volume
configMap:
name: my-config
containers:
- image: tfogo/devops
name: devops
ports:
- containerPort: 80
# Mount configMap volume
volumeMounts:
- name: config-volume
mountPath: /config
# Set environment variables from a secret
env:
- name: SECRET_TOKEN
valueFrom:
secretKeyRef:
name: mysecret
key: token
apiVersion: v1
kind: Pod
metadata:
name: devops
labels:
env: prod
spec:
# Volumes for the pod. Can be many different types.
# Here we use the emptyDir volume type.
volumes:
- name: cache-volume
emptyDir: {}
containers:
- image: tfogo/devops
name: devops
# Where to mount volumes in the container
volumeMounts:
- mountPath: /cache
name: cache-volume
# What ports to expose on the container
ports:
- containerPort: 80
name: http
protocol: TCP
resources:
# Request these minimum resources
requests:
cpu: 500m
memory: 128Mi
# Define how K8s tests for the pod's liveness
livenessProbe:
httpGet:
path: /healthy
port: 80
initialDelaySeconds: 5
timeoutSeconds: 1
periodSeconds: 10
failureThreshold: 3
apiVersion: v1
kind: Pod
metadata:
name: devops
labels:
env: prod
spec:
# Volumes for the pod. Can be many different types.
# Here we use the emptyDir volume type.
volumes:
- name: cache-volume
emptyDir: {}
containers:
- image: tfogo/devops
name: devops
# Where to mount volumes in the container
volumeMounts:
- mountPath: /cache
name: cache-volume
# What ports to expose on the container
ports:
- containerPort: 80
name: http
protocol: TCP
resources:
# Request these minimum resources
requests:
cpu: 500m
memory: 128Mi
# Define how K8s tests for the pod's liveness
livenessProbe:
httpGet:
path: /healthy
port: 80
initialDelaySeconds: 5
timeoutSeconds: 1
periodSeconds: 10
failureThreshold: 3
kind: Service
apiVersion: v1
metadata:
name: devops
spec:
selector:
# Pods with this label will be routed to by this service
app: devops
ports:
- protocol: TCP
# Port exposed on the Service Cluster IP
port: 80
# Exposed port on the Pod
targetPort: 80
# Service type can be ClusterIP (default),
# NodePort, LoadBalancer, or ExternalName
type: NodePort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment