Kubernetes Resources Examples
Fleetingkubernetes resources examples
Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: minimal-ingress
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-svc
port:
number: 8000
Pod
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: my
image: busybox
command: ["sh"]
args: ["-c", "nc -l 0.0.0.0 -p 8000"]
ports:
- containerPort: 8000
PersistentVolume
apiVersion: "v1"
kind: "PersistentVolume"
metadata:
name: "my-pv"
spec:
capacity:
storage: 10Gi
accessModes:
- "ReadWriteOnce"
gcePersistentDisk:
fsType: "ext4"
pdName: "my-test-disk"
PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-pvc
spec:
storageClassName: "" # Empty string must be explicitly set otherwise default StorageClass will be set
volumeName: my-pv
resources:
requests:
storage: 100Mi
accessModes:
- ReadWriteOnce
Pod
apiVersion: v1
kind: Pod
metadata:
name: my-reader
spec:
containers:
- name: my
image: busybox
command: ["sh"]
args: ["-c", "ls /volume/ && sleep 3600"]
volumeMounts:
- mountPath: "/volume"
name: my-volume
volumes:
- name: my-volume
persistentVolumeClaim:
claimName: my-pvc
Service
apiVersion: v1
kind: Service
metadata:
name: my-svc
spec:
ports:
- name: "test"
port: 8000
selector:
name: my-pod
Pod
apiVersion: v1
kind: Pod
metadata:
name: my-writer
spec:
containers:
- name: my
image: busybox
command: ["sh"]
args: ["-c", "echo test > /volume/test && sleep 3600"]
volumeMounts:
- mountPath: "/volume"
name: my-volume
volumes:
- name: my-volume
persistentVolumeClaim:
claimName: my-pvc
Pod
apiVersion: v1
kind: Pod
metadata:
name: my-writer2
spec:
containers:
- name: my
image: busybox
command: ["sh"]
args: ["-c", "echo test > /volume/test2 && sleep 3600"]
volumeMounts:
- mountPath: "/volume"
name: my-volume
volumes:
- name: my-volume
persistentVolumeClaim:
claimName: my-pvc