Skip to content

Instantly share code, notes, and snippets.

@dimMaryanto93
Last active April 8, 2023 11:40
Show Gist options
  • Save dimMaryanto93/96f6954c9a27a6b1934113b10223196a to your computer and use it in GitHub Desktop.
Save dimMaryanto93/96f6954c9a27a6b1934113b10223196a to your computer and use it in GitHub Desktop.
Kubernetes Workload Resources

Kubernetes workload resources

  • Deployment
  • Stateful
  • Job
  • CronJob
  • DeamonSet
  • Cannary Deployment
  • BlueGreen Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: autoscale-nginx-deploy
labels:
app: nginx
env: test
spec:
replicas: 3
selector:
matchLabels:
app: nginx
env: test
template:
metadata:
name: autoscale-nginx-deploy
labels:
app: nginx
env: test
spec:
containers:
- name: nginx
image: nginx:mainline
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 10m
memory: 10Mi
limits:
cpu: 50m
memory: 50Mi
ports:
- containerPort: 80
name: http
restartPolicy: Always
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: autoscale-nginx-deploy
spec:
maxReplicas: 10
minReplicas: 1
scaleTargetRef:
kind: Deployment
name: autoscale-nginx-deploy
apiVersion: apps/v1
metrics:
- type: Pods
pods:
metric:
name: packets-per-second
target:
type: AverageValue
averageValue: 5k
---
apiVersion: v1
kind: Service
metadata:
name: autoscale-nginx-deploy
spec:
selector:
app: nginx
env: test
ports:
- protocol: TCP
port: 80
targetPort: 80
type: NodePort
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deploy
labels:
app: nginx
env: test
spec:
replicas: 3
selector:
matchLabels:
app: nginx
env: test
template:
metadata:
name: nginx-deploy
labels:
app: nginx
env: test
spec:
containers:
- name: nginx
image: nginx:mainline
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
name: http
restartPolicy: Always
apiVersion: apps/v1
kind: Deployment
metadata:
name: rollingupdate-nginx-deploy
labels:
app: nginx
env: test
spec:
strategy:
rollingUpdate:
maxSurge: 3
maxUnavailable: 2
replicas: 10
selector:
matchLabels:
app: nginx
env: test
template:
metadata:
name: nginx
labels:
app: nginx
env: test
spec:
containers:
- name: nginx
image: nginx:mainline
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
name: http
restartPolicy: Always
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment