Skip to content

Instantly share code, notes, and snippets.

@elsonrodriguez
Last active June 20, 2016 03:27
Show Gist options
  • Save elsonrodriguez/819f4efff11803d4c0bb to your computer and use it in GitHub Desktop.
Save elsonrodriguez/819f4efff11803d4c0bb to your computer and use it in GitHub Desktop.
random kubernetes pv provisioning notes

This is an example of testing Kubernetes volume provisioning.

This will work on a Kubernetes 1.2 beta 0 cluster, provisioned by:

  1. Rsyncing https://github.com/kubernetes/kubernetes/tree/9f62a2b196ad5fad3bc66ef78c5459fb9f072de2/cluster over the cluster directory in this release of k8s: https://github.com/kubernetes/kubernetes/releases/download/v1.2.0-beta.0/kubernetes.tar.gz
  2. Running KUBERNETES_PROVIDER=aws kube-up.sh

After that, kubectl create -f busybox-pvc.yaml and kubectl create -f busybox-rc.yaml

kind: "PersistentVolumeClaim"
apiVersion: "v1"
metadata:
name: "claim1"
annotations:
volume.alpha.kubernetes.io/storage-class: "foo"
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: "3Gi"
apiVersion: v1
kind: ReplicationController
metadata:
labels:
app: pvtest
name: pvtest
spec:
replicas: 1
selector:
app: pvtest
template:
metadata:
labels:
app: pvtest
spec:
containers:
- name: busybox
image: busybox
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /importantdata
name: importantdata
restartPolicy: Always
volumes:
- name: importantdata
persistentVolumeClaim:
claimName: claim1
apiVersion: v1
kind: ReplicationController
metadata:
labels:
name: mongo
name: mongo-controller
spec:
replicas: 1
template:
metadata:
labels:
name: mongo
spec:
containers:
- image: mongo
name: mongo
ports:
- name: mongo
containerPort: 27017
hostPort: 27017
volumeMounts:
- name: mongo-persistent-storage
mountPath: /data/db
volumes:
- name: mongo-persistent-storage
persistentVolumeClaim:
claimName: mongo
kind: "PersistentVolumeClaim"
apiVersion: "v1"
metadata:
name: "mongo"
annotations:
volume.alpha.kubernetes.io/storage-class: "mongo"
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: "30Gi"
apiVersion: v1
kind: Service
metadata:
labels:
name: mongo
name: mongo
spec:
ports:
- port: 27017
targetPort: 27017
selector:
name: mongo
apiVersion: v1
kind: ReplicationController
metadata:
labels:
name: web
name: web-controller
spec:
replicas: 2
selector:
name: web
template:
metadata:
labels:
name: web
spec:
containers:
- image: node:0.10.40
command: ['/bin/sh', '-c']
args: ['cd /home && git clone https://github.com/ijason/NodeJS-Sample-App.git demo && cd demo/EmployeeDB/ && npm install && sed -i -- ''s/localhost/mongo/g'' app.js && node app.js']
name: web
ports:
- containerPort: 3000
name: http-server
livenessProbe:
httpGet:
path: /
port: 3000
timeoutSeconds: 5
initialDelaySeconds: 15
apiVersion: v1
kind: Service
metadata:
name: web
labels:
name: web
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 3000
protocol: TCP
selector:
name: web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment