Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: <Image>
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: <Port>
Services
apiVersion: v1
kind: Service
metadata:
name: myapp
spec:
selector:
app: myapp
ports:
- port: <Port>
targetPort: <Target Port>
Secret
apiVersion: v1
kind: Secret
metadata:
name: mysecret
type: Opaque
data:
password: <Password>
Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: myingress
labels:
name: myingress
spec:
rules:
- host: <Host>
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: <Service>
port:
number: <Port>
Pod
apiVersion: v1
kind: Pod
metadata:
name: myapp
labels:
name: myapp
spec:
containers:
- name: myapp
image: <Image>
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: <Port>
Persistent volume
apiVersion: v1
kind: PersistentVolume
metadata:
name: mypv
spec:
capacity:
storage: <Size>
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Recycle
storageClassName: slow
mountOptions:
- hard
- nfsvers=4.1
nfs:
path: /tmp
server: 172.17.0.2
Persistent Volume Claim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mypvc
spec:
resources:
requests:
storage: <Size>
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: myapp
data:
key: value
Replication Controller
apiVersion: v1
kind: ReplicationController
metadata:
name: myapp
spec:
replicas: <Replicas>
selector:
app: myapp
template:
metadata:
name: myapp
labels:
app: myapp
spec:
containers:
- name: myapp
image: <Image>
ports:
- containerPort: <Port>
StatefulSet
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mystatefulset
spec:
selector:
matchLabels:
app: myapp
serviceName: <ServiceName>
replicas: 2
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: k8s.gcr.io/nginx-slim:0.8
ports:
- containerPort: 80
name: web
volumeMounts:
- name: www
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
HorizontalPodAutoscaler
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: myapp
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: myapp
minReplicas: 1
maxReplicas: 3
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50