Last active
September 7, 2017 23:13
-
-
Save DStorck/ba30fc08174a8935a97c87d1070bebf4 to your computer and use it in GitHub Desktop.
kubernetes sample configurations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# simple pv | |
kind: PersistentVolume | |
apiVersion: v1 | |
metadata: | |
name: task-pv-volume | |
labels: | |
type: local | |
spec: | |
storageClassName: manual | |
capacity: | |
storage: 10Gi | |
accessModes: | |
- ReadWriteOnce | |
hostPath: | |
path: "/tmp/data" | |
or: | |
emptyDir: | |
path: "/blah" | |
---- | |
kind: PersistentVolumeClaim | |
apiVersion: v1 | |
metadata: | |
name: task-pv-claim | |
spec: | |
storageClassName: manual | |
accessModes: | |
- ReadWriteOnce | |
resources: | |
requests: | |
storage: 3Gi | |
--- | |
apiVersion: extensions/v1beta1 | |
kind: DaemonSet | |
metadata: | |
name: nginx-daemonset | |
spec: | |
template: | |
metadata: | |
labels: | |
app: test-app | |
spec: | |
containers: | |
- name: nginx-daemonset | |
image: nginx | |
ports: | |
- containerPort: 80 | |
# simple pod with multiple containers | |
--- | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: sample-pod | |
spec: | |
containers: | |
- name: nginx | |
image: nginx | |
- name: redis | |
image: redis | |
# simple pod with init-container | |
--- | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: init-demo | |
spec: | |
containers: | |
- name: checker | |
image: busybox | |
command: ['sh', "-c", "if /usr/dir/<file> does not exist...exit" ] | |
volumeMounts: | |
- name: workdir | |
mountPath: /usr/workdir | |
# These containers are run during pod initialization | |
initContainers: | |
- name: touch | |
image: busybox | |
command: ['sh', "-c", "touch /workdir/file.txt;" ] | |
volumeMounts: | |
- name: workdir | |
mountPath: "/workdir" | |
dnsPolicy: Default | |
volumes: | |
- name: workdir | |
emptyDir: {} | |
# deployment with 2 replicas | |
--- | |
apiVersion: apps/v1beta1 | |
kind: Deployment | |
metadata: | |
name: my-nginx | |
spec: | |
replicas: 2 | |
template: | |
metadata: | |
labels: | |
run: my-nginx | |
spec: | |
containers: | |
- name: my-nginx | |
image: nginx | |
ports: | |
- containerPort: 80 | |
# then run kubectl expose deployment/my-nginx to create the service | |
--- | |
apiVersion: batch/v1 | |
kind: Job | |
metadata: | |
name: printer | |
spec: | |
completions: 4 | |
parallelism: 2 | |
template: | |
metadata: | |
name: printer | |
spec: | |
containers: | |
- name: printer | |
image: busybox | |
command: ["sh", "-c", "echo 'hello'"] | |
restartPolicy: Never | |
# then run kubectl get pods --show-all | grep printer | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment