storage introduction

This commit is contained in:
Pamir Erdem
2018-10-22 22:32:35 +03:00
parent 6c4b416151
commit 9fccc9434f
8 changed files with 172 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: nginx:1.7.9
name: test-container
volumeMounts:
- mountPath: /usr/share/nginx/html
name: cache-volume
initContainers:
- name: git-code-downlaod
image: alpine/git
command: ['sh', '-c', 'git clone https://github.com/wlsf82/helloworld.git; mv * /cache ']
volumeMounts:
- mountPath: /cache
name: cache-volume
volumes:
- name: cache-volume
emptyDir: {}

View File

@@ -0,0 +1,20 @@
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: nginx:1.7.9
name: test-container
volumeMounts:
- mountPath: /usr/share/nginx/html
name: cache-volume
- name: git-code-downlaod
image: alpine/git
command: ['sh', '-c', 'while true; do rm -rdf /cache/*; git clone https://github.com/wlsf82/helloworld.git; mv -f helloworld/ /cache; sleep 30; done; ']
volumeMounts:
- mountPath: /cache
name: cache-volume
volumes:
- name: cache-volume
emptyDir: {}

View File

@@ -0,0 +1,27 @@
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: nginx:1.7.9
name: test-container
volumeMounts:
- mountPath: /usr/share/nginx/html
name: cache-volume
initContainers:
- name: template-changer
image: alpine/git
command: ['sh', '-c', 'cp /conf/* /cache; chmod +x /cache/*']
volumeMounts:
- mountPath: /cache
name: cache-volume
- mountPath: /conf
name: conf
volumes:
- name: cache-volume
emptyDir: {}
- name: conf
configMap:
name: mysql-conn

View File

@@ -0,0 +1,14 @@
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: nginx:1.7.9
name: test-container
volumeMounts:
- mountPath: /cache
name: cache-volume
volumes:
- name: cache-volume
emptyDir: {}

View File

@@ -0,0 +1,16 @@
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: nginx:1.7.9
name: test-container
volumeMounts:
- mountPath: /cache
name: cache-volume
volumes:
- name: cache-volume
emptyDir:
medium: Memory
sizeLimit: "1Gi"

View File

@@ -0,0 +1,29 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx-pd
labels:
zone: us-est-coast
cluster: test-cluster1
rack: rack-22
annotations:
build: two
builder: john-doe
spec:
containers:
- name: nginx-pd
image: nginx:1.7.9
volumeMounts:
- name: podinfo
mountPath: /etc/podinfo
readOnly: false
volumes:
- name: podinfo
downwardAPI:
items:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
- path: "annotations"
fieldRef:
fieldPath: metadata.annotations

View File

@@ -0,0 +1,44 @@
### EmptyDir
```bash
vim 01-2-emptydir-pod.yaml
kubectl apply -f 01-2-emptydir-pod.yaml
kubectl port-forward test-pd 8080:80
curl -XGET http://localhost:8080/helloworld/helloworld.html
kubectl delete -f 01-2-emptydir-pod.yaml
```
### Bad Practice
```bash
kubectl apply -f 01-3-emptydir-pod.yaml
kubectl port-forward test-pd 8080:80
curl -XGET http://localhost:8080/helloworld/helloworld.html
kubectl delete -f 01-3-emptydir-pod.yaml
```
### Secret Volume
```bash
echo mysql://root:topsecretpassword@remote_mysql:3306/acedemand > mysql.conn
kubectl create secret generic mysqlconnection --from-file=mysql.conn
kubectl apply -f 03-secretdir.yaml
kubectl exec -it test-pd -- /bin/sh
ls /secret
cat /secret/mysql.conn
```
### configmap readonly
```bash
kubectl create configmap mysql-conn --from-file mysql.conn
kubectl apply -f 01-4-emptydir-pod.yaml
kubectl exec -it test-pd -- /bin/sh
cd /usr/share/nginx/html
ls -lart
# find executable rights
kubectl delete configmap mysql-conn
kubectl delete -f 01-4-emptydir-pod.yaml
```

View File

@@ -0,0 +1 @@
mysql://root:topsecretpassword@remote_mysql:3306/acedemand